1
0
Fork 0

cleanup status bar blocks

This commit is contained in:
Luca Bilke 2022-08-07 12:54:35 +02:00
parent a6abad2114
commit f355b1f6ef
5 changed files with 39 additions and 29 deletions

View file

@ -3,19 +3,19 @@
clock=$(date '+%I')
case "$clock" in
"00") icon=" " ;;
"01") icon=" " ;;
"02") icon=" " ;;
"03") icon=" " ;;
"04") icon=" " ;;
"05") icon=" " ;;
"06") icon=" " ;;
"07") icon=" " ;;
"08") icon=" " ;;
"09") icon=" " ;;
"10") icon=" " ;;
"11") icon=" " ;;
"12") icon=" " ;;
"00") icon="" ;;
"01") icon="" ;;
"02") icon="" ;;
"03") icon="" ;;
"04") icon="" ;;
"05") icon="" ;;
"06") icon="" ;;
"07") icon="" ;;
"08") icon="" ;;
"09") icon="" ;;
"10") icon="" ;;
"11") icon="" ;;
"12") icon="" ;;
esac
case $BLOCK_BUTTON in
@ -26,4 +26,4 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
date "+%d.%M.%Y $icon%H:%M"
echo " $(date "+%d.%m.%Y $icon %H:%M") "

View file

@ -18,9 +18,9 @@ case $BLOCK_BUTTON in
esac
if grep -xq 'up' /sys/class/net/w*/operstate 2>/dev/null ; then
wifiicon="$(awk '/^\s*w/ { print "直 ", int($3 * 100 / 70) "% " }' /proc/net/wireless)"
wifiicon="$(awk '/^\s*w/ { print " 直", int($3 * 100 / 70) "% " }' /proc/net/wireless)"
elif grep -xq 'down' /sys/class/net/w*/operstate 2>/dev/null ; then
grep -xq '0x1003' /sys/class/net/w*/flags && wifiicon="睊 " || wifiicon=" "
grep -xq '0x1003' /sys/class/net/w*/flags && wifiicon=" 睊" || wifiicon="  "
fi
printf "%s%s%s\n" "$wifiicon" "$(sed "s/down/ /;s/up/ /" /sys/class/net/e*/operstate 2>/dev/null)" "$(sed "s/.*/嬨 /" /sys/class/net/tun*/operstate 2>/dev/null)"
printf "%s%s%s\n" "$wifiicon" "$(sed "s/down/  /;s/up/  /" /sys/class/net/e*/operstate 2>/dev/null)" "$(sed "s/.*/ 嬨/" /sys/class/net/tun*/operstate 2>/dev/null)"

View file

@ -1,13 +1,24 @@
#!/bin/sh
filter() { mpc | sed "/^volume:/d;s/\\&/&/g;s/\\[paused\\].*/⏸/g;/\\[playing\\].*/d;/^ERROR/Q" | paste -sd ' ' -;}
filter() {
if mpc &>/dev/null && [[ $(mpc | wc -l) -eq 3 ]]; then
song=$(mpc current -f "%artist% - %title%" | xargs -0 )
[[ $(echo $song | wc -m) -gt 37 ]] && song="${song:0:36}…"
mpc | awk 'NR==2' | grep -q playing && icon="" || icon=""
echo " $icon $song "
elif mpc &>/dev/null && [[ $(mpc | wc -l) -eq 1 ]]; then
echo " ﱙ "
else
exit 1
fi
}
pidof -x sb-mpdup >/dev/null 2>&1 || sb-mpdup >/dev/null 2>&1 &
case $BLOCK_BUTTON in
1) mpc status | filter ; setsid -f "$TERMINAL" -e ncmpcpp ;; # right click, pause/unpause
2) mpc toggle | filter ;; # right click, pause/unpause
3) mpc status | filter ; notify-send "🎵 Music module" "\- Shows mpd song playing.
3) mpc status | filter ; notify-send " Music module" "\- Shows mpd song playing.
- ⏸ when paused.
- Left click opens ncmpcpp.
- Middle click pauses.

View file

@ -6,8 +6,7 @@
case $BLOCK_BUTTON in
1) setsid -f "$TERMINAL" -e bmon ;;
3) notify-send " Network traffic module" ": Traffic received
祝: Traffic transmitted" ;;
3) notify-send "歷 Network traffic module" ": Traffic received : Traffic transmitted" ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
@ -17,7 +16,7 @@ update() {
read -r i < "$arg"
sum=$(( sum + i ))
done
cache=${XDG_CACHE_HOME:-$HOME/.cache}/${1##*/}
cache=/tmp/${1##*/}
[ -f "$cache" ] && read -r old < "$cache" || old=0
printf %d\\n "$sum" > "$cache"
printf %d\\n $(( sum - old ))
@ -26,4 +25,4 @@ update() {
rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes)
printf " %4sB 祝 %4sB\\n" $(numfmt --to=iec $rx) $(numfmt --to=iec $tx)
printf "  %4sB  %4sB \\n" $(numfmt --to=iec $rx $tx)

View file

@ -13,18 +13,18 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
[ $(pamixer --get-mute) = true ] && echo "" && exit
[ $(pamixer --get-mute) = true ] && echo "" && exit
vol="$(pamixer --get-volume)"
if [ "$vol" -gt "70" ]; then
icon=""
icon=""
elif [ "$vol" -gt "30" ]; then
icon="奔"
icon=""
elif [ "$vol" -gt "0" ]; then
icon=""
icon=""
else
echo " "&& exit
echo " "&& exit
fi
echo " $icon $vol%"
echo " $icon $vol% "