mabox-tools/bin/mabox-obstart

97 lines
2.6 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
}
phwmon() {
#kill phwmon.py if running
if phwmonpid=$(pgrep -f phwmon.py); then
kill $phwmonpid
fi
. $HOME/.config/mabox/mabox.conf
2021-09-08 00:45:45 +02:00
if [ $phwmon_monitor = true ];then
2021-09-08 00:45:45 +02:00
[[ $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
}
2020-02-20 01:21:01 +01:00
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
# Run mwelcome if not disaled
2020-09-21 15:25:36 +02:00
[ ! -f "$HOME/.config/mabox/.mwelcome" ] && mwelcome &
2020-02-18 17:24:18 +01:00
. $HOME/.config/mabox/mabox.conf
#Set config variables if not set or empty; ":" means do nothing
# NEW CONFIG VARIABLES - SET defaults at openbox start
2021-09-08 00:45:45 +02:00
[[ -v phwmon_monitor ]] && : || mb-setvar phwmon_monitor=true
[[ -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
2021-09-08 00:45:45 +02:00
[[ -v places_vboxes ]] && : || mb-setvar places_vboxes=false
2020-02-20 01:21:01 +01:00
virtualboxes
if command -v phwmon.py &>/dev/null; then
phwmon
fi
2020-02-20 01:21:01 +01:00
}
case "$1" in
startopenbox) startopenbox;;
virtualboxes) virtualboxes;;
phwmon) phwmon;;
2020-02-20 01:21:01 +01:00
*)
echo -e "Usage $(basename "$0") startopenbox|virtualboxes|phwmon" >&2
2020-02-20 01:21:01 +01:00
exit 1
;;
esac
exit 0