How To: Refresh your status bar in response to a hotkey - Desktop Customization & Workflow

Users browsing this thread: 1 Guest(s)
pfr
Nixers
Ok, so I've tried but I cannot get this working. My config is below:

PHP Code:
<?php 
#!/bin/sh

Volume() {
VolInf="$(mixerctl outputs.master | sed -e 's|.*,||g')"
echo "Vol $name $(expr \( $VolInf \* 100 \) / 254)%"
}

Battery() {
Capacity="$(envstat -s acpibat0:charge | tail -1 | sed -e 's,.*(\([ ]*[0-9]*\)\..*,\1,g')%"
State="$(envstat -d acpibat0 | awk 'FNR == 10 {print $2}')"

if [ "${State}" = "TRUE" ]; then
echo 'Charging' ${Capacity}
else
echo
'Discharging' ${Capacity}
fi
}

Weather() {
echo
"$(curl -s wttr.in/Melbourne?format='%C+%t\n')"
}

Pkgs() {
echo
"$(pkg_info | wc -l | sed -e 's/^[ \t]*//') pkgs"
}

Update() {
echo \
"$(Weather) | $(Pkgs) | $(Battery) | $(Volume)" &
wait
}

pidfile="/tmp/status-$USER.pid"

if [ "$1" = "reload" ]; then
kill
-USR1 "$(cat "$pidfile")"
exit $?
fi

if [ "$1" != "no-pidfile" ]; then
echo "$$" > "$pidfile"
fi
trap true USR1

while :
do
Update
sleep 60
&
wait $!
done

I've also added this to my .spectrwm.conf

PHP Code:
<?php 
# Volume Keys
program[raise_volume] = mixerctl -w outputs.master+=12 && kill -USR1 "$(cat "/tmp/status-$USER.pid")"
bind[raise_volume] = XF86AudioRaiseVolume
program
[lower_volume] = mixerctl -w outputs.master-=12 && kill -USR1 "$(cat "/tmp/status-$USER.pid")"
bind[lower_volume] = XF86AudioLowerVolume
_____________________________________________________________________________________________
“Maybe you have some bird ideas... Maybe that's the best you can do.” - Terry A. Davis (R.I.P Terry & Percival)


Messages In This Thread
RE: How To: Refresh your status bar in response to a hotkey - by pfr - 01-09-2020, 08:19 AM