mabox-tools/bin/mabox-obstart

58 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
#
#
virtualboxes() {
case $LANG in
pl*)
VBOXGUI="VirtualBox GUI"
VBOXES="Maszyny wirtualne"
REFRESH="Odśwież listę"
;;
es*)
VBOXGUI="Interfaz VirtualBox"
VBOXES="Virtual Machines"
REFRESH="Refrescar lista"
;;
*)
VBOXGUI="VirtualBox GUI"
VBOXES="Virtual Machines"
REFRESH="Refresh list"
;;
esac
if [[ -x "$(command -v VBoxManage)" ]]; then
{
printf "%b\n" "^sep($VBOXES)"
printf "%b\n" "$VBOXGUI,virtualbox"
printf "%b\n" "^sep()"
}> $HOME/.config/mabox/vboxes.csv
VBoxManage list -s vms | cut -f 2 -d "\"" | sort -f | while read vm
do
printf "%s\n" "$vm,vboxmanage startvm \"${vm}\"" >>$HOME/.config/mabox/vboxes.csv
done
printf "%s\n%s\n" "^sep()" "$REFRESH,/usr/bin/mabox-obstart virtualboxes" >>$HOME/.config/mabox/vboxes.csv
fi
}
startopenbox() {
# 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
# Run mwelcome if not disaled
[ ! -f "$HOME/.config/mabox/.mwelcome" ] && mwelcome &
virtualboxes
}
case "$1" in
startopenbox) startopenbox;;
virtualboxes) virtualboxes;;
*)
echo -e "Usage $(basename "$0") startopenbox|virtualboxes" >&2
exit 1
;;
esac
exit 0