mabox-tools/bin/mabox-obstart

60 lines
1.3 KiB
Plaintext
Raw Normal View History

2020-02-20 01:21:01 +01:00
#!/usr/bin/env bash
2020-02-18 17:24:18 +01:00
#
#
2020-02-20 01:21:01 +01:00
virtualboxes() {
2020-02-26 21:22:40 +01:00
case $LANG in
pl*)
2020-08-24 16:13:01 +02:00
VBOXGUI="VirtualBox GUI"
2020-02-26 21:22:40 +01:00
VBOXES="Maszyny wirtualne"
REFRESH="Odśwież listę"
2020-08-24 16:13:01 +02:00
;;
es*)
VBOXGUI="Interfaz VirtualBox"
VBOXES="Virtual Machines"
REFRESH="Refrescar lista"
;;
2020-02-26 21:22:40 +01:00
*)
2020-08-24 16:13:01 +02:00
VBOXGUI="VirtualBox GUI"
2020-02-26 21:22:40 +01:00
VBOXES="Virtual Machines"
REFRESH="Refresh list"
2020-08-24 16:13:01 +02:00
;;
2020-02-26 21:22:40 +01:00
esac
2020-02-20 01:21:01 +01:00
if [[ -x "$(command -v VBoxManage)" ]]; then
{
2020-02-26 21:22:40 +01:00
printf "%b\n" "^sep($VBOXES)"
2020-08-24 16:13:01 +02:00
printf "%b\n" "$VBOXGUI,virtualbox"
2020-03-02 23:31:28 +01:00
printf "%b\n" "^sep()"
2020-02-20 01:21:01 +01:00
}> $HOME/.config/mabox/vboxes.csv
VBoxManage list -s vms | cut -f 2 -d "\"" | sort -f | while read vm
do
2020-03-14 15:44:30 +01:00
printf "%s\n" "$vm,vboxmanage startvm \"${vm}\"" >>$HOME/.config/mabox/vboxes.csv
2020-02-20 01:21:01 +01:00
done
2020-02-26 21:22:40 +01:00
printf "%s\n%s\n" "^sep()" "$REFRESH,/usr/bin/mabox-obstart virtualboxes" >>$HOME/.config/mabox/vboxes.csv
2020-02-20 01:21:01 +01:00
fi
}
startopenbox() {
2020-02-18 17:24:18 +01:00
# Copy only new files from /etc/xdg/autostart/
config_dir=${XDG_CONFIG_HOME:-$HOME/.config}
rsync -aq --ignore-existing /etc/xdg/autostart/ $config_dir/autostart
# source Mabox main config file
. $HOME/.config/mabox/mabox.conf
# Run mwelcome if not disaled
2020-02-20 01:21:01 +01:00
[ $show_welcome == true ] && mwelcome &
virtualboxes
}
case "$1" in
startopenbox) startopenbox;;
virtualboxes) virtualboxes;;
*)
echo -e "Usage $(basename "$0") startopenbox|virtualboxes" >&2
exit 1
;;
esac
exit 0