0

So my goal is just bind alt+shift to run script in xmonad. My mod key is super(win)(mod4Mask). How can I do this? This is how I try to do it now:

This is how my xmonad.sh looks like now (just path changed)

import XMonad
import XMonad.Config.Desktop
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.
import XMonad.Util.EZConfig
import System.IO

main = xmonad $ desktopConfig
  { terminal = "urxvt"
  , modMask  = mod4Mask
  } `additionalKeys`
  [ ((mod1Mask, shiftMask), spawn "/home/my-login/some-folder/my-script.sh"
  ]

And this is the error which I get: output

2 Answers 2

0

The important part of that error seems to be (with extra spaces for readability):

Expected type: KeySym

Actual type: KeyMask

In the expression: shiftMask

So, apparently you need to use a KeySym instead of a KeyMask for the second part of the key combo. That's likely because the "modifier keys" (Ctrl, Alt, Shift, Cmd/Win/Super) are "masks" (bitmasks) that change the internally-generated code when other keys are pressed, but they don't do so for each other.

If you are okay using 2 modifiers + 1 regular key for this effect you can "or" the modifiers together as per this answer and pick a KeySym that's not already mapped to that 3-key combo.

If losing/moving one of the modifier keys is okay the answer below that is from someone who uses xmodmap to remap the left Ctrl key to the left Super/Win key. So, you could remap a KeyMask to a KeySym if it would somehow be worth it.

2
  • 1
    Thank you for detailed yet clear answer! Sad that there isn't yet simple solution for binding two specific keys to one task. Jul 13, 2020 at 17:46
  • No problem :) It seems to fail because it considers two masks to be an invalid shortcut, but if that were allowed it would be fine. So, it should be possible with some other software or if you could customize xmonad or build from source, but I've never actually used any of this personally and only got the "answers" because of some searching, lol.
    – l3l_aze
    Jul 13, 2020 at 19:20
0

Yay, I found it:

, ((shiftMask, xK_Alt_L), spawn "$HOME/.local/bin/dmscripts/dm-lang"  ) -- Language Switching

You can use xmodmap or xev to find out the keysym and all you need to do is append xK_ to it.

Now just need to figure out if I can use this with EZConfig's AdditionalKeysP as well

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .