finished xmonad.hs
This commit is contained in:
parent
3b45fcbba2
commit
2b4f1ab84c
1 changed files with 80 additions and 81 deletions
|
|
@ -15,11 +15,17 @@ import System.Exit
|
||||||
import XMonad.Layout.NoBorders (noBorders, smartBorders)
|
import XMonad.Layout.NoBorders (noBorders, smartBorders)
|
||||||
import XMonad.Layout.ResizableTile
|
import XMonad.Layout.ResizableTile
|
||||||
import XMonad.Layout.SimplestFloat
|
import XMonad.Layout.SimplestFloat
|
||||||
|
import XMonad.Actions.CopyWindow
|
||||||
|
import XMonad.Actions.DynamicWorkspaces
|
||||||
import XMonad.Actions.GridSelect
|
import XMonad.Actions.GridSelect
|
||||||
import XMonad.Actions.NoBorders
|
import XMonad.Actions.NoBorders
|
||||||
import XMonad.Actions.Warp(warpToScreen)
|
import XMonad.Actions.Warp(warpToScreen)
|
||||||
import XMonad.Actions.WindowBringer
|
import XMonad.Actions.WindowBringer
|
||||||
|
import XMonad.Prompt
|
||||||
|
import XMonad.Util.EZConfig (additionalKeysP)
|
||||||
import Data.Monoid
|
import Data.Monoid
|
||||||
|
import Data.List
|
||||||
|
import Data.Maybe
|
||||||
|
|
||||||
import qualified XMonad.StackSet as W
|
import qualified XMonad.StackSet as W
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
|
@ -28,18 +34,18 @@ import qualified Data.Map as M
|
||||||
-- certain contrib modules.
|
-- certain contrib modules.
|
||||||
--
|
--
|
||||||
-- myTerminal = "urxvt;ps -U $USER |grep dzen2|awk '{print $1}'|xargs kill -USR1"
|
-- myTerminal = "urxvt;ps -U $USER |grep dzen2|awk '{print $1}'|xargs kill -USR1"
|
||||||
myTerminal = "urxvtc"
|
mterminal = "urxvtc"
|
||||||
|
|
||||||
-- Width of the window border in pixels.
|
-- Width of the window border in pixels.
|
||||||
--
|
--
|
||||||
myBorderWidth = 1
|
mborderWidth = 1
|
||||||
|
|
||||||
-- modMask lets you specify which modkey you want to use. The default
|
-- modMask lets you specify which modkey you want to use. The default
|
||||||
-- is mod1Mask ("left alt"). You may also consider using mod3Mask
|
-- is mod1Mask ("left alt"). You may also consider using mod3Mask
|
||||||
-- ("right alt"), which does not conflict with emacs keybindings. The
|
-- ("right alt"), which does not conflict with emacs keybindings. The
|
||||||
-- "windows key" is usually mod4Mask.
|
-- "windows key" is usually mod4Mask.
|
||||||
--
|
--
|
||||||
myModMask = mod4Mask
|
mmodMask = mod4Mask
|
||||||
|
|
||||||
-- | The default number of workspaces (virtual screens) and their names.
|
-- | The default number of workspaces (virtual screens) and their names.
|
||||||
-- By default we use numeric strings, but any string may be used as a
|
-- By default we use numeric strings, but any string may be used as a
|
||||||
|
|
@ -50,52 +56,61 @@ myModMask = mod4Mask
|
||||||
--
|
--
|
||||||
-- > workspaces = ["web", "irc", "code" ] ++ map show [4..9]
|
-- > workspaces = ["web", "irc", "code" ] ++ map show [4..9]
|
||||||
--
|
--
|
||||||
myWorkspaces :: [WorkspaceId]
|
mworkspaces :: [WorkspaceId]
|
||||||
myWorkspaces = map show [1 .. 9 :: Int]
|
mworkspaces = map show [1 .. 9 :: Int]
|
||||||
|
|
||||||
-- Border colors for unfocused and focused windows, respectively.
|
-- Border colors for unfocused and focused windows, respectively.
|
||||||
--
|
--
|
||||||
myNormalBorderColor = "#999999"
|
mnormalBorderColor = "#999999"
|
||||||
myFocusedBorderColor = "#dd0000"
|
mfocusedBorderColor = "#dd0000"
|
||||||
|
|
||||||
-- Custom keys
|
-- Custom keys
|
||||||
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
|
mkeys = [ ("M-S-n", sendMessage MirrorShrink) -- Expand current window
|
||||||
myKeys =
|
, ("M-S-t", sendMessage MirrorExpand) -- Shrink current window
|
||||||
-- Window management
|
|
||||||
[ ((modMask .|. shiftMask, xK_n ), sendMessage MirrorShrink) -- %! Expand current window
|
|
||||||
, ((modMask .|. shiftMask, xK_t ), sendMessage MirrorExpand) -- %! Shrink current window
|
|
||||||
|
|
||||||
-- Bring dzen to the front
|
-- Bring dzen to the front
|
||||||
, ("M-S-b", spawn "ps -U hunner|grep dzen2|awk '{print $1}'|xargs kill -USR1")
|
, ("M-S-b", spawn "ps -U hunner|grep dzen2|awk '{print $1}'|xargs kill -USR1")
|
||||||
|
|
||||||
-- Toggle the border of the currently focused window
|
-- Toggle the border of the currently focused window
|
||||||
, ((modMask , xK_b ), withFocused toggleBorder)
|
, ("M-b" , withFocused toggleBorder)
|
||||||
|
|
||||||
-- Gridselect to pick windows
|
-- Gridselect to pick windows
|
||||||
--, ((modMask , xK_g ), goToSelected defaultGSConfig)
|
--, ((modMask , xK_g ), goToSelected defaultGSConfig)
|
||||||
--, ((modMask , xK_g ), goToSelected gsconfig3)
|
--, ((modMask , xK_g ), goToSelected gsconfig3)
|
||||||
, ((modMask , xK_a ), warpToCentre >> wsgrid)
|
--, ("M-g" , warpToCentre >> wsgrid)
|
||||||
|
--, ("M-g" , wsgrid)
|
||||||
|
, ("M-g" , warpToCentre >> promptedWs)
|
||||||
|
|
||||||
-- Goes to window or bring up window
|
-- Goes to window or bring up window
|
||||||
, ((modMask .|. shiftMask, xK_g ), gotoMenu)
|
, ("M-S-g", gotoMenu)
|
||||||
, ((modMask .|. shiftMask, xK_b ), bringMenu)
|
, ("M-S-b", bringMenu)
|
||||||
]
|
|
||||||
++
|
-- Multimedia
|
||||||
-- mod-[1..9] %! Switch to workspace N
|
, ("<XF86AudioPlay>" , spawn "mpc toggle" ) -- play/pause mpd
|
||||||
-- mod-shift-[1..9] %! Move client to workspace N
|
, ("<XF86AudioStop>" , spawn "mpc stop" ) -- stop mpd
|
||||||
[((m .|. modMask, k), windows $ f i)
|
, ("<XF86AudioPrev>" , spawn "mpc prev" ) -- prev song
|
||||||
| (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
|
, ("<XF86AudioNext>" , spawn "mpc next" ) -- next song
|
||||||
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
|
, ("<XF86AudioMute>" , spawn "amixer -q -- sset Headphone togglemute") -- toggle mute via custom script
|
||||||
++
|
, ("<XF86AudioLowerVolume>", spawn "mpc volume -3" ) -- volume down via custom script
|
||||||
-- mod-{w,e,r} %! Switch to physical/Xinerama screens 1, 2, or 3
|
, ("<XF86AudioRaiseVolume>", spawn "mpc volume +3" ) -- volume up via custom script
|
||||||
-- mod-shift-{w,e,r} %! Move client to screen 1, 2, or 3
|
, ("M-S-<Backspace>" , removeWorkspace)
|
||||||
[((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
|
|
||||||
| (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
|
-- Dynamic workspace commands
|
||||||
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
|
, ("M-S-w" , selectWorkspace myXPConfig)
|
||||||
|
, ("M-m" , withWorkspace myXPConfig (windows . W.shift))
|
||||||
|
, ("M-S-m" , withWorkspace myXPConfig (windows . copy))
|
||||||
|
, ("M-S-r" , renameWorkspace myXPConfig)
|
||||||
|
]
|
||||||
|
-- Don't auto-assign the key shortcuts
|
||||||
|
-- ++
|
||||||
|
-- zip (map (("M-" ++) . show) [1..9]) (map (withNthWorkspace W.greedyView) [0..])
|
||||||
|
-- ++
|
||||||
|
-- zip (map (("M-S-" ++) . show) [1..9]) (map (withNthWorkspace W.shift) [0..])
|
||||||
|
|
||||||
|
warpToCentre = gets (W.screen . W.current . windowset) >>= \x -> warpToScreen x 0.5 0.5
|
||||||
|
|
||||||
{-
|
{-
|
||||||
[10:28] dschoepe : gets (map W.tag . W.workspaces . windowset) should work
|
[10:28] dschoepe : gets (map W.tag . W.workspaces . windowset) should work
|
||||||
[10:28] aavogt : dschoepe: yeah
|
|
||||||
[10:31] aavogt : somewhat useful variation on that is:
|
[10:31] aavogt : somewhat useful variation on that is:
|
||||||
[10:32] aavogt : gets $ map W.tag . uncurry (++) . partition (isJust . W.stack) . W.workspaces . windowset
|
[10:32] aavogt : gets $ map W.tag . uncurry (++) . partition (isJust . W.stack) . W.workspaces . windowset
|
||||||
[10:32] aavogt : to put the populated ones towards the inside
|
[10:32] aavogt : to put the populated ones towards the inside
|
||||||
|
|
@ -103,30 +118,12 @@ myKeys =
|
||||||
[10:34] aavogt : needs imports of Data.List and Data.Maybe
|
[10:34] aavogt : needs imports of Data.List and Data.Maybe
|
||||||
-}
|
-}
|
||||||
|
|
||||||
warpToCentre = gets (W.screen . map W.tag . W.workspaces . windowset) >>= \x -> warpToScreen x 0.5 0.5
|
--wsgrid = gridselect gsConfig =<< gets (map (\x -> (x,x)) . (map W.tag . uncurry (++) . partition (isJust . W.stack) . W.workspaces . windowset)) -- (map W.tag . W.workspaces . windowset))
|
||||||
|
wsgrid = gridselect gsConfig =<< gets (map (\x -> (x,x)) . (map W.tag . W.workspaces . windowset))
|
||||||
wsgrid = gridselect gsConfig =<< asks (map (\x -> (x,x)) . workspaces . config)
|
promptedWs = wsgrid >>= \x -> whenJust x $ \y -> windows $ W.greedyView y
|
||||||
--promptedGoto = wsgrid >>= flip whenJust (switchTopic myTopicConfig)
|
|
||||||
--promptedShift = wsgrid >>= \x -> whenJust x $ \y -> windows (W.greedyView y . W.shift y)
|
|
||||||
|
|
||||||
{-
|
|
||||||
-- | Like `gridSelect' but with the current windows and their titles as elements
|
|
||||||
gridselectWorkspace :: GSConfig W.Workspace -> X (Maybe W.Workspace)
|
|
||||||
gridselectWorkspace gsconf = workspaceMap >>= gridselect gsconf
|
|
||||||
|
|
||||||
workspaceMap :: X [(String,W.Workspace)]
|
|
||||||
workspaceMap = do
|
|
||||||
ws <- gets workspaceset
|
|
||||||
wins <- mapM keyValuePair (W.workspaces ws)
|
|
||||||
return wins
|
|
||||||
where keyValuePair w = flip (,) w `fmap` decorateName' w
|
|
||||||
|
|
||||||
decorateName' :: W.workspace -> X String
|
|
||||||
decorateName' w = do
|
|
||||||
fmap show $ getName w
|
|
||||||
-}
|
|
||||||
|
|
||||||
{-
|
{-
|
||||||
|
- Fancy gsConfig
|
||||||
gsConfig = defaultGSConfig { gs_navigate = neiu `M.union` gs_navigate (defaultGSConfig`asTypeOf`gsConfig) }
|
gsConfig = defaultGSConfig { gs_navigate = neiu `M.union` gs_navigate (defaultGSConfig`asTypeOf`gsConfig) }
|
||||||
where neiu = M.insert (0,xK_space) (const (0,0)) $ M.map (\(x,y) (a,b) -> (x+a,y+b)) $ M.fromList
|
where neiu = M.insert (0,xK_space) (const (0,0)) $ M.map (\(x,y) (a,b) -> (x+a,y+b)) $ M.fromList
|
||||||
[((0,xK_n),(-1,0))
|
[((0,xK_n),(-1,0))
|
||||||
|
|
@ -135,6 +132,9 @@ gsConfig = defaultGSConfig { gs_navigate = neiu `M.union` gs_navigate (defaultGS
|
||||||
,((0,xK_u),(0,-1))]
|
,((0,xK_u),(0,-1))]
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
myXPConfig :: XPConfig
|
||||||
|
myXPConfig = defaultXPConfig { fgColor = "#dd0000", bgColor = "black", borderColor = "#dd0000" }
|
||||||
|
|
||||||
gsConfig = defaultGSConfig
|
gsConfig = defaultGSConfig
|
||||||
{ gs_navigate = M.unions
|
{ gs_navigate = M.unions
|
||||||
[reset
|
[reset
|
||||||
|
|
@ -152,10 +152,11 @@ gsConfig = defaultGSConfig
|
||||||
]
|
]
|
||||||
-- jump back to the center with the spacebar, regardless of the current position.
|
-- jump back to the center with the spacebar, regardless of the current position.
|
||||||
reset = M.singleton (0,xK_space) (const (0,0))
|
reset = M.singleton (0,xK_space) (const (0,0))
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
-- Mouse bindings: default actions bound to mouse events
|
-- Mouse bindings: default actions bound to mouse events
|
||||||
--
|
--
|
||||||
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
|
mmouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
|
||||||
|
|
||||||
-- mod-button1, Set the window to floating mode and move by dragging
|
-- mod-button1, Set the window to floating mode and move by dragging
|
||||||
[ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w))
|
[ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w))
|
||||||
|
|
@ -180,7 +181,7 @@ myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
|
||||||
-- The available layouts. Note that each layout is separated by |||,
|
-- The available layouts. Note that each layout is separated by |||,
|
||||||
-- which denotes layout choice.
|
-- which denotes layout choice.
|
||||||
--
|
--
|
||||||
myLayout = smartBorders Full ||| tiled ||| Mirror tiled ||| simplestFloat
|
mlayout = smartBorders Full ||| tiled ||| Mirror tiled ||| simplestFloat
|
||||||
where
|
where
|
||||||
-- default tiling algorithm partitions the screen into two panes
|
-- default tiling algorithm partitions the screen into two panes
|
||||||
--tiled = Tall nmaster delta ratio
|
--tiled = Tall nmaster delta ratio
|
||||||
|
|
@ -211,7 +212,7 @@ myLayout = smartBorders Full ||| tiled ||| Mirror tiled ||| simplestFloat
|
||||||
-- To match on the WM_NAME, you can use 'title' in the same way that
|
-- To match on the WM_NAME, you can use 'title' in the same way that
|
||||||
-- 'className' and 'resource' are used below.
|
-- 'className' and 'resource' are used below.
|
||||||
--
|
--
|
||||||
myManageHook = composeAll
|
mmanageHook = composeAll
|
||||||
[ className =? "MPlayer" --> doFloat
|
[ className =? "MPlayer" --> doFloat
|
||||||
, title =? "VLC media player" --> doFloat
|
, title =? "VLC media player" --> doFloat
|
||||||
, className =? "Gimp" --> doFloat
|
, className =? "Gimp" --> doFloat
|
||||||
|
|
@ -227,8 +228,8 @@ myManageHook = composeAll
|
||||||
, resource =? "kdesktop" --> doIgnore ]
|
, resource =? "kdesktop" --> doIgnore ]
|
||||||
|
|
||||||
-- Whether focus follows the mouse pointer.
|
-- Whether focus follows the mouse pointer.
|
||||||
myFocusFollowsMouse :: Bool
|
mfocusFollowsMouse :: Bool
|
||||||
myFocusFollowsMouse = True
|
mfocusFollowsMouse = True
|
||||||
|
|
||||||
{-
|
{-
|
||||||
[14:25] dschoepe : Hunner: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=8798#a8798
|
[14:25] dschoepe : Hunner: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=8798#a8798
|
||||||
|
|
@ -252,23 +253,21 @@ pickyFocusEventHook _ = return $ All True
|
||||||
|
|
||||||
-- Run xmonad!
|
-- Run xmonad!
|
||||||
--
|
--
|
||||||
main = xmonad defaults
|
main = do
|
||||||
|
xmonad $ defaultConfig
|
||||||
|
{ terminal = mterminal
|
||||||
|
, focusFollowsMouse = mfocusFollowsMouse
|
||||||
|
, borderWidth = mborderWidth
|
||||||
|
, modMask = mmodMask
|
||||||
|
, workspaces = mworkspaces
|
||||||
|
, normalBorderColor = mnormalBorderColor
|
||||||
|
, focusedBorderColor = mfocusedBorderColor
|
||||||
|
|
||||||
defaults = defaultConfig
|
-- key bindings
|
||||||
{ -- simple stuff
|
, mouseBindings = mmouseBindings
|
||||||
, terminal = myTerminal
|
|
||||||
, focusFollowsMouse = myFocusFollowsMouse
|
|
||||||
, borderWidth = myBorderWidth
|
|
||||||
, modMask = myModMask
|
|
||||||
, workspaces = myWorkspaces
|
|
||||||
, normalBorderColor = myNormalBorderColor
|
|
||||||
, focusedBorderColor = myFocusedBorderColor
|
|
||||||
|
|
||||||
, -- key bindings
|
-- hooks, layouts
|
||||||
, mouseBindings = myMouseBindings
|
, layoutHook = mlayout
|
||||||
|
, manageHook = mmanageHook
|
||||||
, -- hooks, layouts
|
|
||||||
, layoutHook = myLayout
|
|
||||||
, manageHook = myManageHook
|
|
||||||
, handleEventHook = pickyFocusEventHook
|
, handleEventHook = pickyFocusEventHook
|
||||||
} `additionalKeysP` myKeys
|
} `additionalKeysP` mkeys
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue