Closed youssefaltai closed 1 year ago
Can you elaborate on this:
the
$clicked
variable stays the same for some reason, it doesn't change even though I update it's value after callingnotify-send
.
What I'm guessing is happening is that the script is executing, and $clicked
's value, within the local scope of this script alone, is being updated. The script finishes and variable is now "out of scope," thus its value is lost. I think that you're expecting $clicked
to retain its value between runs, which is something you can achieve by reading/storing its value in a text file, for example, rather than a temporary variable
I could be totally off-base with that guess, though, but it's the first thing that came to mind as a potential cause/solution
Corbin
I think that you're expecting
$clicked
to retain its value between runs, which is something you can achieve by reading/storing its value in a text file, for example, rather than a temporary variable
You are right, that's exactly what was happening.
Here is the new script:
#!/usr/bin/bash
clicked=$(cat /tmp/clicked)
case $BUTTON in
1) notify-send hello; echo "left" > /tmp/clicked;;
3) notify-send goodbye; echo "right" > /tmp/clicked;;
esac
printf $clicked
Now it works just fine, thank you, Corbin.
Problem
I have a simple bash script
myscript.sh
:and I have this in
dwmblocks/blocks.h
:and this in
dwm/config.h
:What I would like to happen is for the block to display "my script: none" at first, and every time I left-click it I would like it to display "my script: left", and "my script: right" every time I right-click it.
The current behavior is that when I left-click the block,
notify-send
works and I get a notification saying "hello", and when I right-click it I get a notification saying "goodbye", but the$clicked
variable stays the same for some reason, it doesn't change even though I update it's value after callingnotify-send
.What am I missing?
Patches
I applied this patch to dwm: https://dwm.suckless.org/patches/statuscmd/dwm-statuscmd-20210405-67d76bd.diff
and this one to dwmblocks: https://dwm.suckless.org/patches/statuscmd/dwmblocks-statuscmd-20210402-96cbb45.diff