panel: another rewrite; use dash (smaller memory footprint) + polish
This commit is contained in:
parent
bcbb431374
commit
5a66167430
|
@ -2,6 +2,8 @@
|
|||
|
||||
[ -f ~/.secrets/accounts.sh ] && . ~/.secrets/accounts.sh || exit
|
||||
|
||||
ERROR=
|
||||
|
||||
get-mail() {
|
||||
local feed=$(curl -u "$1:$2" --silent https://mail.google.com/mail/feed/atom)
|
||||
if [ "$(echo $feed | grep -c "<fullcount>")" -eq 1 ]
|
||||
|
@ -9,6 +11,7 @@ get-mail() {
|
|||
echo $feed | grep -o "<entry>" | wc -l
|
||||
else
|
||||
>&2 echo "mail.sh: error with $1"
|
||||
ERROR=1
|
||||
echo 0
|
||||
fi
|
||||
}
|
||||
|
@ -17,4 +20,6 @@ a=$(get-mail "${MAIL1[USER]}" "${MAIL1[PASS]}")
|
|||
b=$(get-mail "${MAIL2[USER]}" "${MAIL2[PASS]}")
|
||||
c=$(get-mail "${MAIL3[USER]}" "${MAIL3[PASS]}")
|
||||
|
||||
echo M$(( $a + $b + $c ))
|
||||
echo -n M$(( $a + $b + $c ))
|
||||
[[ $ERROR ]] && echo -n !
|
||||
echo
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env dash
|
||||
|
||||
while :
|
||||
do
|
14
os/arch/.config/panel/lemons/network
Executable file
14
os/arch/.config/panel/lemons/network
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env dash
|
||||
|
||||
# No wifi interface? Abort!
|
||||
ints=$(find /sys/class/net/*/wireless -type d)
|
||||
[ -z "$ints" ] && echo "Ix" && exit
|
||||
|
||||
# Start watching
|
||||
while :
|
||||
do
|
||||
signal=$(awk 'NR==3 {print $3}' /proc/net/wireless)
|
||||
echo "I${signal%?}"
|
||||
# echo "I${signal%?},$(iwgetid --raw)"
|
||||
sleep 10
|
||||
done
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env dash
|
||||
|
||||
checkupdates >/dev/null
|
||||
echo "U$(pacaur -Qu | wc -l)"
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env dash
|
||||
|
||||
# I expect all volume adjustments to be done through the volume.sh script (in
|
||||
# os/arch/bin), which will inform lemonbar of changes, so we only need to intialize
|
|
@ -1,14 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# No wifi interface? Abort!
|
||||
ints=$(awk -F "/" 'FNR==NR { wire[$5]++; next } { split(FILENAME, state, "/"); if (state[5] in wire && $1 == "up") print state[5] }' <(find /sys/class/net/*/wireless -type d) $(find /sys/class/net/*/operstate ! -type d))
|
||||
[ -z "$ints" ] && echo "Ix" && exit
|
||||
|
||||
# Start watching
|
||||
while :
|
||||
do
|
||||
signal=$(awk 'NR==3 {print $3}' /proc/net/wireless)
|
||||
echo "I${signal%?}"
|
||||
# echo "I${signal%?},$(iwgetid --raw)"
|
||||
sleep 5
|
||||
done
|
|
@ -1,27 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env dash
|
||||
|
||||
if [[ $1 == "--kill" ]]
|
||||
if [ "$1" = "--kill" ]
|
||||
then
|
||||
pkill -f 'bash .+/panel\.sh'
|
||||
pkill -f '^bash .+/panel$'
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
CWD="$(cd $(dirname $0) && pwd -P)"
|
||||
. $CWD/panel_config
|
||||
. $CWD/panel-config
|
||||
|
||||
|
||||
#
|
||||
running() { pgrep -f $1 >/dev/null; }
|
||||
|
||||
cleanup() {
|
||||
[ -e "$PANEL_FIFO" ] && rm -f "$PANEL_FIFO"
|
||||
pkill -P $$
|
||||
}
|
||||
cleanup() { rm -rf /tmp/panel-fifo-* && pkill -P $$; }
|
||||
|
||||
#
|
||||
trap cleanup INT TERM QUIT EXIT
|
||||
[ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
|
||||
mkfifo "$PANEL_FIFO"
|
||||
echo "MKFIFO $PANEL_FIFO"
|
||||
|
||||
if running lemonbar
|
||||
then
|
||||
|
@ -34,24 +31,24 @@ fi
|
|||
# Bootstrap panel(s)
|
||||
#
|
||||
|
||||
clock -sf "T%A, %b %d::%I:%M%p" > "$PANEL_FIFO" &
|
||||
xtitle -sf 'X%s' > "$PANEL_FIFO" &
|
||||
bspc subscribe report > "$PANEL_FIFO" &
|
||||
clock -sf "T%A, %b %d::%I:%M%p" > "${PANEL_FIFO}" &
|
||||
xtitle -sf 'X%s' > "${PANEL_FIFO}" &
|
||||
bspc subscribe report > "${PANEL_FIFO}" &
|
||||
|
||||
pushd $CWD/lemons >/dev/null
|
||||
for lemon in *.sh
|
||||
cd $CWD/lemons >/dev/null
|
||||
for lemon in *
|
||||
do
|
||||
echo "INIT: $lemon"
|
||||
./$lemon > "$PANEL_FIFO" &
|
||||
echo "INIT $lemon"
|
||||
./$lemon >"${PANEL_FIFO}" &
|
||||
done
|
||||
popd >/dev/null
|
||||
cd - >/dev/null
|
||||
|
||||
#
|
||||
progress-bar() {
|
||||
progress_bar() {
|
||||
BAR_SIZE=${2:-26}
|
||||
C1="%{F#FF0000}-%{F-}"
|
||||
C2="%{F#555555}-%{F-}"
|
||||
DELIM="%{F#777777}|%{F-}"
|
||||
C1="%{F${COLOR_6}}-%{F-}"
|
||||
C2="%{F${COLOR_DIM}}-%{F-}"
|
||||
DELIM=
|
||||
|
||||
echo "$1" | SIZE=$BAR_SIZE CHAR1="$C1" CHAR2="$C2" SEP='' START="$DELIM" END="$DELIM" mkb
|
||||
}
|
||||
|
@ -63,78 +60,83 @@ parse() {
|
|||
data="${line#?}"
|
||||
case $line in
|
||||
# Minimal icons
|
||||
U*) updates=" %{F${COLOR[DIM]}}\ue00f%{F-}"
|
||||
if [[ "$data" > 0 ]]; then
|
||||
updates=" %{F${COLOR[2]}}\ue00f$data%{F-}"
|
||||
U*) updates=" %{F${COLOR_DIM}}$ICON_UPD%{F-}"
|
||||
if [ "$data" -gt 0 ]; then
|
||||
updates=" %{F${COLOR_2}}$ICON_UPD$data%{F-}"
|
||||
fi
|
||||
;;
|
||||
M*) icon="${ICON[mail]}"
|
||||
M*) icon="${ICON_MAIL}"
|
||||
color="${COLOR_FG}"
|
||||
if [ "$data" = *! ]
|
||||
then
|
||||
data="${data%?}"
|
||||
color="${COLOR_1}"
|
||||
fi
|
||||
case "$data" in
|
||||
!) mail="%{F${COLOR[3]}}$icon!%{F-}"
|
||||
;;
|
||||
[1-9]*)
|
||||
mail="%{F${COLOR[1]}}$icon$data%{F-}"
|
||||
mail="$icon$data"
|
||||
;;
|
||||
0) mail="%{F${COLOR[DIM]}}$icon%{F-}"
|
||||
0) mail="$icon"
|
||||
color="${COLOR_DIM}"
|
||||
;;
|
||||
esac
|
||||
mail="%{F$color}$mail%{F-}"
|
||||
;;
|
||||
V*) case "$data" in
|
||||
0) vol=" %{F${COLOR[DIM]}}${ICON[muted]}%{F-}"
|
||||
0) vol=" %{F${COLOR_DIM}}${ICON_MUTED}%{F-}"
|
||||
;;
|
||||
*) vol=" ${ICON[speaker]}"
|
||||
*) vol=" ${ICON_SPEAKER}"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
# Full segments
|
||||
I*) # ssid=" ${data#*,}"
|
||||
case "${data%,*}" in
|
||||
100|[6-9][0-9]) icon="${ICON[wifi3]} " ;;
|
||||
[2-5][0-9]) icon="${ICON[wifi2]} " ;;
|
||||
# [1-2][0-9]) icon="${ICON[wifi2]} " ;;
|
||||
x) icon="${ICON[wifioff]}" ;;
|
||||
*) icon="${ICON[wifi1]} " ;;
|
||||
100|[6-9][0-9]) icon="${ICON_WIFI3} " ;;
|
||||
[2-5][0-9]) icon="${ICON_WIFI2} " ;;
|
||||
x) icon="${ICON_WIFI0}" ;;
|
||||
*) icon="${ICON_WIFI1} " ;;
|
||||
esac
|
||||
wifi=" $icon"
|
||||
;;
|
||||
|
||||
# Full segments
|
||||
E*) # TODO ethernet
|
||||
;;
|
||||
X*) title="$data"
|
||||
X*) xtitle="$data"
|
||||
;;
|
||||
T*) datetime=" ${ICON[date]} ${data%::*} ${ICON[time]} ${data#*::}"
|
||||
T*) datetime=" ${ICON_DATE} ${data%::*} ${ICON_TIME} ${data#*::}"
|
||||
;;
|
||||
S*) song=""
|
||||
case "$data" in
|
||||
P*) icon="${ICON[play]}" ;;
|
||||
p*) icon="${ICON[pause]}" ;;
|
||||
P*) icon="%{F${COLOR_2}}${ICON_PLAY}%{F-}" ;;
|
||||
p*) icon="%{F${COLOR_4}}${ICON_PAUSE}%{F-}" ;;
|
||||
*) icon="" ;;
|
||||
esac
|
||||
if [[ -n $icon ]]
|
||||
if [ -n "$icon" ]
|
||||
then
|
||||
info="${data#?}"
|
||||
title=$(echo "$info" | cut -d'^' -f1)
|
||||
artist=$(echo "$info" | cut -d'^' -f2)
|
||||
album=$(echo "$info" | cut -d'^' -f3)
|
||||
# title=$(echo "$info" | cut -d'^' -f1)
|
||||
# artist=$(echo "$info" | cut -d'^' -f2)
|
||||
# album=$(echo "$info" | cut -d'^' -f3)
|
||||
seek=$(echo "$info" | cut -d'^' -f4)
|
||||
perc=$(echo "$info" | cut -d'^' -f5)
|
||||
|
||||
song="%{B${COLOR[ALTBG]}} $icon ${seek%/*} $(progress-bar $perc 24) ${seek#*/} %{B-}"
|
||||
song="$song $title - $artist"
|
||||
[[ $album ]] && song="$song ($album)"
|
||||
# song="$title - $artist"
|
||||
# [ -n "$album" ] && song="$song ($album)"
|
||||
song="%{B${COLOR_ALTBG}} $icon ${seek%/*} $(progress_bar $perc 16) ${seek#*/} %{B-} "
|
||||
fi
|
||||
;;
|
||||
W*) # bspwm's state
|
||||
wm=""
|
||||
IFS=':'
|
||||
set -- $data
|
||||
while [[ $# > 0 ]]
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
id=$1
|
||||
name=${id#???}
|
||||
case $id in
|
||||
[mM]*)
|
||||
[[ $num_mon < 2 ]] && shift && continue
|
||||
[ "$num_mon" -lt 2 ] && shift && continue
|
||||
case $id in
|
||||
m*) # monitor
|
||||
_FG=$COLOR_MONITOR_FG
|
||||
|
@ -174,7 +176,8 @@ parse() {
|
|||
_BG=$COLOR_FOCUSED_URGENT_BG
|
||||
;;
|
||||
esac
|
||||
wm="${wm}%{F$_FG}%{B$_BG}%{A:bspc desktop -f ${id#?}:} ${ICON[$name]:$name} %{A}%{B-}%{F-}"
|
||||
eval "icon=\$ICON_$name"
|
||||
wm="${wm}%{F$_FG}%{B$_BG}%{A:bspc desktop -f ${id#?}:} ${icon:-$name} %{A}%{B-}%{F-}"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
|
@ -183,18 +186,19 @@ parse() {
|
|||
esac
|
||||
echo -e \
|
||||
"%{l}${wm}${song}" \
|
||||
"%{c}${xtitle}" \
|
||||
"%{r}${mail}${updates}${vol}${wifi}${datetime} "
|
||||
done
|
||||
}
|
||||
|
||||
parse < "$PANEL_FIFO" | \
|
||||
parse < "${PANEL_FIFO}" | \
|
||||
lemonbar \
|
||||
-a 32 \
|
||||
-g x$PANEL_HEIGHT \
|
||||
-f "$PANEL_FONT" \
|
||||
-f "$ICON_FONT" \
|
||||
-F "${COLOR[FG]}" \
|
||||
-B "${COLOR[BG]}" \
|
||||
-F "$COLOR_FG" \
|
||||
-B "$COLOR_BG" \
|
||||
| sh &
|
||||
|
||||
wait
|
70
os/arch/.config/panel/panel-config
Normal file
70
os/arch/.config/panel/panel-config
Normal file
|
@ -0,0 +1,70 @@
|
|||
PANEL_FIFO=/tmp/panel-fifo
|
||||
|
||||
# Customization ########################
|
||||
PANEL_HEIGHT=25
|
||||
PANEL_FONT="terminus:size=9:antialias=false"
|
||||
ICON_FONT="siji:size=9:antialias=false"
|
||||
|
||||
# Colors
|
||||
for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
||||
do
|
||||
eval "COLOR_$i="$(xrdb -query | awk "/^\*\.color$i:/ {print \$2}")
|
||||
done
|
||||
|
||||
bg="$(xrdb -query | awk '/^\*\.background:/ {print $2}')"
|
||||
fg="$(xrdb -query | awk '/^\*\.foreground:/ {print $2}')"
|
||||
|
||||
# FG="#bbc2cf"
|
||||
# BG="#e022252c"
|
||||
COLOR_FG="$fg"
|
||||
COLOR_BG="#e0${bg#?}"
|
||||
|
||||
COLOR_HL="#185b75"
|
||||
COLOR_DIM="#155872"
|
||||
COLOR_ALTBG="#FF${bg#?}"
|
||||
COLOR_NONE="#00${bg#?}"
|
||||
|
||||
COLOR_MONITOR_FG="#8dbcdf"
|
||||
COLOR_MONITOR_BG="${COLOR_BG}"
|
||||
COLOR_FOCUSED_MONITOR_FG="#b1d0e8"
|
||||
COLOR_FOCUSED_MONITOR_BG="${COLOR_NONE}"
|
||||
COLOR_FREE_FG="${COLOR_DIM}"
|
||||
COLOR_FREE_BG="${COLOR_BG}"
|
||||
COLOR_FOCUSED_FREE_FG="${COLOR_0}"
|
||||
COLOR_FOCUSED_FREE_BG="${COLOR_NONE}"
|
||||
COLOR_OCCUPIED_FG="#a7a5a5"
|
||||
COLOR_OCCUPIED_BG="${COLOR_BG}"
|
||||
COLOR_FOCUSED_OCCUPIED_FG="#d6d3d2"
|
||||
COLOR_FOCUSED_OCCUPIED_BG="${COLOR_NONE}"
|
||||
COLOR_URGENT_FG="${COLOR_1}"
|
||||
COLOR_URGENT_BG="${COLOR_BG}"
|
||||
COLOR_FOCUSED_URGENT_FG="#501d1f"
|
||||
COLOR_FOCUSED_URGENT_BG="${COLOR_NONE}"
|
||||
|
||||
# bspwm desktop icons
|
||||
ICON_DESKTOP=""
|
||||
ICON_CODE=""
|
||||
ICON_ART=""
|
||||
ICON_WEB=""
|
||||
ICON_CHAT=""
|
||||
ICON_FILE=""
|
||||
ICON_MUSIC=""
|
||||
ICON_MEDIA=""
|
||||
ICON_GAMES="" # ghost
|
||||
# clock icons
|
||||
ICON_DATE=""
|
||||
ICON_TIME=""
|
||||
# wireless icons
|
||||
ICON_WIFI0=""
|
||||
ICON_WIFI1=""
|
||||
ICON_WIFI2=""
|
||||
ICON_WIFI3=""
|
||||
# media player icons
|
||||
ICON_PLAY=""
|
||||
ICON_PAUSE=""
|
||||
ICON_STOP=""
|
||||
ICON_MUTED=""
|
||||
ICON_SPEAKER=""
|
||||
# misc
|
||||
ICON_MAIL=""
|
||||
ICON_UPD=""
|
36
os/arch/.config/panel/panel-notify
Executable file
36
os/arch/.config/panel/panel-notify
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CWD=$(cd $(dirname $0) && pwd -P)
|
||||
|
||||
if [ -t 0 ]
|
||||
then
|
||||
if [ "$#" -eq 0 ]
|
||||
then
|
||||
>&2 echo "Usage: panel_update.sh [LEMON_TO_UPDATE]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
:*) LEMON="$CWD/lemons/${1#?}"
|
||||
if [ ! -f "$LEMON" ]
|
||||
then
|
||||
>&2 echo "Couldn't find that lemon ($1)"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
. $CWD/panel-config
|
||||
pkill -f "bash \./lemons/${1#?}"
|
||||
pushd "$CWD" >/dev/null
|
||||
$LEMON > "$PANEL_FIFO" &
|
||||
popd >/dev/null
|
||||
;;
|
||||
*) echo "$@" | $0
|
||||
;;
|
||||
esac
|
||||
else
|
||||
. $CWD/panel-config
|
||||
while read -r line
|
||||
do
|
||||
echo "$line" > "$PANEL_FIFO" &
|
||||
done
|
||||
fi
|
2
os/arch/.config/panel/panel-pacman-hook
Executable file
2
os/arch/.config/panel/panel-pacman-hook
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/usr/bin/env bash
|
||||
$(dirname $0)/panel-notify :updates
|
|
@ -1,77 +0,0 @@
|
|||
PANEL_FIFO=/tmp/panel-fifo
|
||||
|
||||
# Customization ########################
|
||||
PANEL_HEIGHT=24
|
||||
PANEL_FONT="terminus:size=9:antialias=false"
|
||||
ICON_FONT="siji:size=9:antialias=false"
|
||||
|
||||
# Colors
|
||||
declare -A COLOR
|
||||
|
||||
END=15
|
||||
for ((i=0;i<=END;i++)); do
|
||||
COLOR[$i]=$(xrdb -query | awk "/^\*\.color$i:/ {print \$2}")
|
||||
done
|
||||
|
||||
bg="$(xrdb -query | awk '/^\*\.background:/ {print $2}')"
|
||||
fg="$(xrdb -query | awk '/^\*\.foreground:/ {print $2}')"
|
||||
|
||||
# FG="#bbc2cf"
|
||||
# BG="#e022252c"
|
||||
COLOR[FG]="$fg"
|
||||
COLOR[BG]="#e0${bg#?}"
|
||||
|
||||
COLOR[HL]="#185b75"
|
||||
COLOR[DIM]="#155872"
|
||||
COLOR[ALTBG]="#FF${bg#?}"
|
||||
|
||||
COLOR_MONITOR_FG="#8dbcdf"
|
||||
COLOR_MONITOR_BG="${COLOR[BG]}"
|
||||
COLOR_FOCUSED_MONITOR_FG="#b1d0e8"
|
||||
COLOR_FOCUSED_MONITOR_BG="${COLOR[BG]}"
|
||||
COLOR_FREE_FG="${COLOR[DIM]}"
|
||||
COLOR_FREE_BG="${COLOR[BG]}"
|
||||
COLOR_FOCUSED_FREE_FG="${COLOR[0]}"
|
||||
COLOR_FOCUSED_FREE_BG="#00000000"
|
||||
COLOR_OCCUPIED_FG="#a7a5a5"
|
||||
COLOR_OCCUPIED_BG="${COLOR[BG]}"
|
||||
COLOR_FOCUSED_OCCUPIED_FG="#d6d3d2"
|
||||
COLOR_FOCUSED_OCCUPIED_BG="#00000000"
|
||||
COLOR_URGENT_FG="${COLOR[1]}"
|
||||
COLOR_URGENT_BG="${COLOR[BG]}"
|
||||
COLOR_FOCUSED_URGENT_FG="#501d1f"
|
||||
COLOR_FOCUSED_URGENT_BG="#d5443e"
|
||||
COLOR_STATE_FG="#89b09c"
|
||||
COLOR_STATE_BG="${COLOR[BG]}"
|
||||
|
||||
declare -A ICON
|
||||
# bspwm desktop icons
|
||||
ICON[desktop]="\ue1d7"
|
||||
ICON[code]="\ue1ec"
|
||||
ICON[art]="\ue1c7"
|
||||
ICON[web]="\ue26d"
|
||||
ICON[chat]="\ue19f"
|
||||
ICON[file]="\ue1e1"
|
||||
ICON[music]="\ue1a6"
|
||||
ICON[games]="\ue140" # ghost
|
||||
# clock icons
|
||||
ICON[date]="\ue267"
|
||||
ICON[time]="\ue016"
|
||||
# wireless icons
|
||||
# ICON[wifioff]="\ue21a"
|
||||
# ICON[wifi1]="\ue25e"
|
||||
# ICON[wifi2]="\ue25f"
|
||||
# ICON[wifi3]="\ue260"
|
||||
# ICON[wifi4]="\ue261"
|
||||
ICON[wifioff]="\ue217"
|
||||
ICON[wifi1]="\ue218"
|
||||
ICON[wifi2]="\ue219"
|
||||
ICON[wifi3]="\ue21a"
|
||||
# media player icons
|
||||
ICON[play]="\ue058"
|
||||
ICON[pause]="\ue09b"
|
||||
ICON[stop]="\ue099"
|
||||
ICON[muted]="\ue04f"
|
||||
ICON[speaker]="\ue05d"
|
||||
# misc
|
||||
ICON[mail]="\ue070"
|
|
@ -1,2 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
/home/hlissner/.config/panel/panel_update.sh updates
|
|
@ -1,22 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [ "$#" -eq 0 ]
|
||||
then
|
||||
>&2 echo "Usage: panel_update.sh [LEMON_TO_UPDATE]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CWD=$(cd $(dirname $0) && pwd -P)
|
||||
LEMON="$CWD/lemons/$1.sh"
|
||||
|
||||
if [ ! -f "$LEMON" ]
|
||||
then
|
||||
>&2 echo "Couldn't find that lemon ($1)"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
. $CWD/panel_config
|
||||
pkill -f "bash \./lemons/$1\.sh"
|
||||
pushd "$CWD" >/dev/null
|
||||
./lemons/$1.sh > "$PANEL_FIFO" &
|
||||
popd >/dev/null
|
Loading…
Reference in a new issue