97 lines
2.4 KiB
Bash
Executable File
97 lines
2.4 KiB
Bash
Executable File
#!/usr/bin/bash
|
|
PANEL_FIFO=/run/user/$(id -u)/lemonbar
|
|
PANEL_HEIGHT=16
|
|
PANEL_FONT="-misc-tamlin-medium-r-normal--16-116-100-100-c-80-iso10646-1"
|
|
PANEL_WM_NAME=bspwm_panel
|
|
|
|
COLOR_BLACK="#000000"
|
|
COLOR_GREY1="#d6d3d2"
|
|
COLOR_GREY2="#a7a5a5"
|
|
COLOR_GREY3="#504e4e"
|
|
|
|
if xdo id -a "$PANEL_WM_NAME" > /dev/null ; then
|
|
printf "%s\n" "The panel is already running." >&2
|
|
exit 1
|
|
fi
|
|
|
|
trap 'trap - TERM; kill 0' INT TERM QUIT EXIT
|
|
|
|
[ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
|
|
mkfifo "$PANEL_FIFO"
|
|
|
|
num_mon=$(bspc query -M | wc -l)
|
|
|
|
conky -c ~/.config/bspwm/conky.conf > "$PANEL_FIFO" &
|
|
bspc config top_padding $PANEL_HEIGHT
|
|
bspc subscribe report > "$PANEL_FIFO" &
|
|
|
|
while read -r line ; do
|
|
case $line in
|
|
S*)
|
|
# conky output
|
|
sys="${line#?}"
|
|
;;
|
|
W*)
|
|
# bspwm's state
|
|
wm=""
|
|
IFS=':'
|
|
mon=0
|
|
set -- ${line#?}
|
|
while [ $# -gt 0 ] ; do
|
|
item=$1
|
|
name=${item#?}
|
|
case $item in
|
|
[mM]*)
|
|
if [ $num_mon -ge 2 ]; then
|
|
mon=$((mon+1))
|
|
if [ $mon -gt 1 ]; then
|
|
wm="${wm}%{F${COLOR_GREY2}}%{B${COLOR_BLACK}};"
|
|
fi
|
|
fi
|
|
;;
|
|
[fFoOuU]*)
|
|
case $item in
|
|
f*)
|
|
# free desktop
|
|
FG=$COLOR_GREY2
|
|
BG=$COLOR_BLACK
|
|
;;
|
|
F*)
|
|
# focused free desktop
|
|
FG=$COLOR_GREY1
|
|
BG=$COLOR_GREY3
|
|
;;
|
|
o*)
|
|
# occupied desktop
|
|
FG=$COLOR_GREY2
|
|
BG=$COLOR_BLACK
|
|
;;
|
|
O*)
|
|
# focused occupied desktop
|
|
FG=$COLOR_GREY1
|
|
BG=$COLOR_GREY3
|
|
;;
|
|
esac
|
|
|
|
wm="${wm}%{F${COLOR_GREY2}}%{B${BG}}%{F${FG}}%{A:bspc desktop -f ${name}:} ${name}%{A}%{F${BG}}%{B${COLOR_GREY2}}"
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
;;
|
|
esac
|
|
|
|
while IFS=';' read -ra array; do
|
|
bar=""
|
|
for item in "${!array[@]}"; do
|
|
bar=${bar}"%{l}${array[${item}]}"
|
|
if [ ${item} -lt $((${#array[@]} - 1)) ]; then
|
|
bar=${bar}"${sys}%{S+}"
|
|
fi
|
|
done
|
|
done <<< ${wm}
|
|
|
|
printf "%s\n" "${bar}%{F${COLOR_GREY2}}%{B${COLOR_BLACK}}${sys}"
|
|
|
|
done < "$PANEL_FIFO" | lemonbar -a 10 -n "$PANEL_WM_NAME" -g x$PANEL_HEIGHT -f "$PANEL_FONT" -F "$COLOR_GREY2" -B "$COLOR_BLACK" | bash
|