Custom combo keybindings

Forum rules
Share your brain ;)
User avatar
catfood
Bad Advice Dog
Posts: 146
Joined: Tue Oct 04, 2016 1:25 am
Location: F google
Contact:

Custom combo keybindings

Unread post by catfood » Fri Nov 18, 2016 7:16 am

I can't promise this will work for all WMs. I got the info from a dwm page and it works in 2wm.

So I'm lazy and wanted my Super key only pseudo "Whisker Menu" regardless of Window Manager... (Alt+P is one key too many for my dmenu!)

https://wiki.archlinux.org/index.php/dw ... g_config.h
Single keys such as Fn or multimedia keys have to be bound with the hex codes obtainable from the program xev.
{ 0, 0xff00, spawn, {.v = keybindname } } would bind foo key 0xff00 to keybindname.
See Extra keyboard keys#Keycodes for information on finding keycodes.
(https://wiki.archlinux.org/index.php/Ex ... s#Keycodes)
I'm on a laptop with an internal "usb" keyboard, so xev worked best for hex capturing my keys. 2nd link info may be necessary for other hardware.

Open a terminal:
Type xev [ enter ]
A white terminal will open. ANY key you press in here will display its info in the 1st terminal.
The hex value for all the odd keys will likely begin with 0x____ , so look for that.
(Keysym 0xffeb, Super_L)
(Keysym 0xffeb, Super_L)
In 2wm config.h:

Code: Select all

#define KEYS \
static Key key[] = { \
        /* modifier                     key             function        argument */ \
        { MODKEY|ShiftMask,             XK_Return,      spawn, \
                { .cmd = "exec urxvt -bg '#111' -fg '#009966' -cr '#eee' +sb -fn '-*-terminus-medium-r-*-*-14-*-*-*-*-*-*-*'$
        { 0,                            0xffeb,         spawn, \
                { .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \
                        " | dmenu -fn '-*-terminus-medium-r-*-*-14-*-*-*-*-*-*-*' -nb '#222' -nf '#ccc' " \
                        "-sb '#555' -sf '#fff')\" && exec $exe" } }, \

Under #define KEYS \
Any combo keybinding you want to change to solo key:
Replace MODKEY, modifier with 0,
Replace XK_key, with 0x#### hex value obtained from xev terminal.
Save config.h

(edit: In openbox, <keybind key="W- "> works for Mod4+__, as long as it has a key to modify. Super_L works to use the key by itself without a 2nd keypress.)

Recompile (if necessary)
Last edited by catfood on Tue Sep 01, 2020 1:32 am, edited 2 times in total.
Thank You!
(I remember when debian "non-gui" installer scared me. #never-forget)

User avatar
catfood
Bad Advice Dog
Posts: 146
Joined: Tue Oct 04, 2016 1:25 am
Location: F google
Contact:

Re: Custom combo keybindings

Unread post by catfood » Mon Aug 10, 2020 12:37 am

Again, the same methods used to restore Fn keys (where 2wm ignored their default values)
machinebacon wrote:
Sat Jul 18, 2020 9:38 pm

Code: Select all

/* modifier                     key             function        argument */ \
{ 0,                            0x1008ff13,     spawn, \	{ .cmd = "amixer set PCM 10%+" } }, \
{ 0,                            0x1008ff11,     spawn, \	{ .cmd = "amixer set PCM 10%-" } }, \
Thank You!
(I remember when debian "non-gui" installer scared me. #never-forget)

Post Reply