bakkeby / dwm-flexipatch

A dwm build with preprocessor directives to decide which patches to include during build time
MIT License
1.15k stars 232 forks source link

Use human readable modifier keys for keybindings #265

Open bakkeby opened 2 years ago

bakkeby commented 2 years ago

Rather than using ShiftMask, ControlMask, Mod1Mask, Mod4Mask, etc. for the modifier keys in dwm keybindings we could define macros on this form:

#define Shift ShiftMask
#define Ctrl ControlMask
#define Alt Mod1Mask
#define AltGr Mod3Mask
#define Super Mod4Mask
#define ShiftGr Mod5Mask

When used this

#define TAGKEYS(KEY,TAG) \
    { MODKEY,                       KEY,      comboview,      {.ui = 1 << TAG} }, \
    { MODKEY|ControlMask,           KEY,      toggleview,     {.ui = 1 << TAG} }, \
    { MODKEY|ShiftMask,             KEY,      combotag,       {.ui = 1 << TAG} }, \
    { MODKEY|ControlMask|ShiftMask, KEY,      toggletag,      {.ui = 1 << TAG} }, \
    { MODKEY|Mod4Mask|ShiftMask,    KEY,      swaptags,       {.ui = 1 << TAG} }, \
    { MODKEY|Mod4Mask,              KEY,      tagnextmon,     {.ui = 1 << TAG} }, \
    { MODKEY|Mod4Mask|ControlMask,  KEY,      tagprevmon,     {.ui = 1 << TAG} },

would look like this:

#define TAGKEYS(KEY,TAG) \
    { MODKEY,                       KEY,      comboview,      {.ui = 1 << TAG} }, \
    { MODKEY|Ctrl,                  KEY,      toggleview,     {.ui = 1 << TAG} }, \
    { MODKEY|Shift,                 KEY,      combotag,       {.ui = 1 << TAG} }, \
    { MODKEY|Ctrl|Shift,            KEY,      toggletag,      {.ui = 1 << TAG} }, \
    { MODKEY|Super|Shift,           KEY,      swaptags,       {.ui = 1 << TAG} }, \
    { MODKEY|Super,                 KEY,      tagnextmon,     {.ui = 1 << TAG} }, \
    { MODKEY|Super|Ctrl,            KEY,      tagprevmon,     {.ui = 1 << TAG} },

The benefit is readability, but the downside is the potential for confusion when moving from dwm-flexipatch to bare dwm or individual patches.

explosion-mental commented 2 years ago

My take on this: I think most ppl using dwm-flexipatch are gonna build from it, specially since there is a script that removes all the bloat. tbh I really think the renaming is really nice (less chars), whoever it's building their dwm from the ground up might as well re-rename the mods (for example Shift -> ShiftMask and so on).

N-R-K commented 2 years ago

The benefit is readability

That depends. If the reader is already familiar with configuring suckless style config.h then the newer macros will actually confuse him, at least at first.

But if we assume most users to be newbie (fair and probably correct assumption) then "super" is arguable. Most people call it the "windows key" or the "win-key".

P.S: I also think there's lower hanging fruits to be picked if making config.h frenlier to newbies is a goal. For example the tag rules uses a bitmask, which is certainly far less readable to newbies compared to pesky ControlMask => Ctrl.