bspwm/examples/panel/panel_bar

119 lines
2.6 KiB
Text
Raw Normal View History

2012-12-27 22:37:16 +01:00
#! /bin/sh
2012-12-19 15:50:42 +01:00
#
2015-12-22 19:25:45 +01:00
# Example panel for lemonbar
2012-12-19 15:50:42 +01:00
2014-07-19 15:26:06 +02:00
. panel_colors
num_mon=$(bspc query -M | wc -l)
2012-12-19 15:50:42 +01:00
while read -r line ; do
2014-01-21 20:48:49 +01:00
case $line in
S*)
# clock output
2015-12-22 19:25:45 +01:00
sys="%{F$COLOR_SYS_FG}%{B$COLOR_SYS_BG} ${line#?} %{B-}%{F-}"
2014-01-21 20:48:49 +01:00
;;
T*)
# xtitle output
2014-07-19 15:26:06 +02:00
title="%{F$COLOR_TITLE_FG}%{B$COLOR_TITLE_BG} ${line#?} %{B-}%{F-}"
2014-01-21 20:48:49 +01:00
;;
W*)
2015-12-22 19:25:45 +01:00
# bspwm's state
wm=
2014-01-21 20:48:49 +01:00
IFS=':'
set -- ${line#?}
while [ $# -gt 0 ] ; do
item=$1
name=${item#?}
case $item in
2015-12-22 19:25:45 +01:00
[mM]*)
case $item in
m*)
# monitor
FG=$COLOR_MONITOR_FG
BG=$COLOR_MONITOR_BG
on_focused_monitor=
2015-12-22 19:25:45 +01:00
;;
M*)
# focused monitor
FG=$COLOR_FOCUSED_MONITOR_FG
BG=$COLOR_FOCUSED_MONITOR_BG
on_focused_monitor=1
2015-12-22 19:25:45 +01:00
;;
esac
[ $num_mon -lt 2 ] && shift && continue
wm="${wm}%{F${FG}}%{B${BG}}%{A:bspc monitor -f ${name}:} ${name} %{A}%{B-}%{F-}"
2014-07-19 15:26:06 +02:00
;;
2015-12-22 19:25:45 +01:00
[fFoOuU]*)
case $item in
f*)
# free desktop
FG=$COLOR_FREE_FG
BG=$COLOR_FREE_BG
UL=$BG
2015-12-22 19:25:45 +01:00
;;
F*)
if [ "$on_focused_monitor" ] ; then
# focused free desktop
FG=$COLOR_FOCUSED_FREE_FG
BG=$COLOR_FOCUSED_FREE_BG
UL=$BG
else
# active free desktop
FG=$COLOR_FREE_FG
BG=$COLOR_FREE_BG
UL=$COLOR_FOCUSED_FREE_BG
fi
2015-12-22 19:25:45 +01:00
;;
o*)
# occupied desktop
FG=$COLOR_OCCUPIED_FG
BG=$COLOR_OCCUPIED_BG
UL=$BG
2015-12-22 19:25:45 +01:00
;;
O*)
if [ "$on_focused_monitor" ] ; then
# focused occupied desktop
FG=$COLOR_FOCUSED_OCCUPIED_FG
BG=$COLOR_FOCUSED_OCCUPIED_BG
UL=$BG
else
# active occupied desktop
FG=$COLOR_OCCUPIED_FG
BG=$COLOR_OCCUPIED_BG
UL=$COLOR_FOCUSED_OCCUPIED_BG
fi
2015-12-22 19:25:45 +01:00
;;
u*)
# urgent desktop
FG=$COLOR_URGENT_FG
BG=$COLOR_URGENT_BG
UL=$BG
2015-12-22 19:25:45 +01:00
;;
U*)
if [ "$on_focused_monitor" ] ; then
# focused urgent desktop
FG=$COLOR_FOCUSED_URGENT_FG
BG=$COLOR_FOCUSED_URGENT_BG
UL=$BG
else
# active urgent desktop
FG=$COLOR_URGENT_FG
BG=$COLOR_URGENT_BG
UL=$COLOR_FOCUSED_URGENT_BG
fi
2015-12-22 19:25:45 +01:00
;;
esac
wm="${wm}%{F${FG}}%{B${BG}}%{U${UL}}%{+u}%{A:bspc desktop -f ${name}:} ${name} %{A}%{B-}%{F-}%{-u}"
2014-07-19 15:26:06 +02:00
;;
2015-12-22 19:25:45 +01:00
[LTG]*)
# layout, state and flags
wm="${wm}%{F$COLOR_STATE_FG}%{B$COLOR_STATE_BG} ${name} %{B-}%{F-}"
2014-01-21 20:48:49 +01:00
;;
esac
shift
done
;;
esac
2015-12-22 19:25:45 +01:00
printf "%s\n" "%{l}${wm}%{c}${title}%{r}${sys}"
2012-12-19 15:50:42 +01:00
done