Improved block scripts

This commit is contained in:
Ashish Kumar Yadav 2020-12-27 20:58:23 +05:30
parent 4c600ba975
commit 5ec0e8ab9c
4 changed files with 17 additions and 16 deletions

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh
ICON=" " ICON="\x0c\x0b"
read -r capacity </sys/class/power_supply/BAT0/capacity read -r capacity </sys/class/power_supply/BAT0/capacity
echo "${ICON}${capacity}%" printf "$ICON%s%%" "$capacity"

View file

@ -1,3 +1,3 @@
#!/bin/sh #!/bin/sh
ICON=" " ICON="\x0c\x0b"
echo "${ICON}$(date '+%a, %d %b')" printf "$ICON%s" "$(date '+%a, %b %d, %R')"

View file

@ -1,15 +1,15 @@
#!/bin/sh #!/bin/sh
ICONc=" " # icon for critical temperatures ICONn="\x0c\x0b" # icon for normal temperatures
ICONn=" " # icon for normal temperatures ICONc="\x0d\x0b" # icon for critical temperatures
crit=70 # critical temperature crit=70 # critical temperature
read -r temp </sys/class/thermal/thermal_zone0/temp read -r temp </sys/class/thermal/thermal_zone0/temp
temp=${temp%???} temp=${temp%???}
if [ "$temp" -ge "$crit" ] ; then if [ "$temp" -lt "$crit" ] ; then
echo "${ICONc}${temp}°C" printf "$ICONn%s°C" "$temp"
else else
echo "${ICONn}${temp}°C" printf "$ICONc%s°C" "$temp"
fi fi

View file

@ -1,11 +1,12 @@
#!/bin/sh #!/bin/sh
ICONhm=" " # headphone plugged in, muted
ICONhn=" " # headphone plugged in, not muted
ICONsm=" " # headphone unplugged, muted
ICONsn=" " # headphone unplugged, not muted
pacmd list-sinks | pacmd list-sinks |
awk -v ihm="$ICONhm" -v ihn="$ICONhn" -v ism="$ICONsm" -v isn="$ICONsn" ' awk '
BEGIN {
ICONsn = "\x0c\x0b" # headphone unplugged, not muted
ICONsm = "\x0d\x0b" # headphone unplugged, muted
ICONhn = "\x0c\x0b" # headphone plugged in, not muted
ICONhm = "\x0d\x0b" # headphone plugged in, muted
}
{ {
if (f) { if (f) {
if ($1 == "index:") { if ($1 == "index:") {
@ -29,7 +30,7 @@ pacmd list-sinks |
} }
END { END {
if (f) { if (f) {
printf "%s", h ? (m ? ihm : ihn) : (m ? ism : isn) printf "%s", h ? (m ? ICONhm : ICONhn) : (m ? ICONsm : ICONsn)
if (vb) { if (vb) {
print vb print vb
} else { } else {