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

Users browsing this thread: 1 Guest(s)
movq
Long time nixers
The version without a PID file:

Code:
#!/bin/sh                                                                                                

Volume() {
    ...
    # they all stay the same
    ...
}

...

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

trap true USR1

while :
do
    Update
    sleep 60 &
    wait $!
done

Let’s say, you saved this as "update_bar.sh". Your key binds would then look like this:

Code:
# Volume Keys
program[raise_volume] = mixerctl -w outputs.master+=12 && pkill -USR1 '^update_bar.sh$'
...

Saves you the trouble of dealing with a PID file, which can contain a wrong PID. This version uses "pkill" to scan through all running processes and send the signal to the ones matching the pattern.

(This still assumes that spectrwm runs key binds using "sh -c ...". Don’t know if that’s true.)


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