You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dwmblocks is a standalone piece of software that has to be installed separately.
When it comes to dwmblocks and click support it is worth having some understanding of how the click handling works and how that has evolved over time.
The original statuscmd patch would execute a series of predefined commands as configured in config.h - this is what is now referred to the "nosignal" variants of the statuscmd patch.
When click support for dwmblocks was introduced this used SIGUSR1 kill signals and later this was changed to use SIGRTMIN (real time) kill signals instead - this means that there are two sets of patches out there for both dwm and for dwmblocks and they work differently.
Below are instructions on how to set up both versions.
The integer value passed here represents the mouse button where 1 is left click, 2 is right click, 3 is middle click, etc. This has nothing to do with the blocks or the signals sent to dwmblocks. If desired one could for example send 71 as the value to indicate that the left mouse button was clicked while shift was held down, which could be used to add special behaviour on the script side.
The command is either an inline command or more commonly referring to a shell script when click handling is involved. Make sure that your shell scripts are marked as being executable. The interval represents how often the command should run, in seconds, while the signal is used in relation to force updating a particular block. In a patched dwmblocks the signal value is included at the start of each block in the final output string and is later stripped out by dwm for display purposes, but are taken into account when determining which block the user clicked on.
A signal with value of 0 means no signal, which ultimately means no click support. Make sure to use unique signals for each of your blocks and values less than 30 (which is the space character).
The delim setting defines the delimiter used between blocks. The delimLen represents the length of the delimiter which for some reason is not derived at runtime.
The catch all notify-send is by no means necessary, but is convenient when testing button clicks.
To force-update a specific block as part of a script, e.g. to have the bar update when the volume changes, a kill signal will have to be sent to dwmblocks.
pkill -RTMIN+2 dwmblocks
The 2 above refers to the update signal as configured in dwmblocks, so if the block has an update signal of 6 then use -RTMIN+6.
Common issues
Here are some common issues in relation to using dwmblocks.
When combined with status2d - the status is cut off or dwm crashing
dwmblocks by default outputs a status that is capped at 50 characters, refer to this line in dwmblocks.c. Increase this as you see fit.
#defineCMDLENGTH 50
Note that the status2d patch for dwm has poor handling of incomplete markup which can result in dwm crashing when trying to create colours that are invalid.
Blocks unrelated to the block that was clicked goes missing until the next update
This can happen if a block (script) was executing when the kill signal related to the mouse click was received by dwmblocks. It is unclear whether this has something to do with using SIGRTMIN signals rather than SIGUSR1, but Luke Smith's build of dwmblocks seems to not have this issue.
Clicks are not working
There are many cogs in play here so this could be due to a lot of things, e.g.
not having a patched dwmblocks that can handle signals
using a SIGUSR1 version of dwmblocks with a SIGRTMIN version of dwm or vice versa
not using the right environment variable ($BLOCK_BUTTON or $BUTTON) in dwmblocks scripts depending on whether the SIGUSR1 or SIGRTMIN patch was used
not having set an update signal for the script in dwmblocks' blocks configuration
having duplicate update signals in dwmblocks' blocks configuration (causes only the first block to trigger)
having changed the values for the sigstatusbar button handlers in dwm config to something that the dwmblocks script does not handle
Note that update signals are essentially inserted as control characters in the dwmblocks output and some signals such as 10 (newline) and 13 (carriage return) may potentially cause issues depending on how the text is handled, but in general this should not be an issue. Try other signals if in doubt and refer to an ASCII table for what the control characters actually mean.
Clicks are misaligned
This typically happens when one tries to incorporate other patches that affect the position of the status and not having discrepancies between what the drawbar function draws and what the buttonpress function calculates having been drawn. Keep in mind that the bar is drawn in full in one go which means that it draws the status on the right, then it draws the tags on the left, the layout symbol and then the window titles. The buttonpress function tries to calculate what the user clicked on by going through the same process by calculating the width of each tag, etc.
Users most commonly have these kind of issues when trying to incorporate the systray or barpadding patches as these affects the width of the bar. You break it, you buy it.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
dwmblocks is a standalone piece of software that has to be installed separately.
When it comes to dwmblocks and click support it is worth having some understanding of how the click handling works and how that has evolved over time.
The original statuscmd patch would execute a series of predefined commands as configured in config.h - this is what is now referred to the "nosignal" variants of the statuscmd patch.
When click support for dwmblocks was introduced this used
SIGUSR1
kill signals and later this was changed to useSIGRTMIN
(real time) kill signals instead - this means that there are two sets of patches out there for both dwm and for dwmblocks and they work differently.Below are instructions on how to set up both versions.
SIGRTMIN
Building dwmblocks:
dwm-flexipatch enable these patches:
BAR_DWMBLOCKS_PATCH
BAR_STATUSCMD_PATCH
dwm:
dwmblocks scripts:
$BUTTON
environment variable to indicate mouse clicksSIGUSR1
Building dwmblocks:
dwm-flexipatch enable these patches:
BAR_DWMBLOCKS_PATCH
BAR_DWMBLOCKS_SIGUSR1_PATCH
BAR_STATUSCMD_PATCH
dwm:
sigstatusbar
function to use SIGUSR1 signals rather than SIGRTMIN referring to this difference:dwm-flexipatch/patch/bar_dwmblocks.c
Lines 38 to 49 in 96820b2
dwmblocks scripts:
$BLOCK_BUTTON
environment variable to indicate mouse clicksConfiguration
dwm
In general you should not need to make any changes to the configuration in dwm, but here are the options.
You only need to change this if the executable has a name other than "dwmblocks".
dwm-flexipatch/config.def.h
Lines 818 to 819 in 96820b2
This you only need to change if you are adding support for additional buttons, e.g. 4 and 5 for mouse wheel.
dwm-flexipatch/config.def.h
Lines 1261 to 1263 in 96820b2
The integer value passed here represents the mouse button where 1 is left click, 2 is right click, 3 is middle click, etc. This has nothing to do with the blocks or the signals sent to dwmblocks. If desired one could for example send
71
as the value to indicate that the left mouse button was clicked while shift was held down, which could be used to add special behaviour on the script side.dwmblocks
Blocks are defined as:
The
command
is either an inline command or more commonly referring to a shell script when click handling is involved. Make sure that your shell scripts are marked as being executable. Theinterval
represents how often the command should run, in seconds, while thesignal
is used in relation to force updating a particular block. In a patched dwmblocks the signal value is included at the start of each block in the final output string and is later stripped out by dwm for display purposes, but are taken into account when determining which block the user clicked on.A
signal
with value of 0 means no signal, which ultimately means no click support. Make sure to use unique signals for each of your blocks and values less than 30 (which is the space character).The
delim
setting defines the delimiter used between blocks. ThedelimLen
represents the length of the delimiter which for some reason is not derived at runtime.Example dwmblocks script with click support:
The catch all notify-send is by no means necessary, but is convenient when testing button clicks.
To force-update a specific block as part of a script, e.g. to have the bar update when the volume changes, a kill signal will have to be sent to dwmblocks.
The
2
above refers to the update signal as configured in dwmblocks, so if the block has an update signal of6
then use-RTMIN+6
.Common issues
Here are some common issues in relation to using dwmblocks.
When combined with status2d - the status is cut off or dwm crashing
dwmblocks by default outputs a status that is capped at 50 characters, refer to this line in dwmblocks.c. Increase this as you see fit.
Note that the status2d patch for dwm has poor handling of incomplete markup which can result in dwm crashing when trying to create colours that are invalid.
Blocks unrelated to the block that was clicked goes missing until the next update
This can happen if a block (script) was executing when the kill signal related to the mouse click was received by dwmblocks. It is unclear whether this has something to do with using
SIGRTMIN
signals rather thanSIGUSR1
, but Luke Smith's build of dwmblocks seems to not have this issue.Clicks are not working
There are many cogs in play here so this could be due to a lot of things, e.g.
SIGUSR1
version of dwmblocks with aSIGRTMIN
version of dwm or vice versa$BLOCK_BUTTON
or$BUTTON
) in dwmblocks scripts depending on whether theSIGUSR1
orSIGRTMIN
patch was usedsigstatusbar
button handlers in dwm config to something that the dwmblocks script does not handleNote that update signals are essentially inserted as control characters in the dwmblocks output and some signals such as 10 (newline) and 13 (carriage return) may potentially cause issues depending on how the text is handled, but in general this should not be an issue. Try other signals if in doubt and refer to an ASCII table for what the control characters actually mean.
Clicks are misaligned
This typically happens when one tries to incorporate other patches that affect the position of the status and not having discrepancies between what the
drawbar
function draws and what thebuttonpress
function calculates having been drawn. Keep in mind that the bar is drawn in full in one go which means that it draws the status on the right, then it draws the tags on the left, the layout symbol and then the window titles. Thebuttonpress
function tries to calculate what the user clicked on by going through the same process by calculating the width of each tag, etc.Users most commonly have these kind of issues when trying to incorporate the systray or barpadding patches as these affects the width of the bar. You break it, you buy it.
Beta Was this translation helpful? Give feedback.
All reactions