You are not logged in.
I'm new to Xmonad. I used to use spectrwm (which I love) but it has been glitchy with a few things and I like the flexibility of Xmonad and its ability to handle exceptions, etc. better. I have, however, run into a sticky spot porting over all my keybindings. I'm not very good with Haskell (mainly because I've failed to grasp the docs -- I've only learned python and a bit of C++), and despite hours on Google I can't figure out how to create keybindings properly. I'm using the EZConfig module. Here is my (confused and botched) xmonad.hs:
import XMonad
import System.Exit
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import XMonad.Util.EZConfig
import XMonad.Util.Run
import XMonad.Actions.CycleWS
import Graphics.X11.ExtraTypes.XF86 --to be used later
-- layout
myLayout = tiled ||| Mirror tiled ||| Full
where
-- default tiling algorithm partitions the screen into two panes
tiled = Tall nmaster delta ratio
-- The default number of windows in the master pane
nmaster = 1
-- Default proportion of screen occupied by master pane
ratio = 1/2
-- Percent of screen to increment by when resizing panes
delta = 3/100
-- window rules
myManageHook = composeAll
[ className =? "MPlayer" --> doFloat
, className =? "Gimp" --> doFloat
, className =? "feh" --> doFloat
, resource =? "desktop_window" --> doIgnore ]
-- keybindings
main = do
xmonad $ defaultConfig
{
-- override settings
terminal = "urxvt"
, borderWidth = 1
, modMask = mod4Mask
-- , numlockMask = 0
, workspaces = ["1","2","3","4","5","6","7","8","9","10"]
, normalBorderColor = "#000000"
, focusedBorderColor = "#ffffff"
, focusFollowsMouse = False
, layoutHook = myLayout
, manageHook = myManageHook
-- , keys = myKeys
}
`additionalKeysP`
[ ("M-x", kill)
, ("M-m", nextWS)
, ("M-n", prevWS)
, ("M-s m", shiftToNext)
, ("M-s n", shiftToPrev)
, ("M-o", W.swapMaster)
, ("M-i", W.focusMaster)
-- scripts
, ("Print", spawn "/home/bryant/.scripts/screenshot")
, ("M-<Backspace>", spawn "/home/bryant/.scripts/screenlock")
, ("M-S-r", spawn "/home/bryant/.scripts/remind-notify")
-- applications
, ("M-<Return>", spawn "dmenu_run -p Run: -nf white -sb white -nb black -sf black -fn 'Terminus-13' -h 12")
, ("M-S-a", spawn "urxvt -e mocp")
, ("M-S-m", spawn "urxvt -e htop")
, ("M-S-n", spawn "urxvt -e newsbeuter")
, ("M-S-c", spawn "urxvt -e wyrd")
, ("M-S-2", spawn "urxvt -e mutt")
, ("M-S-e", spawn "urxvt -e vim")
, ("M-S-<Home>", spawn "urxvt -e ranger")
, ("M-S-g", spawn "gimp")
-- system actions
, ("M-s", spawn "systemctl suspend") ]I cobbled most of this together based on stuff I found across the web. Can anyone point me in the right direction here, and preferably explain the keybinding process a little clearer? Also, how can I find a list of the various functions (nextWS, etc) so I can rebind them to my spectrwm bindings?
EDIT
found a solution. I used the non-EZconfig method and after a lot of debugging, here is my config:
import XMonad
import System.Exit
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import XMonad.Util.Run
import XMonad.Actions.CycleWS
import Graphics.X11.ExtraTypes.XF86
import Graphics.X11.Xlib
import XMonad.Prompt
import XMonad.Prompt.Shell
import XMonad.Prompt.XMonad
-- layout
myLayout = tiled ||| Mirror tiled ||| Full
where
-- default tiling algorithm partitions the screen into two panes
tiled = Tall nmaster delta ratio
-- The default number of windows in the master pane
nmaster = 1
-- Default proportion of screen occupied by master pane
ratio = 1/2
-- Percent of screen to increment by when resizing panes
delta = 3/100
-- window rules
myManageHook = composeAll
[ className =? "MPlayer" --> doFloat
, className =? "Gimp" --> doFloat
, className =? "feh" --> doFloat
, resource =? "desktop_window" --> doIgnore ]
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
[ ((mod4Mask, xK_x ), kill)
, ((mod4Mask, xK_m ), nextWS)
, ((mod4Mask, xK_n ), prevWS)
, ((mod4Mask .|. mod1Mask, xK_m ), shiftToNext)
, ((mod4Mask .|. mod1Mask, xK_n ), shiftToPrev)
, ((mod4Mask, xK_o ), windows W.swapMaster)
, ((mod4Mask, xK_i ), windows W.focusMaster)
, ((0, xK_Print ), spawn "/home/bryant/.scripts/screenshot")
, ((mod4Mask, xK_BackSpace ), spawn "/home/bryant/.scripts/screenlock")
, ((mod4Mask .|. shiftMask, xK_r ), spawn "/home/bryant/.scripts/remind-notify")
, ((mod4Mask, xK_Return ), spawn "dmenu_run -p Run: -nf white -sb white -nb black -sf black -fn 'Terminus-13' -h 12")
, ((mod4Mask .|. shiftMask, xK_a ), spawn "urxvt -e mocp")
, ((mod4Mask .|. shiftMask, xK_m ), spawn "urxvt -e htop")
, ((mod4Mask .|. shiftMask, xK_n ), spawn "urxvt -e newsbeuter")
, ((mod4Mask .|. shiftMask, xK_c ), spawn "urxvt -e wyrd")
, ((mod4Mask .|. shiftMask, xK_2 ), spawn "urxvt -e mutt")
, ((mod4Mask .|. shiftMask, xK_e ), spawn "urxvt -e vim")
, ((mod4Mask .|. shiftMask, xK_Home ), spawn "urxvt -e ranger")
, ((mod4Mask .|. shiftMask, xK_g ), spawn "gimp")
, ((mod4Mask, xK_s), spawn "systemctl suspend") ]
main = do
xmonad $ defaultConfig
{
-- override settings
terminal = "urxvt"
, borderWidth = 1
, modMask = mod4Mask
, workspaces = ["1","2","3","4","5","6","7","8","9","10"]
, normalBorderColor = "#000000"
, focusedBorderColor = "#ffffff"
, focusFollowsMouse = False
, layoutHook = myLayout
, manageHook = myManageHook
, keys = myKeys
}I still have to bind my multimedia keys, but after that I should have it all set up.
My question is this: does this replace the original default keybindings, or merely override them?
Last edited by ParanoidAndroid (2013-05-08 20:06:56)
Offline