Skip to content

Instantly share code, notes, and snippets.

@pinguinson
Created August 10, 2015 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinguinson/ff8e37bba6574f4b7593 to your computer and use it in GitHub Desktop.
Save pinguinson/ff8e37bba6574f4b7593 to your computer and use it in GitHub Desktop.
panel_bar
#! /bin/sh
. panel_colors
num_mon=$(bspc query -M | wc -l)
PADDING=" "
while read -r line ; do
case $line in
N*)
# wifi output
wifi="$PADDING${line#?}$PADDING"
;;
B*)
# battery output
battery="$PADDING${line#?}$PADDING"
;;
D*)
# date output
date="$PADDING${line#?}$PADDING"
;;
C*)
# clock output
clock="$PADDING${line#?}$PADDING"
;;
V*)
# alsa volume
volume="$PADDING${line#?}$PADDING"
;;
W*)
# bspwm internal state
wm_infos=""
IFS=':'
set -- ${line#?}
while [ $# -gt 0 ] ; do
item=$1
name=${item#?}
case $item in
M*)
# active monitor
if [ $num_mon -gt 1 ] ; then
wm_infos="$wm_infos %{F$COLOR_ACTIVE_MONITOR_FG}%{B$COLOR_ACTIVE_MONITOR_BG}$PADDING${name}$PADDING%{B-}%{F-} "
fi
;;
m*)
# inactive monitor
if [ $num_mon -gt 1 ] ; then
wm_infos="$wm_infos %{F$COLOR_INACTIVE_MONITOR_FG}%{B$COLOR_INACTIVE_MONITOR_BG}$PADDING${name}$PADDING%{B-}%{F-} "
fi
;;
O*)
# focused occupied desktop
wm_infos="${wm_infos}%{F$COLOR_FOCUSED_OCCUPIED_FG}%{B$COLOR_FOCUSED_OCCUPIED_BG}%{U$COLOR_FOREGROUND}%{+u}$PADDING${name}$PADDING%{-u}%{B-}%{F-}"
;;
F*)
# focused free desktop
wm_infos="${wm_infos}%{F$COLOR_FOCUSED_FREE_FG}%{B$COLOR_FOCUSED_FREE_BG}%{U$COLOR_FOREGROUND}%{+u}$PADDING${name}$PADDING%{-u}%{B-}%{F-}"
;;
U*)
# focused urgent desktop
wm_infos="${wm_infos}%{F$COLOR_FOCUSED_URGENT_FG}%{B$COLOR_FOCUSED_URGENT_BG}%{U$COLOR_FOREGROUND}%{+u}$PADDING${name}$PADDING%{-u}%{B-}%{F-}"
;;
o*)
# occupied desktop
wm_infos="${wm_infos}%{F$COLOR_OCCUPIED_FG}%{B$COLOR_OCCUPIED_BG}%{A:bspc desktop -f ${name}:}$PADDING${name}$PADDING%{A}%{B-}%{F-}"
;;
f*)
# free desktop
wm_infos="${wm_infos}%{F$COLOR_FREE_FG}%{B$COLOR_FREE_BG}%{A:bspc desktop -f ${name}:}$PADDING${name}$PADDING%{A}%{B-}%{F-}"
;;
u*)
# urgent desktop
wm_infos="${wm_infos}%{F$COLOR_URGENT_FG}%{B$COLOR_URGENT_BG}$PADDING${name}$PADDING%{B-}%{F-}"
;;
esac
shift
done
;;
esac
printf "%s\n" "%{l}${wm_infos}%{r}${title}${wifi}${volume}${battery}${date}${clock}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment