statusclick - bakkeby/dusk GitHub Wiki
Function | Expected argument | Default keybinding |
---|---|---|
statusclick | integer | N/A |
The statusclick
function is what handles button clicks on the different statuses on the bar.
You may want to have a look at the bar rules and how the status module works in general and how to set up individual statuses.
Status clicks are handled by a single external script that is defined by the statusclickcmd
variable in config.h:
static const char *statusclickcmd[] = { NULL, "/path/to/statusclick.sh", NULL };
This script is essentially called (spawned) every time the user clicks on any of the statuses.
When the script spawned there are two environment variables that are set:
Environment variable | Value |
---|---|
BLOCK_BUTTON | The integer passed to the statusclick function |
BLOCK_STATUS | The status number, e.g. 0 , 1 , ..., 9
|
This allows for the script to differentiate between which status was clicked and which button was clicked.
The argument passed to the statusclick
function can be an arbitrary number, but generally this
will be the same as the button number pressed.
The default configuration passes these values:
static Button buttons[] = {
/* click event mask button function argument */
...
{ ClkStatusText, 0, Button1, statusclick, {.i = 1 } },
{ ClkStatusText, 0, Button2, statusclick, {.i = 2 } },
{ ClkStatusText, 0, Button3, statusclick, {.i = 3 } },
{ ClkStatusText, 0, Button4, statusclick, {.i = 4 } },
{ ClkStatusText, 0, Button5, statusclick, {.i = 5 } },
{ ClkStatusText, 0, Button6, statusclick, {.i = 6 } },
{ ClkStatusText, 0, Button7, statusclick, {.i = 7 } },
{ ClkStatusText, 0, Button8, statusclick, {.i = 8 } },
{ ClkStatusText, 0, Button9, statusclick, {.i = 9 } },
{ ClkStatusText, Shift, Button1, statusclick, {.i = 10 } },
{ ClkStatusText, Shift, Button2, statusclick, {.i = 11 } },
{ ClkStatusText, Shift, Button3, statusclick, {.i = 12 } },
...
As an example Shift+right click
gives a different button number of 12 to allow the click handling
script to treat these differently.
You can repeat this pattern if you have a mouse with more than 9 buttons.
Here is an example status click script that simply delegates to other scripts depending on which status was clicked.
#!/bin/sh
case $BLOCK_STATUS in
0) ~/bin/statusbar/clock_click ;;
1) ~/bin/statusbar/volume_click ;;
2) ~/bin/statusbar/mem_click ;;
3) ~/bin/statusbar/cpu_click ;;
4) ~/bin/statusbar/sysupdates_paru_click ;;
5) ~/bin/statusbar/mouse_battery_click ;;
7) ~/bin/statusbar/statusbutton_click ;;
*) notify-send -t 2000 "Unknown status $BLOCK_STATUS clicked $BLOCK_BUTTON" & ;;
esac
And here is the example click handling script for status number 0:
#!/bin/sh
case $BLOCK_BUTTON in
1) notify-send -t 3000 "$(date '+%A')" "📅 $(date '+%B %dXX' | sed -r -e 's/(1[123])XX/\1th/;s/1XX/1st/;s/2XX/2nd/;s/3XX/3rd/;s/XX/th/;s/ 0/ /')" & ;;
2) st -t "Calendar" -e bash -c "cal -y; read -n 1 -p '' ignored" & ;;
3) notify-send -t 9000 "$(date '+%A')" "$(cal --color=never)" & ;;
8) subl ~/bin/statusbar/clock ;;
9) subl ~/bin/statusbar/clock_click ;;
*) notify-send -t 2000 "clock $BLOCK_BUTTON" & ;;
esac
More example scripts can be found under the dusk.resources repository.
There are no external commands for the statusclick
function.