You are not logged in.

#1 2014-08-17 12:41:22

Lustique
Member
From: DE
Registered: 2013-11-15
Posts: 17

Spectrwm: Setting a key combination as the mod key

Hello everyone,
I'm thinking of converting from xMonad to Spectrwm since I don't use Haskell anymore (at least at the moment). However, I encountered a problem I cannot find a solution for on my own when I tried to port my xMonad settings to Spectrwm: For xMonad, I have my mod key set to a combination of ctrl and alt, since I use old keyboards a lot, hence no super key, and don't want to use alt as a mod key because of reasons (mainly the occasional use of emacs …).

Using "myModMask     = (mod1Mask .|. controlMask)" in xmonad.hs (you can find the whole file below), I got the intended behaviour for xMonad, but I cannot figure out how to do this in Spectrwm. I have tried to use "modkey = Mod1 + Control" and similar stuff, but nothing worked. I then tried to map ctrl + alt to super using xbindkeys and xte, but that didn't work either. Does anyone here have any idea on how to do this?

My xmonad.hs:

 
-- Imports
import XMonad
-- import XMonad.Config.Xfce
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Layout.NoBorders
import XMonad.Util.EZConfig(additionalKeys)

-- The main function
main = xmonad =<< statusBar myBar myPP toggleStrutsKey myConfig 

-- My definitions
-- myTerminal 	= "xfce4-terminal"
myTerminal 	= "urxvt"
-- myModMask 	= mod5Mask -- Mit 'xmodmap' kann überprüft werden, welche Tasten zu welchem mod#n gehören )ISO_Level3_Shift = Alt_gr
myModMask 	= (mod1Mask .|. controlMask)
myBar 		= "xmobar" 
myPP 		= xmobarPP

myWorkspaces = ["¹α","²β","³γ","⁴δ","⁵ε","⁶ζ","⁷η","⁸θ","⁹ι"]

toggleStrutsKey XConfig {XMonad.modMask = modMask} = (modMask, xK_b)

--  Colors to match zenburn theme
selected   = "'#8faa9f'"
background = "'#1f1f1f'"
foreground = "'#dcdccc'"
 
appFontXft = "Inconsolata:size=10:bold:dpi=96:hinting=true:hintstyle=hintslight:antialias=true:rgba=rgb:lcdfilter=lcdlight"

-- myDmenuTitleBar =
--     "dmenu_run\
--         \ -p 'Run:'\
--         \ -i\
--         \ -bh " ++ barHeight  ++ "\
--         \ -nb " ++ background ++ "\
--         \ -nf " ++ foreground ++ "\
--         \ -sb " ++ selected   ++ "\
--         \ -fn " ++ appFontXft ++ "\
--     \`"

myDmenuTitleBar = "dmenu_run -p 'Run:' -i " ++  " -nb " ++ background ++ " -nf " ++ foreground ++ " -sb " ++ selected   ++ " -fn " ++ appFontXft

myConfig = defaultConfig 
		{terminal 	= myTerminal 
		, modMask 	= myModMask
		, layoutHook 	= avoidStruts $ smartBorders $ layoutHook defaultConfig
		, manageHook 	= manageHook defaultConfig <+> manageDocks
		, workspaces 	= myWorkspaces
		} `additionalKeys` 
                [ ((myModMask, xK_p), spawn myDmenuTitleBar) ] 

Offline

#2 2014-08-17 13:00:45

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,545
Website

Re: Spectrwm: Setting a key combination as the mod key

Spectrwm doesn't currently seem capable of that.  it can only select one key.  The following (untested!) patch against the current git code should do what you want:

--- spectrwm.c	2014-08-17 08:55:01.992351074 -0400
+++ spectrwm.c	2014-08-17 08:58:15.207971002 -0400
@@ -8186,16 +8186,13 @@
 	(void)selector;
 	(void)flags;
 
-	if (strncasecmp(value, "Mod1", strlen("Mod1")) == 0)
-		update_modkey(XCB_MOD_MASK_1);
-	else if (strncasecmp(value, "Mod2", strlen("Mod2")) == 0)
-		update_modkey(XCB_MOD_MASK_2);
-	else if (strncasecmp(value, "Mod3", strlen("Mod3")) == 0)
-		update_modkey(XCB_MOD_MASK_3);
-	else if (strncasecmp(value, "Mod4", strlen("Mod4")) == 0)
-		update_modkey(XCB_MOD_MASK_4);
-	else
-		return (1);
+	int modmask = 0;
+	if (strcasestr(value, "Mod1")) modmask |= XCB_MOD_MASK_1;
+	if (strcasestr(value, "Mod2")) modmask |= XCB_MOD_MASK_2;
+	if (strcasestr(value, "Mod3")) modmask |= XCB_MOD_MASK_3;
+	if (strcasestr(value, "Mod4")) modmask |= XCB_MOD_MASK_4;
+	if (strcasestr(value, "Control")) modmask |= XCB_MOD_MASK_CONTROL;
+	update_modkey(modmask);
 	return (0);
 }

"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2014-08-25 17:45:17

Lustique
Member
From: DE
Registered: 2013-11-15
Posts: 17

Re: Spectrwm: Setting a key combination as the mod key

Thanks for your help! (Sorry for the wait, but I forgot to answer yikes)
Unfortunately, I have no idea on how to put this to use, because I never really compiled anything manually (at least nothing for productive use/something that's in the repo, as well). Do you think I should somehow contact a developer and point him/her to this post?

Last edited by Lustique (2014-08-25 17:46:02)

Offline

#4 2014-08-25 17:50:13

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,545
Website

Re: Spectrwm: Setting a key combination as the mod key

You could submit a request here.  If the author wanted to include this request, it would be a very easy revision for them.

But applying a patch is pretty simple (especially with an AUR PKGBUILD) and if you're up for learning just a little you can read the second half of this wiki page to use the patch posted above with the existing spectrwm-git package in the AUR.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB