121 lines
3.9 KiB
Bash
Executable file
121 lines
3.9 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
if [[ "$1" = -k ]]; then
|
|
pkill -f '^[bd]ash .+/panel$'
|
|
exit
|
|
elif pgrep lemonbar >/dev/null; then
|
|
>&2 echo "Lemonbar is already running"
|
|
exit 1
|
|
fi
|
|
|
|
CWD=$(dirname $0)
|
|
. $CWD/panel-config
|
|
|
|
#
|
|
cleanup() { rm -rf "$PANEL_FIFO"; pkill -P $$; }
|
|
|
|
#
|
|
trap cleanup INT TERM QUIT EXIT
|
|
[ -e "$PANEL_FIFO" ] && rm -f "$PANEL_FIFO"
|
|
mkfifo "$PANEL_FIFO"
|
|
echo "MKFIFO $PANEL_FIFO"
|
|
|
|
|
|
#
|
|
# Bootstrap panel(s)
|
|
#
|
|
|
|
clock -sf "D%A, %b %d %I:%M %p" > "${PANEL_FIFO}" &
|
|
xtitle -sf 'X%s' > "${PANEL_FIFO}" &
|
|
bspc subscribe report > "${PANEL_FIFO}" &
|
|
|
|
for lemon in $CWD/lemons/*; do
|
|
if [[ -f "$lemon" ]]; then
|
|
echo "INIT ${lemon##*/}"
|
|
$lemon > "${PANEL_FIFO}" &
|
|
fi
|
|
done
|
|
|
|
#
|
|
parse() {
|
|
num_mon=$(bspc query -M | wc -l)
|
|
while read -r line; do
|
|
data="${line#?}"
|
|
case $line in
|
|
# Minimal icons
|
|
B*) battery=" $data " ;;
|
|
U*) updates=" $data " ;;
|
|
M*) mail=" $data " ;;
|
|
V*) vol=" %{A:vol toggle:}$data${A} " ;;
|
|
I*) wifi=" $data " ;;
|
|
I*) wifi=" $data " ;;
|
|
|
|
# Full segments
|
|
X*) xtitle="$data" ;;
|
|
D*) datetime=" $data " ;;
|
|
S*) song="$data " ;;
|
|
W*) # bspwm's state
|
|
wm=
|
|
IFS=':'
|
|
set -- $data
|
|
while [ "$#" -gt 0 ]
|
|
do
|
|
id=$1
|
|
name=${id#?}
|
|
case $id in
|
|
[mM]*)
|
|
M="$name"
|
|
[[ $M != "C" ]] && M=
|
|
# [ "$num_mon" -lt 2 ] && shift && continue
|
|
# case $id in
|
|
# m*) # monitor
|
|
# _FG=$COLOR_MONITOR_FG
|
|
# _BG=$COLOR_MONITOR_BG
|
|
# ;;
|
|
# M*) # focused monitor
|
|
# _FG=$COLOR_FOCUSED_MONITOR_FG
|
|
# _BG=$COLOR_FOCUSED_MONITOR_BG
|
|
# ;;
|
|
# esac
|
|
# wm="${wm}%{F$_FG}%{B$_BG}%{A:bspc monitor -f ${name}:} ${name} %{A}%{B-}%{F-}"
|
|
;;
|
|
[fFoOuU]*)
|
|
if [[ $M ]]; then
|
|
icon="$ICON_FULL"
|
|
case $id in
|
|
f*) _FG=$COLOR_FREE_FG icon="$ICON_NONE" ;; # free desktop
|
|
F*) _FG=$COLOR_FOCUSED_FREE_FG icon="$ICON_NONE" ;; # focused free desktop
|
|
o*) _FG=$COLOR_OCCUPIED_FG ;; # occupied desktop
|
|
O*) _FG=$COLOR_FOCUSED_OCCUPIED_FG ;; # focused occupied desktop
|
|
u*) _FG=$COLOR_URGENT_FG ;; # urgent desktop
|
|
U*) _FG=$COLOR_FOCUSED_URGENT_FG ;; # focused urgent desktop
|
|
esac
|
|
eval "icon=\$ICON_$(echo ${name#??})"
|
|
# wm="${wm}%{F$_FG}%{A:bspc desktop -f ${name}:} ${icon:-$name} %{A}%{F-}"
|
|
wm="${wm}%{F$_FG}%{A:bspc desktop -f ${name}:} ${icon:-$name} %{A}%{B-}%{F-}"
|
|
fi
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
;;
|
|
esac
|
|
echo -e \
|
|
"%{l} ${xtitle}${song}" \
|
|
"%{c}${wm}" \
|
|
"%{r}${battery}${mail}${updates}${vol}${wifi} ${datetime}"
|
|
done
|
|
}
|
|
|
|
parse < "${PANEL_FIFO}" | \
|
|
lemonbar \
|
|
-a 32 \
|
|
-g 2560x$PANEL_HEIGHT+1200+0 \
|
|
-f "$PANEL_FONT" \
|
|
-f "$ICON_FONT" \
|
|
-F "$COLOR_FG" \
|
|
-B "$COLOR_BG" \
|
|
| sh &
|
|
|
|
wait
|