Fix polybar script issue

This commit is contained in:
natemaia 2017-12-08 02:03:03 -08:00
parent ea01d6facd
commit 15c324b030
3 changed files with 32 additions and 21 deletions

View File

@ -1,10 +1,14 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if [ -e "$HOME/.config/.composite_enabled" ] && pgrep compton >/dev/null; then if [ -e "$HOME/.config/.composite_enabled" ] && [ "$(pidof compton)" ]; then
al-compositor --restart al-compositor --restart
elif [ -e "$HOME/.config/.composite_enabled" ]; then elif [ -e "$HOME/.config/.composite_enabled" ]; then
al-compositor --start al-compositor --start
else else
echo -e "Compositing in not enabled.. Requires ~/.config/.composite_enabled echo "#Compositing enabled" > $HOME/.config/.composite_enabled
\n\nTry running paranoid and enabling compositing" if [ "$(pidof compton)" ]; then
al-compositor --start
else
al-compositor --restart
fi
fi fi

View File

@ -17,6 +17,7 @@ HELP="\nUSAGE:\n\tstart-polybar [OPTIONS]
\t--help, -h\tPrint this usage message and exit \t--help, -h\tPrint this usage message and exit
\n\tWith no options the script will stop and reload polybar" \n\tWith no options the script will stop and reload polybar"
# determine WM
for i in ${WMS[@]}; do for i in ${WMS[@]}; do
if [[ "$(wmctrl -m | grep -i name | awk '{print tolower($2)}')" == "$i" ]]; then if [[ "$(wmctrl -m | grep -i name | awk '{print tolower($2)}')" == "$i" ]]; then
WM=$i && break WM=$i && break
@ -27,32 +28,38 @@ for i in ${WMS[@]}; do
fi fi
done done
# check if passed options
case "$@" in case "$@" in
*help|-h) *help|-h)
echo -e $HELP && exit 0 echo -e $HELP && exit 0
;; ;;
*reload|-r) *reload|-r)
if [[ "$CUR_WM" == "openbox" ]]; then if [[ "$WM" == "openbox" ]]; then
openbox --restart openbox --restart
al-compositor --restart && al-tint2restart al-compositor --restart && al-tint2restart
fi fi
;; ;;
*)
:
;;
esac esac
if pgrep tint2 >/dev/null; then
echo "Tint is running... Exiting" && exit 0 # bail if tint2 is running
else if [ "$(pidof tint2)" ]; then exit 0; fi
while pgrep polybar >/dev/null; do
# kill running bars
while [ "$(pidof polybar)" ]; do
pkill polybar && sleep 0.5 pkill polybar && sleep 0.5
done done
echo "Using $CUR_WM... Launching Bars"
for bar in "${BARS[@]}"; do
polybar -r --config=$CONFIG ${CUR_WM}-$bar & # launch bars
done for bar in "${BARS[@]}"; do
polybar -r --config=$CONFIG ${WM}-$bar &
done
if [ "$(pidof polybar)" ]; then
echo "Bars launched..." echo "Bars launched..."
else
echo "Bars Failed to Launch"
fi fi

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
while pgrep polybar >/dev/null; do while [ "$(pidof polybar)" ]; do
killall -q polybar && sleep 0.5 pkill polybar && sleep 0.5
echo "Bars stopped..."
done done
echo "Bars stopped..."