os/arch (lemonbar): more error handling in panel bootstrap

This commit is contained in:
Henrik Lissner 2017-01-03 03:50:10 -05:00
parent a78820f469
commit 12a5de6de3

View file

@ -1,8 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if [ "$1" = "-k" ]; then if [[ "$1" = -k ]]; then
pkill -f '^bash .+/panel$' pkill -f '^[bd]ash .+/panel$'
exit exit
elif pgrep lemonbar >/dev/null; then
>&2 echo "Lemonbar is already running"
exit 1
fi fi
CWD=$(dirname $0) CWD=$(dirname $0)
@ -13,15 +16,10 @@ cleanup() { rm -rf "$PANEL_FIFO"; pkill -P $$; }
# #
trap cleanup INT TERM QUIT EXIT trap cleanup INT TERM QUIT EXIT
[ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO" [ -e "$PANEL_FIFO" ] && rm -f "$PANEL_FIFO"
mkfifo "$PANEL_FIFO" mkfifo "$PANEL_FIFO"
echo "MKFIFO $PANEL_FIFO" echo "MKFIFO $PANEL_FIFO"
if pgrep lemonbar >/dev/null; then
>&2 echo "Lemonbar is already running"
exit 1
fi
# #
# Bootstrap panel(s) # Bootstrap panel(s)
@ -32,8 +30,10 @@ xtitle -sf 'X%s' > "${PANEL_FIFO}" &
bspc subscribe report > "${PANEL_FIFO}" & bspc subscribe report > "${PANEL_FIFO}" &
for lemon in $CWD/lemons/*; do for lemon in $CWD/lemons/*; do
if [[ -f "$lemon" ]]; then
echo "INIT ${lemon##*/}" echo "INIT ${lemon##*/}"
$lemon > "${PANEL_FIFO}" & $lemon > "${PANEL_FIFO}" &
fi
done done
# #