os/arch panel: refactor main script; polish bar config
This commit is contained in:
parent
3cfd9f0d43
commit
b244cd9214
|
@ -1,17 +1,14 @@
|
||||||
#!/usr/bin/env dash
|
#!/usr/bin/env dash
|
||||||
|
|
||||||
if [ "$1" = "--kill" ]
|
if [ "$1" = "-k" ]; then
|
||||||
then
|
|
||||||
pkill -f '^dash .+/panel$'
|
pkill -f '^dash .+/panel$'
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CWD="$(cd $(dirname $0) && pwd -P)"
|
CWD=$(dirname $0)
|
||||||
. $CWD/panel-config
|
. $CWD/panel-config
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
running() { pgrep -f $1 >/dev/null; }
|
|
||||||
cleanup() { rm -rf "$PANEL_FIFO"; pkill -P $$; }
|
cleanup() { rm -rf "$PANEL_FIFO"; pkill -P $$; }
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -20,9 +17,8 @@ trap cleanup INT TERM QUIT EXIT
|
||||||
mkfifo "$PANEL_FIFO"
|
mkfifo "$PANEL_FIFO"
|
||||||
echo "MKFIFO $PANEL_FIFO"
|
echo "MKFIFO $PANEL_FIFO"
|
||||||
|
|
||||||
if running lemonbar
|
if pgrep lemonbar >/dev/null; then
|
||||||
then
|
>&2 echo "Lemonbar is already running"
|
||||||
2>&1 echo "Lemonbar already running"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -35,17 +31,15 @@ clock -sf "T${ICON_DATE} %A, %b %d ${ICON_TIME} %I:%M%p" > "${PANEL_FIFO}" &
|
||||||
xtitle -sf 'X%s' > "${PANEL_FIFO}" &
|
xtitle -sf 'X%s' > "${PANEL_FIFO}" &
|
||||||
bspc subscribe report > "${PANEL_FIFO}" &
|
bspc subscribe report > "${PANEL_FIFO}" &
|
||||||
|
|
||||||
for lemon in $CWD/lemons/*
|
for lemon in $CWD/lemons/*; do
|
||||||
do
|
echo "INIT ${lemon##*/}"
|
||||||
echo "INIT $(basename $lemon)"
|
|
||||||
$lemon > "${PANEL_FIFO}" &
|
$lemon > "${PANEL_FIFO}" &
|
||||||
done
|
done
|
||||||
|
|
||||||
#
|
#
|
||||||
parse() {
|
parse() {
|
||||||
num_mon=$(bspc query -M | wc -l)
|
num_mon=$(bspc query -M | wc -l)
|
||||||
while read -r line
|
while read -r line; do
|
||||||
do
|
|
||||||
data="${line#?}"
|
data="${line#?}"
|
||||||
case $line in
|
case $line in
|
||||||
# Minimal icons
|
# Minimal icons
|
||||||
|
@ -55,14 +49,12 @@ parse() {
|
||||||
;;
|
;;
|
||||||
M*) mail=" $data"
|
M*) mail=" $data"
|
||||||
;;
|
;;
|
||||||
V*) vol=" $data"
|
V*) vol=" %{A:volume.sh toggle:}$data${A}"
|
||||||
;;
|
;;
|
||||||
I*) wifi=" $data"
|
I*) wifi=" $data"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# Full segments
|
# Full segments
|
||||||
E*) # TODO ethernet
|
|
||||||
;;
|
|
||||||
X*) xtitle="$data"
|
X*) xtitle="$data"
|
||||||
;;
|
;;
|
||||||
T*) datetime=" $data"
|
T*) datetime=" $data"
|
||||||
|
@ -119,7 +111,7 @@ parse() {
|
||||||
_BG=$COLOR_FOCUSED_URGENT_BG
|
_BG=$COLOR_FOCUSED_URGENT_BG
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
eval "icon=\$ICON_$name"
|
eval "icon=\$ICON_$(echo $name | tr '[:lower:]' '[:upper:]')"
|
||||||
wm="${wm}%{F$_FG}%{B$_BG}%{A:bspc desktop -f ${id#?}:} ${icon:-$name} %{A}%{B-}%{F-}"
|
wm="${wm}%{F$_FG}%{B$_BG}%{A:bspc desktop -f ${id#?}:} ${icon:-$name} %{A}%{B-}%{F-}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -130,7 +122,7 @@ parse() {
|
||||||
echo -e \
|
echo -e \
|
||||||
"%{l}${wm}${song}" \
|
"%{l}${wm}${song}" \
|
||||||
"%{c}${xtitle}" \
|
"%{c}${xtitle}" \
|
||||||
"%{r}${battery}${mail}${updates}${vol}${wifi}${datetime} "
|
"%{r}${battery}${mail}${updates}${vol}${wifi}${datetime} "
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +133,7 @@ parse < "${PANEL_FIFO}" | \
|
||||||
-f "$PANEL_FONT" \
|
-f "$PANEL_FONT" \
|
||||||
-f "$ICON_FONT" \
|
-f "$ICON_FONT" \
|
||||||
-F "$COLOR_FG" \
|
-F "$COLOR_FG" \
|
||||||
-B "$COLOR_BG" \
|
# -B "$COLOR_BG" \
|
||||||
| sh &
|
| sh &
|
||||||
|
|
||||||
wait
|
wait
|
||||||
|
|
Loading…
Reference in a new issue