[feature] adjust text for unicode icon

This commit is contained in:
Klesh Wong 2020-09-29 18:21:37 +08:00
parent 7c17a0bd0a
commit 24792d3a7c

View File

@ -7,63 +7,64 @@ function update
set text $text "🎥" set text $text "🎥"
end end
# mpd # mpd
if which mpc if which mpc 1>/dev/null 2>&1
set music (mpc) set music (mpc)
if string match -r playing "$music[2]" if string match -r playing "$music[2]" 1>/dev/null 2>&1
set text $text "♬ $music[1]" set text $text "♬ $music[1]"
end end
end end
# volume # volume
set vol (amixer get Master) set vol (amixer get Master)
if string match -r '\[off\]' "$vol" if string match -r '\[off\]' "$vol"
set text $text " 0" set text $text "🔉 0"
else else
set v (string match -r '\[(\d+)%\]' $vol | tail -n 1) set v (string match -r '\[(\d+)%\]' $vol | tail -n 1)
set text $text " $v" set text $text "🔊 $v"
end end
# network # network
for nic in (ls -d /sys/class/net/e*) for nic in (ls -d /sys/class/net/e*)
if grep up $nic/operstate > /dev/null if grep up $nic/operstate > /dev/null
set speed (cat $nic/speed)M set speed (cat $nic/speed)M
set text $text " $speed" set text $text "🖧 $speed"
end end
end end
set wifi (grep "^\s*w" /proc/net/wireless | awk '{ print int($3 * 100 / 70) "%" }') set wifi (grep "^\s*w" /proc/net/wireless | awk '{ print int($3 * 100 / 70) "%" }')
if test -n "$wifi" if test -n "$wifi"
set text $text " $wifi" set text $text "📡 $wifi"
end end
# memory # memory
set memory (free | awk '/^Mem:/ {print $3 "/" $2 "*" 100}' | math -s0) set memory (free | awk '/^Mem:/ {print $3 "/" $2 "*" 100}' | math -s0)
set text $text " $memory%" set text $text "📈 $memory%"
# cpu # cpu
set cpu (sensors | awk '/Core /{print $3}' | sort -r | head -n 1) set cpu (sensors | awk '/Core /{print $3}' | sort -r | head -n 1)
if test -n "$cpu" if test -n "$cpu"
set text $text " $cpu" set text $text "🌡 $cpu"
end end
# battery # battery
set battery (cat /sys/class/power_supply/BAT0/capacity 2>/dev/null || echo "-1") set battery (cat /sys/class/power_supply/BAT0/capacity 2>/dev/null || echo "-1")
if test "$battery" -gt -1 if test "$battery" -gt -1
set plugged (cat /sys/class/power_supply/AC/online) set plugged (cat /sys/class/power_supply/AC/online)
if test "$plugged" -eq 1 if test "$plugged" -eq 1
set battery " $battery%" set battery "🔌 $battery%"
else else
if test $battery -gt 90 set battery "🔋 $battery%"
set battery " $battery%" #if test $battery -gt 90
else if test $battery -gt 75 #set battery " $battery%"
set battery " $battery%" #else if test $battery -gt 75
else if test $battery -gt 50 #set battery " $battery%"
set battery " $battery%" #else if test $battery -gt 50
else if test $battery -gt 25 #set battery " $battery%"
set battery " $battery%" #else if test $battery -gt 25
else #set battery " $battery%"
set battery " $battery%" #else
end #set battery " $battery%"
#end
end end
set text $text "$battery" set text $text "$battery"
end end
# | sed 's/Mon/一/; s/Tue/二/; s/Wed/三/; s/Thu/四/; s/Fri/五/; s/Sat/六/; s/Sun/日/;' # | sed 's/Mon/一/; s/Tue/二/; s/Wed/三/; s/Thu/四/; s/Fri/五/; s/Sat/六/; s/Sun/日/;'
set dt (date +"%m-%d %H:%M %a") set dt (date +"%m-%d %H:%M %a")
set text $text " $dt" set text $text " $dt"
set text (string join ' ' $text) set text (string join ' ' $text)
xsetroot -name " $text " xsetroot -name " $text "