mabox-tools/bin/mabox-obstart

96 lines
2.5 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
}
phwmon() {
#kill phwmon.py if running
if phwmonpid=$(pgrep -f phwmon.py); then
kill $phwmonpid
fi
. $HOME/.config/mabox/mabox.conf
if [ $phwmon_monitor == true ];then
[[ $phwmon_cpu == true ]] && cpu="--cpu" || cpu=""
[[ $phwmon_mem == true ]] && mem="--mem" || mem=""
[[ $phwmon_swap == true ]] && swap="--swap" || swap=""
[[ $phwmon_net == true ]] && net="--net" || net=""
[[ $phwmon_io == true ]] && io="--io" || io=""
phwmon.py ${cpu} ${mem} ${swap} ${net} ${io} --task_manager lxtask
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 &
. $HOME/.config/mabox/mabox.conf
#Set config variables if not set or empty; ":" means do nothing
# NEW CONFIG VARIABLES - SET defaults at openbox start
[[ -v phwmon_monitor ]] && : || mb-setvar phwmon_monitor=false
[[ -v phwmon_cpu ]] && : || mb-setvar phwmon_cpu=true
[[ -v phwmon_mem ]] && :|| mb-setvar phwmon_mem=true
[[ -v phwmon_swap ]] && : || mb-setvar phwmon_swap=false
[[ -v phwmon_net ]] && : || mb-setvar phwmon_net=true
[[ -v phwmon_io ]] && : || mb-setvar phwmon_io=false
[[ -v places_tint2pipe ]] && : || mb-setvar places_tint2pipe=true
[[ -v places_quicknav ]] && : || mb-setvar places_quicknav=true
[[ -v places_bookmarks ]] && : || mb-setvar places_bookmarks=true
virtualboxes
if command -v phwmon.py &>/dev/null; then
phwmon
fi
}
case "$1" in
startopenbox) startopenbox;;
virtualboxes) virtualboxes;;
phwmon) phwmon;;
*)
echo -e "Usage $(basename "$0") startopenbox|virtualboxes|phwmon" >&2
exit 1
;;
esac
exit 0