From 15c324b0303827feb739b527e61ddad14c84c6e5 Mon Sep 17 00:00:00 2001 From: natemaia Date: Fri, 8 Dec 2017 02:03:03 -0800 Subject: [PATCH] Fix polybar script issue --- home/bin/start-compton | 10 +++++++--- home/bin/start-polybar | 37 ++++++++++++++++++++++--------------- home/bin/stop-polybar | 6 +++--- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/home/bin/start-compton b/home/bin/start-compton index 307ec21b..f397ec76 100755 --- a/home/bin/start-compton +++ b/home/bin/start-compton @@ -1,10 +1,14 @@ #!/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 elif [ -e "$HOME/.config/.composite_enabled" ]; then al-compositor --start else - echo -e "Compositing in not enabled.. Requires ~/.config/.composite_enabled - \n\nTry running paranoid and enabling compositing" + echo "#Compositing enabled" > $HOME/.config/.composite_enabled + if [ "$(pidof compton)" ]; then + al-compositor --start + else + al-compositor --restart + fi fi diff --git a/home/bin/start-polybar b/home/bin/start-polybar index 140d969b..e05c1d89 100755 --- a/home/bin/start-polybar +++ b/home/bin/start-polybar @@ -17,6 +17,7 @@ HELP="\nUSAGE:\n\tstart-polybar [OPTIONS] \t--help, -h\tPrint this usage message and exit \n\tWith no options the script will stop and reload polybar" +# determine WM for i in ${WMS[@]}; do if [[ "$(wmctrl -m | grep -i name | awk '{print tolower($2)}')" == "$i" ]]; then WM=$i && break @@ -27,32 +28,38 @@ for i in ${WMS[@]}; do fi done +# check if passed options case "$@" in *help|-h) echo -e $HELP && exit 0 ;; *reload|-r) - if [[ "$CUR_WM" == "openbox" ]]; then + if [[ "$WM" == "openbox" ]]; then openbox --restart al-compositor --restart && al-tint2restart fi ;; - *) - : - ;; esac -if pgrep tint2 >/dev/null; then - echo "Tint is running... Exiting" && exit 0 -else - while pgrep polybar >/dev/null; do - pkill polybar && sleep 0.5 - done - echo "Using $CUR_WM... Launching Bars" - for bar in "${BARS[@]}"; do - polybar -r --config=$CONFIG ${CUR_WM}-$bar & - done + +# bail if tint2 is running +if [ "$(pidof tint2)" ]; then exit 0; fi + + +# 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 echo "Bars launched..." +else + echo "Bars Failed to Launch" fi - diff --git a/home/bin/stop-polybar b/home/bin/stop-polybar index db443a0e..36364ab1 100755 --- a/home/bin/stop-polybar +++ b/home/bin/stop-polybar @@ -1,6 +1,6 @@ #!/usr/bin/env bash -while pgrep polybar >/dev/null; do - killall -q polybar && sleep 0.5 +while [ "$(pidof polybar)" ]; do + pkill polybar && sleep 0.5 + echo "Bars stopped..." done -echo "Bars stopped..."