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
ICON=" "
ICON="\x0c\x0b"
read -r capacity </sys/class/power_supply/BAT0/capacity
echo "${ICON}${capacity}%"
printf "$ICON%s%%" "$capacity"

View file

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

View file

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

View file

@ -1,11 +1,12 @@
#!/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 |
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 ($1 == "index:") {
@ -29,7 +30,7 @@ pacmd list-sinks |
}
END {
if (f) {
printf "%s", h ? (m ? ihm : ihn) : (m ? ism : isn)
printf "%s", h ? (m ? ICONhm : ICONhn) : (m ? ICONsm : ICONsn)
if (vb) {
print vb
} else {