2016-11-04 17:50:03 -07:00
|
|
|
#!/usr/bin/env dash
|
2016-10-19 07:56:37 -07:00
|
|
|
|
2016-11-04 17:50:03 -07:00
|
|
|
if [ "$1" = "--kill" ]
|
2016-11-03 10:47:41 -07:00
|
|
|
then
|
2016-11-05 08:27:30 -07:00
|
|
|
pkill -f '^dash .+/panel$'
|
2016-11-03 10:47:41 -07:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2016-11-02 16:58:47 -07:00
|
|
|
CWD="$(cd $(dirname $0) && pwd -P)"
|
2016-11-04 17:50:03 -07:00
|
|
|
. $CWD/panel-config
|
|
|
|
|
2016-10-19 07:56:37 -07:00
|
|
|
|
2016-10-31 19:07:23 -07:00
|
|
|
#
|
2016-11-03 10:47:41 -07:00
|
|
|
running() { pgrep -f $1 >/dev/null; }
|
2016-11-05 08:27:30 -07:00
|
|
|
cleanup() { rm -rf "$PANEL_FIFO"; pkill -P $$; }
|
2016-10-31 19:07:23 -07:00
|
|
|
|
2016-11-03 10:47:41 -07:00
|
|
|
#
|
|
|
|
trap cleanup INT TERM QUIT EXIT
|
|
|
|
[ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
|
|
|
|
mkfifo "$PANEL_FIFO"
|
2016-11-04 17:50:03 -07:00
|
|
|
echo "MKFIFO $PANEL_FIFO"
|
2016-11-03 10:47:41 -07:00
|
|
|
|
|
|
|
if running lemonbar
|
2016-11-02 16:58:47 -07:00
|
|
|
then
|
2016-11-03 10:47:41 -07:00
|
|
|
2>&1 echo "Lemonbar already running"
|
|
|
|
exit 1
|
2016-11-02 16:58:47 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Bootstrap panel(s)
|
|
|
|
#
|
|
|
|
|
2016-11-06 16:40:02 -08:00
|
|
|
clock -sf "T${ICON_DATE} %A, %b %d ${ICON_TIME} %I:%M%p" > "${PANEL_FIFO}" &
|
2016-11-04 17:50:03 -07:00
|
|
|
xtitle -sf 'X%s' > "${PANEL_FIFO}" &
|
|
|
|
bspc subscribe report > "${PANEL_FIFO}" &
|
2016-10-31 19:07:23 -07:00
|
|
|
|
2016-11-06 16:40:02 -08:00
|
|
|
for lemon in $CWD/lemons/*
|
2016-11-02 16:58:47 -07:00
|
|
|
do
|
2016-11-06 16:40:02 -08:00
|
|
|
echo "INIT $(basename $lemon)"
|
|
|
|
$lemon > "${PANEL_FIFO}" &
|
2016-11-02 16:58:47 -07:00
|
|
|
done
|
|
|
|
|
|
|
|
#
|
|
|
|
parse() {
|
|
|
|
num_mon=$(bspc query -M | wc -l)
|
|
|
|
while read -r line
|
2016-10-31 19:07:23 -07:00
|
|
|
do
|
2016-11-02 16:58:47 -07:00
|
|
|
data="${line#?}"
|
|
|
|
case $line in
|
|
|
|
# Minimal icons
|
2016-11-06 16:40:02 -08:00
|
|
|
B*) battery="$data"
|
2016-11-05 08:27:49 -07:00
|
|
|
;;
|
2016-11-06 16:40:02 -08:00
|
|
|
U*) updates=" $data"
|
2016-11-02 16:58:47 -07:00
|
|
|
;;
|
2016-11-06 16:40:02 -08:00
|
|
|
M*) mail=" $data"
|
2016-11-02 16:58:47 -07:00
|
|
|
;;
|
2016-11-06 16:40:02 -08:00
|
|
|
V*) vol=" $data"
|
2016-11-02 16:58:47 -07:00
|
|
|
;;
|
2016-11-06 16:40:02 -08:00
|
|
|
I*) wifi=" $data"
|
2016-11-02 16:58:47 -07:00
|
|
|
;;
|
2016-11-04 17:50:03 -07:00
|
|
|
|
|
|
|
# Full segments
|
2016-11-02 16:58:47 -07:00
|
|
|
E*) # TODO ethernet
|
|
|
|
;;
|
2016-11-04 17:50:03 -07:00
|
|
|
X*) xtitle="$data"
|
2016-11-02 16:58:47 -07:00
|
|
|
;;
|
2016-11-06 16:40:02 -08:00
|
|
|
T*) datetime=" $data"
|
2016-11-02 16:58:47 -07:00
|
|
|
;;
|
2016-11-06 16:40:02 -08:00
|
|
|
S*) song="$data "
|
2016-11-02 16:58:47 -07:00
|
|
|
;;
|
|
|
|
W*) # bspwm's state
|
|
|
|
wm=""
|
|
|
|
IFS=':'
|
|
|
|
set -- $data
|
2016-11-04 17:50:03 -07:00
|
|
|
while [ "$#" -gt 0 ]
|
2016-11-02 16:58:47 -07:00
|
|
|
do
|
|
|
|
id=$1
|
|
|
|
name=${id#???}
|
|
|
|
case $id in
|
|
|
|
[mM]*)
|
2016-11-04 17:50:03 -07:00
|
|
|
[ "$num_mon" -lt 2 ] && shift && continue
|
2016-11-02 16:58:47 -07:00
|
|
|
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 ${id}:} ${name} %{A}%{B-}%{F-}"
|
|
|
|
;;
|
|
|
|
[fFoOuU]*)
|
|
|
|
case $id in
|
|
|
|
f*) # free desktop
|
|
|
|
_FG=$COLOR_FREE_FG
|
|
|
|
_BG=$COLOR_FREE_BG
|
|
|
|
;;
|
|
|
|
F*) # focused free desktop
|
|
|
|
_FG=$COLOR_FOCUSED_FREE_FG
|
|
|
|
_BG=$COLOR_FOCUSED_FREE_BG
|
|
|
|
;;
|
|
|
|
o*) # occupied desktop
|
|
|
|
_FG=$COLOR_OCCUPIED_FG
|
|
|
|
_BG=$COLOR_OCCUPIED_BG
|
|
|
|
;;
|
|
|
|
O*) # focused occupied desktop
|
|
|
|
_FG=$COLOR_FOCUSED_OCCUPIED_FG
|
|
|
|
_BG=$COLOR_FOCUSED_OCCUPIED_BG
|
|
|
|
;;
|
|
|
|
u*) # urgent desktop
|
|
|
|
_FG=$COLOR_URGENT_FG
|
|
|
|
_BG=$COLOR_URGENT_BG
|
|
|
|
;;
|
|
|
|
U*) # focused urgent desktop
|
|
|
|
_FG=$COLOR_FOCUSED_URGENT_FG
|
|
|
|
_BG=$COLOR_FOCUSED_URGENT_BG
|
|
|
|
;;
|
|
|
|
esac
|
2016-11-04 17:50:03 -07:00
|
|
|
eval "icon=\$ICON_$name"
|
|
|
|
wm="${wm}%{F$_FG}%{B$_BG}%{A:bspc desktop -f ${id#?}:} ${icon:-$name} %{A}%{B-}%{F-}"
|
2016-11-02 16:58:47 -07:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
echo -e \
|
|
|
|
"%{l}${wm}${song}" \
|
2016-11-04 17:50:03 -07:00
|
|
|
"%{c}${xtitle}" \
|
2016-11-05 08:27:49 -07:00
|
|
|
"%{r}${battery}${mail}${updates}${vol}${wifi}${datetime} "
|
2016-10-31 19:07:23 -07:00
|
|
|
done
|
2016-11-02 16:58:47 -07:00
|
|
|
}
|
2016-10-31 19:07:23 -07:00
|
|
|
|
2016-11-04 17:50:03 -07:00
|
|
|
parse < "${PANEL_FIFO}" | \
|
2016-11-02 16:58:47 -07:00
|
|
|
lemonbar \
|
|
|
|
-a 32 \
|
|
|
|
-g x$PANEL_HEIGHT \
|
|
|
|
-f "$PANEL_FONT" \
|
|
|
|
-f "$ICON_FONT" \
|
2016-11-04 17:50:03 -07:00
|
|
|
-F "$COLOR_FG" \
|
|
|
|
-B "$COLOR_BG" \
|
2016-11-02 16:58:47 -07:00
|
|
|
| sh &
|
2016-10-19 07:56:37 -07:00
|
|
|
|
2016-11-02 16:58:47 -07:00
|
|
|
wait
|