mabox-tools/bin/mabox-obstart

134 lines
4.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
}
phwmon() {
#kill phwmon.py if running
if phwmonpid=$(pgrep -f phwmon.py); then
kill $phwmonpid
2022-04-26 20:23:05 +02:00
sleep 1
fi
. $HOME/.config/mabox/mabox.conf
2021-09-08 00:45:45 +02:00
if [ $phwmon_monitor = true ];then
2022-04-26 20:23:05 +02:00
#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
2022-04-26 20:43:02 +02:00
[[ -v phwmon_bgcolor ]] && : || mb-setvar phwmon_bgcolor=#30303080
2022-04-26 20:23:05 +02:00
[[ -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
2022-04-26 20:43:02 +02:00
bg="--bg=${phwmon_bgcolor:-#30303080}"
2022-04-26 20:23:05 +02:00
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}"
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=""
2022-04-26 20:23:05 +02:00
#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
}
2022-04-10 21:42:46 +02:00
checkautostart () {
# Copy only new files from /etc/xdg/autostart/
2020-02-18 17:24:18 +01:00
config_dir=${XDG_CONFIG_HOME:-$HOME/.config}
2022-04-10 21:42:46 +02:00
rsync -aq --ignore-existing /etc/xdg/autostart/ $config_dir/autostart
}
startopenbox() {
checkautostart
2021-11-05 13:47:29 +01:00
2020-02-18 17:24:18 +01:00
# Run mwelcome if not disaled
2020-09-21 15:25:36 +02:00
[ ! -f "$HOME/.config/mabox/.mwelcome" ] && mwelcome &
2022-06-06 16:55:24 +02:00
# [ -f "$HOME/.config/wpg/.mabox-init" ] && wpg-mabox-init &
2022-05-27 00:17:29 +02:00
2023-01-17 13:54:30 +01:00
# rename old wrappers, they now in /usr/local/bin
wrappers=(nitrogen i3lock xrandr lxappearance skippy-xd-fix)
for wrapper in "${wrappers[@]}"
do
2023-01-17 14:29:22 +01:00
[[ -f "$HOME/.local/bin/${wrapper}" ]] && mv "$HOME/.local/bin/${wrapper}" "$HOME/.local/bin/${wrapper}.old"
2023-01-17 14:20:13 +01:00
done
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
2022-04-26 20:23:05 +02:00
[[ -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
2022-05-14 01:42:45 +02:00
[[ -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
2020-02-20 01:21:01 +01:00
virtualboxes
if command -v phwmon.py &>/dev/null; then
phwmon
fi
2024-02-12 07:28:04 +01:00
PKGS=$(checkupdates | wc -l)
mb-setvar updates=${PKGS}
2020-02-20 01:21:01 +01:00
}
case "$1" in
startopenbox) startopenbox;;
2022-04-10 21:42:46 +02:00
checkautostart) checkautostart;;
2020-02-20 01:21:01 +01:00
virtualboxes) virtualboxes;;
phwmon) phwmon;;
2020-02-20 01:21:01 +01:00
*)
2022-04-26 20:23:05 +02:00
echo -e "Usage $(basename "$0") startopenbox|checkautostart|virtualboxes|phwmon" >&2
2020-02-20 01:21:01 +01:00
exit 1
;;
esac
exit 0