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

Cant click blocks #11

Closed
twoeightdev opened this issue Jan 11, 2022 · 8 comments
Closed

Cant click blocks #11

twoeightdev opened this issue Jan 11, 2022 · 8 comments

Comments

@twoeightdev
Copy link

twoeightdev commented Jan 11, 2022

hi, thanks for your work, everythings good but i'm having problem with clicking on the blocks as it does nothing. here is my config:

#define CMDLENGTH 60
#define DELIMITER " | "
#define CLICKABLE_BLOCKS

const Block blocks[] = {
    BLOCK("sb-mail",        180,        17),
    BLOCK("sb-news",        1,          18),
    BLOCK("sb-forecast",    18000,      19),
    BLOCK("sb-memory",      1,          20),
    BLOCK("sb-gpu",         1,          21),
    BLOCK("sb-cpu",         1,          22),
    BLOCK("sb-time",        0,          23),
    BLOCK("sb-date",        1,          24),
    // BLOCK("sb-network", 5,    25),
};

and here is the script for sb-news

#!/bin/sh

case $BLOCK_BUTTON in
    1) setsid "$TERMINAL" -e newsboat ;;
esac

. sb-theme
display "$(cat /tmp/newsupdate 2>/dev/null || echo "$(newsboat -x print-unread | awk '{ if($1>0) print "NEWS:" $1}')")"

i use this statuscmd-status2d-with-signal

did i do it all correctly?😅 thanks for the help

Edit: distro- Void linux

@UtkarshVerma
Copy link
Owner

Did you patch your dwm as mentioned in the README under the clickability section?
At a glance, everything you have here seems fine.

@twoeightdev
Copy link
Author

Did you patch your dwm as mentioned in the README under the clickability section? At a glance, everything you have here seems fine.

yes sir i already did. i use this to patch dwm. i use the statuscmd-status2d the one wtih signal.

i have this on my dwm

#define STATUSBAR "dwmblocks"

    { ClkStatusText,        0,              Button1,        sigstatusbar,   {.i = 1} },
    { ClkStatusText,        0,              Button2,        sigstatusbar,   {.i = 2} },
    { ClkStatusText,        0,              Button3,        sigstatusbar,   {.i = 3} },

@UtkarshVerma
Copy link
Owner

UtkarshVerma commented Jan 11, 2022

You've applied the patch for status2d, but you need to change a line in the source code of dwm. Change these lines:

				return statuspid;
		}
	}
-	if (!(fp = popen("pidof -s "STATUSBAR, "r")))
+	if (!(fp = popen("pgrep -o "STATUSBAR, "r")))
		return -1;
	fgets(buf, sizeof(buf), fp);
	pclose(fp);

This is covered in the README. It you do this properly, clickability will start working.

@twoeightdev
Copy link
Author

You've applied the patch for status2d, but you need to change a line in the source code of dwm. Change these lines:

				return statuspid;
		}
	}
-	if (!(fp = popen("pidof -s "STATUSBAR, "r")))
+	if (!(fp = popen("pgrep -o "STATUSBAR, "r")))
		return -1;
	fgets(buf, sizeof(buf), fp);
	pclose(fp);

yea i already did that:

pid_t
getstatusbarpid()
{
    char buf[32], *str = buf, *c;
    FILE *fp;

    if (statuspid > 0) {
        snprintf(buf, sizeof(buf), "/proc/%u/cmdline", statuspid);
        if ((fp = fopen(buf, "r"))) {
            fgets(buf, sizeof(buf), fp);
            while ((c = strchr(str, '/')))
                str = c + 1;
            fclose(fp);
            if (!strcmp(str, STATUSBAR))
                return statuspid;
        }
    }
    if (!(fp = popen("pgrep -s "STATUSBAR, "r")))
        return -1;
    fgets(buf, sizeof(buf), fp);
    pclose(fp);
    return strtoul(buf, NULL, 10);
}

btw im using this on fresh dwm 6.3 no other patch atm only this.

@twoeightdev
Copy link
Author

twoeightdev commented Jan 11, 2022

oops i think the pgrep -s and should be pgrep -o makes it not working. i'll try and report sir.

Edit: Fixed! thank you sir 😊

@UtkarshVerma
Copy link
Owner

oops i think the pgrep -s and should be pgrep -o makes it not working. i'll try and report sir.

Yeah, double check that command as it is responsible for sending click events to dwmblocks.

Also, for debugging, ensure that you only have one instance of dwmblocks running by using

killall -9 dwmblocks

And then launching dwmblocks.

@kovmos
Copy link

kovmos commented Feb 21, 2022

Hey sorry to reopen this but I'm having the same problem and changing pgrep -s to pgrep -o doesn't seem to fix it.
Here is my config of dwmblocks:

#define CMDLENGTH 60
#define DELIMITER "  "
#define CLICKABLE_BLOCKS

const Block blocks[] = {
        BLOCK("sb-test",    1, 17),
};

Here is the script "sb-test":

#!/bin/sh

case $BLOCK_BUTTON in
        1) notify-send "hello" ;;
esac

case $BUTTON in
        1) notify-send "hello" ;;
esac

echo "hello"

I added a second case statement with the $BUTTON variable since that's what it's used on the example on the page for the statuscmd patch but it didn't work either.
Here is the relevant seccion of dwm.c just in case:

                        fclose(fp);
                        if (!strcmp(str, STATUSBAR))
                                return statuspid;
                }
        }
        if (!(fp = popen("pidof -o "STATUSBAR, "r")))
                return -1;
        fgets(buf, sizeof(buf), fp);
        pclose(fp);
        return strtol(buf, NULL, 10);

I tested everything on a fresh install of dwm, only the statuscmd patch applied.
I'm really lost on how to get this working so I appreciate any help :D

@UtkarshVerma
Copy link
Owner

It should work with the statsuscmd patch and changing the line I mentioned in the README to pgrep. Also, please use the $BLOCK_BUTTON variable.

You could try debugging this:

# Have only one block in config.h, set interval to 0

# Kill all previous instances
killall dwmblocks -9

# Create a new instance of dwmblocks and watch its stacktrace for signals
strace -e 'trace=!all' dwmblocks

Check if you get any updates in strace on clicking on the statusbar.

gsavarela added a commit to gsavarela/mydots that referenced this issue Jun 18, 2022
dme86 added a commit to dme86/dwm that referenced this issue Mar 27, 2023
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

3 participants