diff options
| author | msinkec <44239392+msinkec@users.noreply.github.com> | 2019-06-12 21:08:38 +0200 |
|---|---|---|
| committer | Luke Smith <luke@lukesmith.xyz> | 2019-06-12 15:08:38 -0400 |
| commit | 2e33d77b156d071ae408c8d463d43d41ba7aa68b (patch) | |
| tree | 8e09ebf4d9c3e9f1634ae8b3a76769abd2db983a /.local/bin | |
| parent | b5925045a3463c65320d3ae409442fb81d2db324 (diff) | |
| download | eibhear-2e33d77b156d071ae408c8d463d43d41ba7aa68b.tar.gz eibhear-2e33d77b156d071ae408c8d463d43d41ba7aa68b.tar.zst eibhear-2e33d77b156d071ae408c8d463d43d41ba7aa68b.zip | |
Refreshing dwm status bar using signals. (#332)
Refreshing the status bar is now done using signals.
Diffstat (limited to '.local/bin')
| -rwxr-xr-x | .local/bin/dwmbar | 21 | ||||
| -rwxr-xr-x | .local/bin/refbar | 5 |
2 files changed, 18 insertions, 8 deletions
diff --git a/.local/bin/dwmbar b/.local/bin/dwmbar index 501ae6a..3f4a0ba 100755 --- a/.local/bin/dwmbar +++ b/.local/bin/dwmbar @@ -3,6 +3,9 @@ # This script sets the statusbar with the xsetroot command at the end. Have it # started by ~/.xinitrc or ~/.xprofile. +# Handle SIGTRAP signals sent by refbar to update the status bar immediately. +trap 'update' 5 + # Set the deliminter character. delim="|" @@ -66,20 +69,28 @@ status() { \ date '+%Y %b %d (%a) %I:%M%p' } -while :; do +update() { \ # So all that big status function was just a command that quicking gets # what we want to be the statusbar. This xsetroot command is what sets # it. Note that the tr command replaces newlines with spaces. This is # to prevent some weird issues that cause significant slowing of # everything in dwm. Note entirely sure of the cause, but again, the tr # command easily avoids it. - xsetroot -name "$(status | tr '\n' ' ')" + xsetroot -name "$(status | tr '\n' ' ')" & + wait # Check to see if new weather report is needed. testweather & + wait + } + +while :; do + update # Sleep for a minute after changing the status bar before updating it - # again. Note that the `refbar` "refreshes" the statusbar by killing - # this command. Feel free to change the time interval if you want. - sleep 1m + # again. We run sleep in the background and use wait until it finishes, + # because traps can interrupt wait immediately, but they can't do that + # with sleep. + sleep 1m & + wait done diff --git a/.local/bin/refbar b/.local/bin/refbar index 671c450..78b5018 100755 --- a/.local/bin/refbar +++ b/.local/bin/refbar @@ -1,6 +1,5 @@ #!/bin/sh # Refresh the dwmbar. -# Right now, now this is done is by killing the sleep in the bar script. - -kill "$(pstree -lp | grep -- -dwmbar\([0-9] | sed "s/.*sleep(\([0-9]\+\)).*/\1/")" +# Send SIGTRAP signal to dwmbar script, which will handle it with a trap. +pkill -SIGTRAP dwmbar |
