Improved blocks

This commit is contained in:
Ashish Kumar Yadav 2020-11-23 11:42:13 +05:30
parent 6802c81903
commit ef29c7ddd5
5 changed files with 41 additions and 13 deletions

View file

@ -1,3 +1,4 @@
#!/bin/sh
ICON=" "
read -r capacity </sys/class/power_supply/BAT0/capacity
echo " ${capacity}%"
echo "${ICON}${capacity}%"

View file

@ -1,2 +1,3 @@
#!/bin/sh
echo " $(date '+%a, %d %b')"
ICON=" "
echo "${ICON}$(date '+%a, %d %b')"

View file

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

View file

@ -1,2 +1,3 @@
#!/bin/sh
echo " $(date '+%H:%M')"
ICON=" "
echo "${ICON}$(date '+%H:%M')"

View file

@ -1,9 +1,31 @@
#!/bin/sh
ICONhm=" " # headphone plugged in, muted
ICONhn=" " # headphone plugged in, not muted
ICONsm=" " # headphone unplugged, muted
ICONsn=" " # headphone unplugged, not muted
volstat=$(pamixer --get-mute --get-volume)
if "${volstat% *}" ; then
echo " ${volstat#* }%"
else
echo " ${volstat#* }%"
fi
pacmd list-sinks |
awk -v iconhm="$ICONhm" -v iconhn="$ICONhn" -v iconsm="$ICONsm" -v iconsn="$ICONsn" '
/\* index: /,0 {
if ($1 == "index:") {
exit
} else if ($1 == "muted:" && $2 == "yes") {
muted = 1
} else if ($1 == "volume:") {
volumel = $3
volumer = $10
volumelp = $5
volumerp = $12
} else if ($1 == "active" && $2 == "port:" && $3 ~ /headphones/) {
headphone = 1
}
}
END {
printf "%s", headphone ? (muted ? iconhm : iconhn) : (muted ? iconsm : iconsn)
if (volumel == volumer) {
print volumelp
} else {
printf "L%s R%s\n", volumelp, volumerp
}
}
'