2017-12-01 00:21:33 -06:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2017-12-05 21:50:28 -06:00
|
|
|
# Polybar launcher script written by Nathaniel Maia for use in ArchLabs
|
2017-12-17 12:06:39 -06:00
|
|
|
# Will launch bars depending on WM
|
2017-12-05 21:50:28 -06:00
|
|
|
# Can also be used to reload openbox session with [--reload] or [-r]
|
|
|
|
|
2017-12-17 12:06:39 -06:00
|
|
|
# I reccomend using al-polyzen to set up a session for each wm
|
2017-12-18 11:26:53 -06:00
|
|
|
# then ditching this script and adding the following line to your autostart
|
2017-12-17 12:06:39 -06:00
|
|
|
# sleep 1; al-polybar-session &
|
2017-12-05 21:50:28 -06:00
|
|
|
|
2017-12-17 12:06:39 -06:00
|
|
|
|
|
|
|
# Enter your bar names here (seperated by spaces) eg. BARS=(bar1 bar2...)
|
|
|
|
# This will be combined with window manager from WMS below eg. openbox-bar1, openbox-bar2...
|
|
|
|
# by default it is set up in WM-BAR naming format eg. i3-bar, openbox-bar, bspwm-bar....
|
2017-12-01 00:21:33 -06:00
|
|
|
BARS=(bar)
|
2017-12-02 01:06:11 -06:00
|
|
|
CONFIG=$HOME/.config/polybar/config
|
2017-12-17 12:06:39 -06:00
|
|
|
WMS=(bspwm i3 openbox xfce awesome)
|
|
|
|
|
|
|
|
############################################################################################
|
|
|
|
|
2017-12-07 22:20:42 -06:00
|
|
|
|
|
|
|
HELP="\nUSAGE:\n\tstart-polybar [OPTIONS]
|
|
|
|
\nOPTIONS:\n\t--reload, -r\tIf running in openbox, will reload the session
|
|
|
|
\t--help, -h\tPrint this usage message and exit
|
|
|
|
\n\tWith no options the script will stop and reload polybar"
|
|
|
|
|
2017-12-08 04:03:03 -06:00
|
|
|
# determine WM
|
2017-12-07 22:20:42 -06:00
|
|
|
for i in ${WMS[@]}; do
|
|
|
|
if [[ "$(wmctrl -m | grep -i name | awk '{print tolower($2)}')" == "$i" ]]; then
|
|
|
|
WM=$i && break
|
|
|
|
elif [[ "$(xprop -root -notype | grep "WM_NAME =" | tr -d '"' | awk '{print tolower($3)}')" == "$i" ]]; then
|
|
|
|
WM=$i && break
|
|
|
|
elif [[ "$(awk '{print tolower($0)}' <<< $XDG_CURRENT_DESKTOP)" == "$i" ]]; then
|
|
|
|
WM=$i && break
|
2017-12-17 12:06:39 -06:00
|
|
|
fi
|
2017-12-07 22:20:42 -06:00
|
|
|
done
|
|
|
|
|
2017-12-08 04:03:03 -06:00
|
|
|
# check if passed options
|
2017-12-07 22:20:42 -06:00
|
|
|
case "$@" in
|
|
|
|
*help|-h)
|
|
|
|
echo -e $HELP && exit 0
|
|
|
|
;;
|
|
|
|
*reload|-r)
|
2017-12-08 04:03:03 -06:00
|
|
|
if [[ "$WM" == "openbox" ]]; then
|
2017-12-07 22:20:42 -06:00
|
|
|
openbox --restart
|
|
|
|
al-compositor --restart && al-tint2restart
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
2017-12-05 21:50:28 -06:00
|
|
|
|
2017-12-08 04:03:03 -06:00
|
|
|
# kill running bars
|
|
|
|
while [ "$(pidof polybar)" ]; do
|
|
|
|
pkill polybar && sleep 0.5
|
|
|
|
done
|
|
|
|
|
|
|
|
# launch bars
|
|
|
|
for bar in "${BARS[@]}"; do
|
|
|
|
polybar -r --config=$CONFIG ${WM}-$bar &
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "$(pidof polybar)" ]; then
|
2017-12-05 22:58:10 -06:00
|
|
|
echo "Bars launched..."
|
2017-12-08 04:03:03 -06:00
|
|
|
else
|
|
|
|
echo "Bars Failed to Launch"
|
2017-12-01 00:21:33 -06:00
|
|
|
fi
|