mabox-tools/bin/mabox-obstart

123 lines
4.0 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
sleep 1
fi
. $HOME/.config/mabox/mabox.conf
if [ $phwmon_monitor = true ];then
#Set config variables if not set or empty; ":" means do nothing
[[ -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 phwmon_bgcolor ]] && : || mb-setvar phwmon_bgcolor=#30303080
[[ -v phwmon_alertcolor ]] && : || mb-setvar phwmon_alertcolor=#ff0000
[[ -v phwmon_cpucolor ]] && : || mb-setvar phwmon_cpucolor=#70b433
[[ -v phwmon_memcolor ]] && :|| mb-setvar phwmon_memcolor=#efc541
[[ -v phwmon_swapcolor ]] && : || mb-setvar phwmon_swapcolor=#ff81ca
[[ -v phwmon_netcolor ]] && : || mb-setvar phwmon_netcolor=#368aeb
[[ -v phwmon_iocolor ]] && : || mb-setvar phwmon_iocolor=#ff5e56
[[ -v phwmon_iconsize ]] && : || mb-setvar phwmon_iconsize=32
bg="--bg=${phwmon_bgcolor:-#30303080}"
fg_alert="--fg_alert=${phwmon_alertcolor:-#ff0000}"
fg_cpu="--fg_cpu=${phwmon_cpucolor:-#70b433}"
fg_mem="--fg_mem=${phwmon_memcolor:-#efc541}"
fg_swap="--fg_swap=${phwmon_swapcolor:-#ff81ca}"
fg_net="--fg_net=${phwmon_netcolor:-#368aeb}"
fg_io="--fg_io=${phwmon_iocolor:-#ff5e56}"
iconsize="--size=${phwmon_iconsize:-32}"
[[ $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
phwmon.py ${cpu} ${mem} ${swap} ${net} ${io} ${bg} ${fg_alert} ${fg_cpu} ${fg_mem} ${fg_swap} ${fg_net} ${fg_io} ${iconsize} --task_manager="lxtask"
fi
}
checkautostart () {
# 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
}
startopenbox() {
checkautostart
# 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 places_tint2pipe ]] && : || mb-setvar places_tint2pipe=true
[[ -v places_quicknav ]] && : || mb-setvar places_quicknav=true
[[ -v places_bookmarks ]] && : || mb-setvar places_bookmarks=true
[[ -v places_vboxes ]] && : || mb-setvar places_vboxes=false
[[ -v menu_sep_font_family ]] && : || mb-setvar "menu_sep_font_family='Noto Sans Bold'"
[[ -v menu_sep_font_size ]] && : || mb-setvar menu_sep_font_size=10
[[ -v item_height_factor ]] && : || mb-setvar item_height_factor=200
virtualboxes
if command -v phwmon.py &>/dev/null; then
phwmon
fi
}
case "$1" in
startopenbox) startopenbox;;
checkautostart) checkautostart;;
virtualboxes) virtualboxes;;
phwmon) phwmon;;
*)
echo -e "Usage $(basename "$0") startopenbox|checkautostart|virtualboxes|phwmon" >&2
exit 1
;;
esac
exit 0