You are not logged in.

#1 2013-03-06 13:19:27

enduser
Member
Registered: 2012-10-04
Posts: 25

xmonad change modMask if mac keyboard

I'd like to change my modMask in xmonad if I'm on a mac, but otherwise leave it alone.  I'm confused about two different aspects of this.  Can I tell the difference between a qwerty on a mac vs non-mac keyboards?  And is there a way to get the default value for modMask or conditionally set it (instead of just looking up the default and hardcoding it)?  I'm not sure how this would work if I had an external keyboard hooked up to my mac, but it'd be cool to at least get it working for the normal cases.  Thanks for any help smile

Offline

#2 2013-03-09 11:47:05

chpln
Member
From: Australia
Registered: 2009-09-17
Posts: 361

Re: xmonad change modMask if mac keyboard

To answer the questions directly:
1) The only means I know of is using the USB product and vendor IDs.  The layout and variant is not published by the keyboard.
2) It's haskell.  But this may not be necessary:

Perhaps instead of making the modMask dynamic, you could use xmodmap to change the key membership of the corresponding modifier?  And udev should be able to handle the keyboard detection.

I have 2 xmodmap config files (one for each state), which are triggered by a udev script like:
/etc/udev/rules.d/90-kbd.rules:

SUBSYSTEM=="usb", ATTRS{idVendor}=="<USB vendor ID>", ATTRS{idProduct}=="<USB product ID>", ENV{REMOVE_CMD}="<command to set state on removal>", RUN+="<command to set state on device connection>"

And so you can use this to set a default layout (REMOVE_CMD), and alter it when a certain device is attached (RUN).

You will probably need to use xhost to loosen security on the X11 session so xmodmap can make the changes when initiated via udev.

Offline

#3 2013-03-09 15:44:27

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,727

Re: xmonad change modMask if mac keyboard

chpln wrote:

... The only means I know of is using the USB product and vendor IDs.  The layout and variant is not published by the keyboard.
...

One might also look at the contents of /proc/bus/input/devices


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#4 2013-03-15 19:42:19

enduser
Member
Registered: 2012-10-04
Posts: 25

Re: xmonad change modMask if mac keyboard

Hmm, thanks for the info.  I've tried a couple of different keyboards, and actually started learning emacs, so now I would prefer to always use super as my mod key, so I can have alt for readline/emacs.  Cheers smile

end

Offline

Board footer

Powered by FluxBB