bakkeby / dusk

Just another fork of dwm
MIT License
154 stars 21 forks source link

XF86 keys #4

Closed genzyy closed 2 years ago

genzyy commented 2 years ago

Hey bakkeby!, I am currently setting up dusk on my machine running arch linux. I was setting the keybindings and now I want to setup xf86 keys, like brightness up and down, play/pause, etc. Is there any way to do this or have I missed something in the wiki?

bakkeby commented 2 years ago

Hi @genzyy,

there is nothing using XF86 keys by default, but if you want it then you can just add this at the start of your config.h:

#include <X11/XF86keysym.h>

Then you should be able to add keybindings like XF86XK_MonBrightnessUp, XF86XK_MonBrightnessDown, etc. To not use a modifier key just leave the modifier as 0.

bakkeby commented 2 years ago

That said, I'd recommend using sxhkd for something like this as you will most likely be calling scripts or applications.

The benefit of having application keybindings in a separate key handler is that if you are window manager hopping or just trying out stuff then you can always open the same programs using the familiar keybindings without having to be concerned about having to set them up again.

genzyy commented 2 years ago
    { KeyPress,   0,                            XF86XK_MonBrightnessUp, spawn,            SHCMD("brightnessctl -q s 5%+")},
    { KeyPress,   0,                            XF86XK_MonBrightnessDown, spawn,              SHCMD("brightnessctl -q s 5%-")},

I tried adding this code in the dusk config.def.h, but when I compile and try to install it, it gives me error. I even tried adding the above mentioned header file still the error exists. What am I doing wrong here?

bakkeby commented 2 years ago

The error it gives you might be helpful :)

I don't think that you are doing anything wrong. This adds an extra dependency on having XF86keysym.h in the system of course, perhaps you do not have that.

That looks to be in the extra/xorgproto package if you are on arch, if you are on another distribution then there are different tools to work out what packages contain the file of interest.

genzyy commented 2 years ago
config.h:745:81: error: ‘XF86XK_MonBrightnessUp’ undeclared here (not in a function)
  745 |         { KeyPress,   0,                                                        XF86XK_MonBrightnessUp, spawn,                    SHCMD("brightnessctl -q s 5%+")},
      |                                                                                 ^~~~~~~~~~~~~~~~~~~~~~
config.h:746:81: error: ‘XF86XK_MonBrightnessDown’ undeclared here (not in a function)
  746 |         { KeyPress,   0,                                                        XF86XK_MonBrightnessDown, spawn,                          SHCMD("brightnessctl -q s 5%-")},
      |                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:20: dusk.o] Error 1

I get this error when I try to run make. This is the error I get. Sorry my bad I should have posted this eariler.

genzyy commented 2 years ago

That looks to be in the extra/xorgproto package if you are on arch, if you are on another distribution then there are different tools to work out what packages contain the file of interest.

I do have xorgproto installed on my system.

Maybe the temporary fix would be to use sxhkd for now

bakkeby commented 2 years ago

That error you will get if you did not add this include statement in your config.h file, as without it it doesn't know what XF86XK_MonBrightnessUp as an example refers to.

#include <X11/XF86keysym.h>
genzyy commented 2 years ago

That error you will get if you did not add this include statement in your config.h file, as without it it doesn't know what XF86XK_MonBrightnessUp as an example refers to.

#include <X11/XF86keysym.h>

Got it fixed! Thank you!

I included this file somewhere in the middle of the file config.def.h and it wasn't working. But now I included this file on top it works fine now.

Edit: We can close this issue.

bakkeby commented 2 years ago

It shouldn't matter where exactly you add it, as long as you include it before the keybindings. Adding it at the top makes most sense.