Xmonad/Config archive/skorpan's xmonad.hs
From HaskellWiki
(Difference between revisions)
(Updating to new configuration.) |
(Updated for 0.7.) |
||
| Line 1: | Line 1: | ||
| - | <haskell> | + | <haskell>import XMonad |
| - | + | import System.Exit | |
| - | + | import XMonad.Hooks.DynamicLog | |
| - | + | import XMonad.Hooks.ManageDocks | |
| - | + | import XMonad.Util.Run (spawnPipe) | |
| - | + | import System.IO (hPutStrLn) | |
| - | import XMonad | + | |
| - | import | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | import XMonad.Hooks.DynamicLog | + | |
| - | import XMonad.Hooks. | + | |
| - | import XMonad. | + | |
| - | import | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
import qualified XMonad.StackSet as W | import qualified XMonad.StackSet as W | ||
| - | + | import qualified Data.Map as M | |
| - | import qualified Data.Map as M | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | dmenuExec | + | dmenuExec = |
| - | + | "exe=`dmenu_path | dmenu -b -nb black -nf white -sb gray -sf black` && eval \"exec $exe\"" | |
| - | + | ||
| - | + | myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $ | |
| - | + | [ ((modMask, xK_Return), spawn $ XMonad.terminal conf) | |
| - | + | , ((modMask, xK_p ), spawn dmenuExec) | |
| - | + | , ((modMask .|. shiftMask, xK_c ), kill) | |
| - | + | , ((modMask, xK_space ), sendMessage NextLayout) | |
| - | + | , ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf) | |
| - | + | , ((modMask, xK_n ), refresh) | |
| - | + | , ((modMask, xK_Tab ), windows W.focusDown) | |
| - | + | , ((modMask, xK_j ), windows W.focusDown) | |
| - | + | , ((modMask, xK_e ), windows W.focusDown) | |
| - | + | , ((modMask, xK_Right ), windows W.focusDown) | |
| - | + | , ((modMask, xK_k ), windows W.focusUp ) | |
| - | + | , ((modMask, xK_Left ), windows W.focusUp ) | |
| - | + | , ((modMask, xK_m ), windows W.focusMaster ) | |
| - | + | , ((modMask .|. shiftMask, xK_Return), windows W.swapMaster) | |
| - | + | , ((modMask .|. shiftMask, xK_e ), windows W.swapDown ) | |
| - | + | , ((modMask .|. shiftMask, xK_j ), windows W.swapDown ) | |
| - | + | , ((modMask .|. shiftMask, xK_k ), windows W.swapUp ) | |
| - | + | , ((modMask, xK_h ), sendMessage Shrink) | |
| - | + | , ((modMask, xK_l ), sendMessage Expand) | |
| - | + | , ((modMask, xK_t ), withFocused $ windows . W.sink) | |
| - | + | , ((modMask , xK_b ), sendMessage ToggleStruts) | |
| - | + | , ((modMask .|. shiftMask, xK_q ), io (exitWith ExitSuccess)) | |
| - | + | , ((modMask , xK_q ), | |
| - | + | broadcastMessage ReleaseResources >> restart "xmonad" True) | |
| - | + | ] | |
| - | + | ++ | |
| - | + | [((m .|. modMask, k), windows $ f i) | |
| - | + | | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9] | |
| + | , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]] | ||
| - | + | myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $ | |
| - | + | [ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w)) | |
| - | + | , ((modMask, button2), (\w -> focus w >> windows W.swapMaster)) | |
| - | + | , ((modMask, button3), (\w -> focus w >> mouseResizeWindow w)) | |
| - | [ | + | |
| - | + | ||
| - | + | ||
| - | , | + | |
| - | + | ||
| - | , | + | |
] | ] | ||
| + | |||
| + | myLayout = avoidStruts (tall ||| Mirror tall ||| Full) | ||
| + | where | ||
| + | tall = Tall nmaster delta ratio | ||
| + | nmaster = 1 | ||
| + | ratio = 1/2 | ||
| + | delta = 2/100 | ||
| + | |||
| + | myManageHook = composeAll | ||
| + | [ className =? "MPlayer" --> doFloat | ||
| + | , className =? "Gimp" --> doFloat | ||
| + | , resource =? "desktop_window" --> doIgnore | ||
| + | , resource =? "kdesktop" --> doIgnore ] <+> manageDocks | ||
| + | |||
| + | myLogHook h = dynamicLogWithPP $ defaultPP { | ||
| + | ppCurrent = dzenColor "black" "white" . pad | ||
| + | , ppVisible = dzenColor "white" "#333333" . pad | ||
| + | , ppHidden = dzenColor "white" "#333333" . pad | ||
| + | , ppHiddenNoWindows = dzenColor "#777777" "#333333" . pad | ||
| + | , ppUrgent = dzenColor "red" "yellow" | ||
| + | , ppWsSep = "" | ||
| + | , ppSep = "" | ||
| + | , ppLayout = dzenColor "white" "#333333" . | ||
| + | (\ x -> fill (case x of | ||
| + | "Tall" -> icon "tall.xbm" | ||
| + | "Mirror Tall" -> icon "mtall.xbm" | ||
| + | "Full" -> icon "full.xbm" | ||
| + | _ -> pad x) 4) | ||
| + | , ppTitle = ("^fg(white) " ++) . dzenEscape | ||
| + | , ppOutput = hPutStrLn h | ||
| + | } | ||
where | where | ||
| - | + | icon h = "^i(/home/deniz/usr/share/dzen2/icons/" ++ h ++ ")" | |
| - | + | fill :: String -> Int -> String | |
| - | + | fill h i = "^p(" ++ show i ++ ")" ++ h ++ "^p(" ++ show i ++ ")" | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | -- | + | myStatusBar = "dzen2 -fn '-*-terminus-*-*-*-*-12-*-*-*-*-*-*-*' -bg '#222222' -fg '#777777' -h 16 -w 1280 -sa c -e '' -ta l" |
| - | -- | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | - | + | main = do din <- spawnPipe myStatusBar |
| - | + | xmonad $ defaultConfig { | |
| - | + | ||
| - | + | terminal = "urxvtc", | |
| - | + | focusFollowsMouse = True, | |
| - | + | borderWidth = 1, | |
| - | + | modMask = mod4Mask, | |
| + | numlockMask = mod2Mask, | ||
| + | workspaces = ["irc","web","dev","4","5","6","7","warez","music"], | ||
| + | normalBorderColor = "#000000", | ||
| + | focusedBorderColor = "#ff0000", | ||
| - | -- | + | -- key bindings |
| - | + | keys = myKeys, | |
| - | + | mouseBindings = myMouseBindings, | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| + | -- hooks, layouts | ||
| + | layoutHook = myLayout, | ||
| + | manageHook = myManageHook, | ||
| + | logHook = myLogHook din | ||
| + | } | ||
</haskell> | </haskell> | ||
Revision as of 11:34, 1 April 2008
import XMonad import System.Exit import XMonad.Hooks.DynamicLog import XMonad.Hooks.ManageDocks import XMonad.Util.Run (spawnPipe) import System.IO (hPutStrLn) import qualified XMonad.StackSet as W import qualified Data.Map as M dmenuExec = "exe=`dmenu_path | dmenu -b -nb black -nf white -sb gray -sf black` && eval \"exec $exe\"" myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $ [ ((modMask, xK_Return), spawn $ XMonad.terminal conf) , ((modMask, xK_p ), spawn dmenuExec) , ((modMask .|. shiftMask, xK_c ), kill) , ((modMask, xK_space ), sendMessage NextLayout) , ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf) , ((modMask, xK_n ), refresh) , ((modMask, xK_Tab ), windows W.focusDown) , ((modMask, xK_j ), windows W.focusDown) , ((modMask, xK_e ), windows W.focusDown) , ((modMask, xK_Right ), windows W.focusDown) , ((modMask, xK_k ), windows W.focusUp ) , ((modMask, xK_Left ), windows W.focusUp ) , ((modMask, xK_m ), windows W.focusMaster ) , ((modMask .|. shiftMask, xK_Return), windows W.swapMaster) , ((modMask .|. shiftMask, xK_e ), windows W.swapDown ) , ((modMask .|. shiftMask, xK_j ), windows W.swapDown ) , ((modMask .|. shiftMask, xK_k ), windows W.swapUp ) , ((modMask, xK_h ), sendMessage Shrink) , ((modMask, xK_l ), sendMessage Expand) , ((modMask, xK_t ), withFocused $ windows . W.sink) , ((modMask , xK_b ), sendMessage ToggleStruts) , ((modMask .|. shiftMask, xK_q ), io (exitWith ExitSuccess)) , ((modMask , xK_q ), broadcastMessage ReleaseResources >> restart "xmonad" True) ] ++ [((m .|. modMask, k), windows $ f i) | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9] , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]] myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $ [ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w)) , ((modMask, button2), (\w -> focus w >> windows W.swapMaster)) , ((modMask, button3), (\w -> focus w >> mouseResizeWindow w)) ] myLayout = avoidStruts (tall ||| Mirror tall ||| Full) where tall = Tall nmaster delta ratio nmaster = 1 ratio = 1/2 delta = 2/100 myManageHook = composeAll [ className =? "MPlayer" --> doFloat , className =? "Gimp" --> doFloat , resource =? "desktop_window" --> doIgnore , resource =? "kdesktop" --> doIgnore ] <+> manageDocks myLogHook h = dynamicLogWithPP $ defaultPP { ppCurrent = dzenColor "black" "white" . pad , ppVisible = dzenColor "white" "#333333" . pad , ppHidden = dzenColor "white" "#333333" . pad , ppHiddenNoWindows = dzenColor "#777777" "#333333" . pad , ppUrgent = dzenColor "red" "yellow" , ppWsSep = "" , ppSep = "" , ppLayout = dzenColor "white" "#333333" . (\ x -> fill (case x of "Tall" -> icon "tall.xbm" "Mirror Tall" -> icon "mtall.xbm" "Full" -> icon "full.xbm" _ -> pad x) 4) , ppTitle = ("^fg(white) " ++) . dzenEscape , ppOutput = hPutStrLn h } where icon h = "^i(/home/deniz/usr/share/dzen2/icons/" ++ h ++ ")" fill :: String -> Int -> String fill h i = "^p(" ++ show i ++ ")" ++ h ++ "^p(" ++ show i ++ ")" myStatusBar = "dzen2 -fn '-*-terminus-*-*-*-*-12-*-*-*-*-*-*-*' -bg '#222222' -fg '#777777' -h 16 -w 1280 -sa c -e '' -ta l" main = do din <- spawnPipe myStatusBar xmonad $ defaultConfig { terminal = "urxvtc", focusFollowsMouse = True, borderWidth = 1, modMask = mod4Mask, numlockMask = mod2Mask, workspaces = ["irc","web","dev","4","5","6","7","warez","music"], normalBorderColor = "#000000", focusedBorderColor = "#ff0000", -- key bindings keys = myKeys, mouseBindings = myMouseBindings, -- hooks, layouts layoutHook = myLayout, manageHook = myManageHook, logHook = myLogHook din }
