LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   How to make key-binds to execute shell scripts in DWM (https://www.linuxquestions.org/questions/linux-desktop-74/how-to-make-key-binds-to-execute-shell-scripts-in-dwm-4175683954/)

pottag 10-20-2020 12:35 PM

How to make key-binds to execute shell scripts in DWM
 
I want to make DWM execute a shell script when I press a series of keys. Like this would do in I3 "bindsym $mod+p exec ~/Tests/shell/mpc-play.sh" Thank you!

sevendogsbsd 10-20-2020 12:54 PM

Guessing you would have to modify the config.h (?) and recompile. Been a while since I have used DWM. You can add your own bindings I think - probably just figure out the key codes and add them in the appropriate spot. I have modified key bindings but not added my own.

individual 10-20-2020 02:28 PM

Quote:

Originally Posted by pottag (Post 6177129)
I want to make DWM execute a shell script when I press a series of keys. Like this would do in I3 "bindsym $mod+p exec ~/Tests/shell/mpc-play.sh" Thank you!

As sevendogsbsd said, you need to add a keybinding in config.h and recompile dwm.
In config.h, define an array of character pointers (strings) to hold the script name, and any arguments it may take, and it must end with NULL.
Code:

static const char *mpcplay[] = { "/absolute/path/to/mpc-play.sh", "ARGUMENTS", NULL };
In the "keys" structure, also in config.h, you can add something like the following.
Code:

{ MODKEY, p, spawn, {.v = mpcplay} },

Si-Ki 10-31-2021 12:22 AM

thanks for the solution, I'm a total newb to all this and wanted to ask you if there is some documentation page that you could guide me to that has all such basic stuff, and also, I wanted to know how to set variables and use them, for eg.

I use brave as my browser.
I downloaded Luke Smith's build of DWM and it has "$BROWSER" all over the config.h file, and there is a key bind to for executing $BROWSER but i believe the value of $BROWSER is not set to brave, how do i fix that?

thanks :)


All times are GMT -5. The time now is 08:42 PM.