Rewrite lemonbar config

This commit is contained in:
Henrik Lissner 2016-11-01 03:07:23 +01:00
parent 1bc46b484a
commit 294594421b
9 changed files with 110 additions and 77 deletions

View file

@ -0,0 +1,3 @@
#!/usr/bin/env bash
bspc subscribe report > "$PANEL_FIFO" &

View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
date_icon="\ue267"
clock_icon="\ue016"
clock -sf "T${date_icon} %A, %b %d::${clock_icon} %I:%M %p"

View file

@ -4,4 +4,4 @@ while :
do do
echo "U"$(checkupdates | wc -l) echo "U"$(checkupdates | wc -l)
sleep 3600 sleep 3600
done > "$PANEL_FIFO" & done

View file

@ -1,7 +1,19 @@
#!/usr/bin/env bash #!/usr/bin/env bash
while : muted="\ue202"
do speaker="\ue203"
echo "V$(volume.sh)" > "$PANEL_FIFO" &
sleep 3 data=$(amixer get Master)
done > "$PANEL_FIFO" & vol=0
if echo "$data" | grep '\[on\]' >/dev/null
then
vol=$(echo "$data" | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p' | uniq)
fi
case "$vol" in
0) text="%{F$COLOR_FREE_FG}${muted}%{F-}"
;;
*) text="${speaker} ${vol}%"
;;
esac
echo "V%{A:volume.sh toggle:} ${text} %{A}"

View file

@ -1,7 +1,27 @@
#!/usr/bin/env bash #!/usr/bin/env bash
wifioff="\ue21a"
wifi0="\ue25d"
wifi1="\ue25e"
wifi2="\ue25f"
wifi3="\ue260"
wifi4="\ue261"
while : while :
do do
echo "I"$(awk 'NR==3 {print $3}' /proc/net/wireless) signal=$(awk 'NR==3 {print $3}' /proc/net/wireless)
if [ -n "$signal" ]
then
icon=$wifi0
case "$signal" in
100|[6-9][0-9]*) icon=$wifi4 ;;
[4-5][0-9]*) icon=$wifi3 ;;
[2-3][0-9]*) icon=$wifi2 ;;
*) icon=$wifi1 ;;
esac
echo "I$icon $(iwgetid -r)"
else
echo "I%{F$COLOR_FREE_FG}${wifioff}%{F-} "
fi
sleep 5 sleep 5
done > "$PANEL_FIFO" & done

View file

@ -1,34 +1,37 @@
#!/usr/bin/env dash #!/usr/bin/env dash
# Quit if already running # trap "trap - TERM; kill 0" INT TERM QUIT EXIT
if [ $(pgrep -cx "$(basename $0)") -gt 1 ]
then
echo "Lemonbar already running"
exit 1
fi
PWD=$(dirname $0)
. $PWD/scripts/config.sh
trap 'trap - TERM; kill 0' INT TERM QUIT EXIT
# Bootstrap
[ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
mkfifo "$PANEL_FIFO"
# #
bspc config top_padding $(( $PANEL_HEIGHT - 2 )) PANEL_FIFO=/tmp/panel-fifo
bspc subscribe report > "$PANEL_FIFO" & PWD=$(dirname $0)
clock -sf 'T%A, %b %d::%I:%M %p' > "$PANEL_FIFO" & THEME="hax"
LEMONBAR="$(pgrep -cx lemonbar)"
for comp in $PWD/lemons/*.sh . $PWD/themes/$THEME.sh
do
if [ "$#" -eq 0 ]; then
[ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
mkfifo "$PANEL_FIFO"
if [ "$LEMONBAR" -gt 0 ]
then
echo "Lemonbar already running"
exit
fi
# Load all lemons (components)
for comp in $PWD/lemons/*.sh
do
echo "INIT: $(basename $comp)" echo "INIT: $(basename $comp)"
. "$comp" . "$comp" > "$PANEL_FIFO" &
done done
$PWD/scripts/parse.sh < "$PANEL_FIFO" | \ #
# Bootstrap panel(s)
#
$PWD/panel_parse.sh $THEME < "$PANEL_FIFO" | \
lemonbar \ lemonbar \
-a 32 \ -a 32 \
-g x$PANEL_HEIGHT \ -g x$PANEL_HEIGHT \
@ -38,4 +41,12 @@ $PWD/scripts/parse.sh < "$PANEL_FIFO" | \
-B "$COLOR_DEFAULT_BG" \ -B "$COLOR_DEFAULT_BG" \
| sh & | sh &
wait wait
elif [ -e "$PANEL_FIFO" ] && [ "$LEMONBAR" -gt 0 ]
then
if [ -f "$PWD/lemons/$1.sh" ]
then
. "$PWD/lemons/$1.sh" > "$PANEL_FIFO" &
fi
fi

View file

@ -1,19 +1,20 @@
#!/usr/bin/env bash #!/usr/bin/env bash
. $(dirname $0)/config.sh theme="$1"
num_mon=$(bspc query -M | wc -l) . $(dirname $0)/themes/${theme}.sh
declare -A ICONS declare -A ICONS
ICONS[desktop]='\ue1d7' ICONS[desktop]="\ue1d7"
ICONS[code]='\ue1ec' ICONS[code]="\ue1ec"
ICONS[art]='\ue1c7' ICONS[art]="\ue1c7"
ICONS[web]='\ue26d' ICONS[web]="\ue26d"
ICONS[chat]='\ue19f' ICONS[chat]="\ue19f"
ICONS[file]='\ue1e1' ICONS[file]="\ue1e1"
ICONS[music]='\ue1a6' ICONS[music]="\ue1a6"
ICONS[misc]='\ue140' ICONS[misc]="\ue140"
num_mon=$(bspc query -M | wc -l)
while read -r line while read -r line
do do
data="${line#?}" data="${line#?}"
@ -21,23 +22,11 @@ do
E*) # TODO ethernet E*) # TODO ethernet
;; ;;
T*) # clock output T*) # clock output
date=" \ue267 ${data%::*} " date=" ${data%::*} "
clock=" \ue016 ${data#*::} " clock=" ${data#*::} "
;; ;;
I*) # wifi I*) # wifi
if [[ $data ]] wifi=" $data "
then
signal="\ue25d"
case "$data" in
100|[6-9][0-9]*) signal="\ue261" ;;
[4-5][0-9]*) signal="\ue260" ;;
[2-3][0-9]*) signal="\ue25f" ;;
*) signal="\ue25e" ;;
esac
wifi=" $signal $(iwgetid -r) "
else
wifi=" %{F$COLOR_FREE_FG}\ue21a%{F-} "
fi
;; ;;
M*) # TODO mail M*) # TODO mail
mail=" \ue1a8 2 " mail=" \ue1a8 2 "
@ -55,7 +44,7 @@ do
while [[ $# > 0 ]] while [[ $# > 0 ]]
do do
id=$1 id=$1
name=${id#??} name=${id#???}
case $id in case $id in
[mM]*) [mM]*)
[[ $num_mon < 2 ]] && shift && continue [[ $num_mon < 2 ]] && shift && continue
@ -108,14 +97,7 @@ do
updates=" \ue00f $data updates " updates=" \ue00f $data updates "
;; ;;
V*) # volume V*) # volume
case "$data" in vol="$data"
0|off)
vol="%{F$COLOR_FREE_FG}\ue202%{F-}"
;;
*) vol="\ue203"
;;
esac
vol="%{A:volume.sh toggle:} $vol %{A}"
;; ;;
esac esac
echo -e "%{l}${wm}${playing}%{r}${mail} ${wifi} ${date} ${clock} ${bt}${vol}" echo -e "%{l}${wm}${playing}%{r}${mail} ${wifi} ${date} ${clock} ${bt}${vol}"

View file

@ -1,7 +1,6 @@
#!/bin/bash #!/bin/bash
PANEL_HEIGHT=24 PANEL_HEIGHT=24
PANEL_FIFO=/tmp/panel-fifo
PANEL_FONT="gohufont:size=11:antialias=false" PANEL_FONT="gohufont:size=11:antialias=false"
ICON_FONT="siji:size=9:antialias=false" ICON_FONT="siji:size=9:antialias=false"

View file