cleanup status bar blocks
This commit is contained in:
parent
a6abad2114
commit
f355b1f6ef
5 changed files with 39 additions and 29 deletions
.local/bin/statusbar
|
@ -3,19 +3,19 @@
|
||||||
clock=$(date '+%I')
|
clock=$(date '+%I')
|
||||||
|
|
||||||
case "$clock" in
|
case "$clock" in
|
||||||
"00") icon=" " ;;
|
"00") icon="" ;;
|
||||||
"01") icon=" " ;;
|
"01") icon="" ;;
|
||||||
"02") icon=" " ;;
|
"02") icon="" ;;
|
||||||
"03") icon=" " ;;
|
"03") icon="" ;;
|
||||||
"04") icon=" " ;;
|
"04") icon="" ;;
|
||||||
"05") icon=" " ;;
|
"05") icon="" ;;
|
||||||
"06") icon=" " ;;
|
"06") icon="" ;;
|
||||||
"07") icon=" " ;;
|
"07") icon="" ;;
|
||||||
"08") icon=" " ;;
|
"08") icon="" ;;
|
||||||
"09") icon=" " ;;
|
"09") icon="" ;;
|
||||||
"10") icon=" " ;;
|
"10") icon="" ;;
|
||||||
"11") icon=" " ;;
|
"11") icon="" ;;
|
||||||
"12") icon=" " ;;
|
"12") icon="" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
|
@ -26,4 +26,4 @@ case $BLOCK_BUTTON in
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
date "+%d.%M.%Y $icon%H:%M"
|
echo " $(date "+%d.%m.%Y $icon %H:%M") "
|
||||||
|
|
|
@ -18,9 +18,9 @@ case $BLOCK_BUTTON in
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if grep -xq 'up' /sys/class/net/w*/operstate 2>/dev/null ; then
|
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
|
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
|
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)"
|
||||||
|
|
|
@ -1,13 +1,24 @@
|
||||||
#!/bin/sh
|
#!/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 &
|
pidof -x sb-mpdup >/dev/null 2>&1 || sb-mpdup >/dev/null 2>&1 &
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
1) mpc status | filter ; setsid -f "$TERMINAL" -e ncmpcpp ;; # right click, pause/unpause
|
1) mpc status | filter ; setsid -f "$TERMINAL" -e ncmpcpp ;; # right click, pause/unpause
|
||||||
2) mpc toggle | filter ;; # 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.
|
- ⏸ when paused.
|
||||||
- Left click opens ncmpcpp.
|
- Left click opens ncmpcpp.
|
||||||
- Middle click pauses.
|
- Middle click pauses.
|
||||||
|
|
|
@ -6,8 +6,7 @@
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
1) setsid -f "$TERMINAL" -e bmon ;;
|
1) setsid -f "$TERMINAL" -e bmon ;;
|
||||||
3) notify-send " Network traffic module" ": Traffic received
|
3) notify-send "歷 Network traffic module" ": Traffic received : Traffic transmitted" ;;
|
||||||
祝: Traffic transmitted" ;;
|
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -17,7 +16,7 @@ update() {
|
||||||
read -r i < "$arg"
|
read -r i < "$arg"
|
||||||
sum=$(( sum + i ))
|
sum=$(( sum + i ))
|
||||||
done
|
done
|
||||||
cache=${XDG_CACHE_HOME:-$HOME/.cache}/${1##*/}
|
cache=/tmp/${1##*/}
|
||||||
[ -f "$cache" ] && read -r old < "$cache" || old=0
|
[ -f "$cache" ] && read -r old < "$cache" || old=0
|
||||||
printf %d\\n "$sum" > "$cache"
|
printf %d\\n "$sum" > "$cache"
|
||||||
printf %d\\n $(( sum - old ))
|
printf %d\\n $(( sum - old ))
|
||||||
|
@ -26,4 +25,4 @@ update() {
|
||||||
rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
|
rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
|
||||||
tx=$(update /sys/class/net/[ew]*/statistics/tx_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)
|
||||||
|
|
|
@ -13,18 +13,18 @@ case $BLOCK_BUTTON in
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
[ $(pamixer --get-mute) = true ] && echo " ﱝ " && exit
|
[ $(pamixer --get-mute) = true ] && echo "ﱝ" && exit
|
||||||
|
|
||||||
vol="$(pamixer --get-volume)"
|
vol="$(pamixer --get-volume)"
|
||||||
|
|
||||||
if [ "$vol" -gt "70" ]; then
|
if [ "$vol" -gt "70" ]; then
|
||||||
icon="墳"
|
icon=""
|
||||||
elif [ "$vol" -gt "30" ]; then
|
elif [ "$vol" -gt "30" ]; then
|
||||||
icon="奔"
|
icon=""
|
||||||
elif [ "$vol" -gt "0" ]; then
|
elif [ "$vol" -gt "0" ]; then
|
||||||
icon="奄"
|
icon=""
|
||||||
else
|
else
|
||||||
echo " ﱝ "&& exit
|
echo " "&& exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo " $icon $vol%"
|
echo " $icon $vol% "
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue