Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can a dwmblock update its output based on $BUTTON? #72

Closed
youssefaltai opened this issue Apr 25, 2023 · 0 comments
Closed

How can a dwmblock update its output based on $BUTTON? #72

youssefaltai opened this issue Apr 25, 2023 · 0 comments

Comments

@youssefaltai
Copy link

Problem

I have a simple bash script myscript.sh:

#!/usr/bin/bash

clicked="none"

case $BUTTON in
    1) notify-send hello; clicked="left";;
    3) notify-send goodbye; clicked="right";;
esac

printf $clicked

and I have this in dwmblocks/blocks.h:

//Modify this file to change what commands output to your statusbar, and recompile using the make command.
static const Block blocks[] = {
	/*Icon*/	/*Command*/		/*Update Interval*/	/*Update Signal*/
    { "my script: ", "myscript.sh", 0, 12},
};

//sets delimeter between status commands. NULL character ('\0') means no delimeter.
static char delim[] = " | ";
static unsigned int delimLen = 5;

and this in dwm/config.h:

static const Button buttons[] = {
//  ...
	{ ClkStatusText,        0,              Button1,        sigdwmblocks,   {.i = 1} },
	{ ClkStatusText,        0,              Button2,        sigdwmblocks,   {.i = 2} },
	{ ClkStatusText,        0,              Button3,        sigdwmblocks,   {.i = 3} },
// ...

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 calling notify-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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant