helm/os/arch/.config/panel/panel_parse.sh

105 lines
3.4 KiB
Bash
Raw Normal View History

2016-10-19 07:56:37 -07:00
#!/usr/bin/env bash
2016-10-31 19:07:23 -07:00
theme="$1"
2016-10-19 07:56:37 -07:00
2016-10-31 19:07:23 -07:00
. $(dirname $0)/themes/${theme}.sh
2016-10-19 07:56:37 -07:00
declare -A ICONS
2016-10-31 19:07:23 -07:00
ICONS[desktop]="\ue1d7"
ICONS[code]="\ue1ec"
ICONS[art]="\ue1c7"
ICONS[web]="\ue26d"
ICONS[chat]="\ue19f"
ICONS[file]="\ue1e1"
ICONS[music]="\ue1a6"
ICONS[misc]="\ue140"
2016-10-19 07:56:37 -07:00
2016-10-31 19:07:23 -07:00
num_mon=$(bspc query -M | wc -l)
2016-10-19 07:56:37 -07:00
while read -r line
do
data="${line#?}"
case $line in
E*) # TODO ethernet
;;
T*) # clock output
2016-10-31 19:07:23 -07:00
date=" ${data%::*} "
clock=" ${data#*::} "
2016-10-19 07:56:37 -07:00
;;
I*) # wifi
2016-10-31 19:07:23 -07:00
wifi=" $data "
2016-10-19 07:56:37 -07:00
;;
M*) # TODO mail
mail=" \ue1a8 2 "
;;
S*) # TODO current song
playing=" \ue1a6 ... "
;;
B*) # TODO bluetooth
bt="\ue00b"
;;
W*) # bspwm's state
wm=""
IFS=':'
set -- $data
while [[ $# > 0 ]]
do
id=$1
2016-10-31 19:07:23 -07:00
name=${id#???}
2016-10-19 07:56:37 -07:00
case $id in
[mM]*)
[[ $num_mon < 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 ${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
wm="${wm}%{F${FG}}%{B${BG}}%{A:bspc desktop -f ${id#?}:} ${ICONS[$name]:$name} %{A}%{B-}%{F-}"
2016-10-19 07:56:37 -07:00
;;
esac
shift
done
;;
U*) # updates
updates=" \ue00f $data updates "
;;
V*) # volume
2016-10-31 19:07:23 -07:00
vol="$data"
2016-10-19 07:56:37 -07:00
;;
esac
echo -e "%{l}${wm}${playing}%{r}${mail} ${wifi} ${date} ${clock} ${bt}${vol}"
2016-10-19 07:56:37 -07:00
done