Created
December 24, 2011 12:00
-
-
Save janx/1517205 to your computer and use it in GitHub Desktop.
my xmonad config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import XMonad hiding ( (|||) ) | |
| import XMonad.Actions.CopyWindow | |
| import XMonad.Actions.CycleWS | |
| import XMonad.Actions.NoBorders | |
| import XMonad.Actions.Submap | |
| import XMonad.Actions.Search | |
| import XMonad.Actions.WindowBringer (bringWindow) | |
| import XMonad.Config.Gnome | |
| import XMonad.Hooks.ManageDocks | |
| import XMonad.Hooks.ManageHelpers | |
| import XMonad.Hooks.DynamicLog | |
| import XMonad.Hooks.UrgencyHook | |
| import XMonad.Layout.LayoutCombinators | |
| import XMonad.Layout.Dishes | |
| import XMonad.Layout.Grid | |
| import XMonad.Layout.IM | |
| import XMonad.Layout.NoBorders | |
| import XMonad.Layout.PerWorkspace | |
| import XMonad.Layout.SimpleFloat | |
| import XMonad.Layout.ThreeColumns | |
| import XMonad.Prompt | |
| import XMonad.Prompt.AppLauncher as AL | |
| import XMonad.Prompt.AppendFile | |
| import XMonad.Prompt.Input | |
| import XMonad.Prompt.Man | |
| import XMonad.Prompt.Shell | |
| import XMonad.Prompt.Ssh | |
| import XMonad.Prompt.Theme | |
| import XMonad.Prompt.Window | |
| import XMonad.Prompt.Workspace | |
| import XMonad.Prompt.XMonad | |
| import XMonad.Util.Run (spawnPipe) | |
| import XMonad.Util.EZConfig | |
| import Control.Monad | |
| import Control.Concurrent | |
| import Control.OldException | |
| import DBus | |
| import DBus.Connection | |
| import DBus.Message | |
| import Data.Ratio ((%)) | |
| import System.IO | |
| import System.Exit | |
| import System.Environment | |
| import System.Cmd | |
| import Text.Printf | |
| import qualified XMonad.StackSet as W | |
| import qualified Data.Map as M | |
| myWorkspaces = map show $ concat [[1..9], [0]] | |
| -- myWorkspaces = map (\(x,y) -> x++":"++y) $ zip (map show [1..7]) ["work", "code", "pig", "cow", "doc", "chat", "daemon"] -- ++ map show [7..9] | |
| searchEngineMap method = M.fromList $ | |
| [ ((0, xK_g), method google) | |
| , ((0, xK_h), method hoogle) | |
| , ((0, xK_w), method wikipedia) | |
| , ((0, xK_d), method dictionary) | |
| , ((0, xK_a), method amazon) | |
| ] | |
| myXPConfig = | |
| XPC { font = "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*" | |
| , bgColor = "#000000" | |
| , fgColor = "#DDDDDD" | |
| , fgHLight = "#FFFFFF" | |
| , bgHLight = "#333333" | |
| , borderColor = "#FFFFFF" | |
| , promptBorderWidth = 0 | |
| , position = Bottom | |
| , height = 16 | |
| , historySize = 256 | |
| , defaultText = "" | |
| , autoComplete = Nothing | |
| , historyFilter = id | |
| , showCompletionOnTab = False | |
| , promptKeymap = defaultXPKeymap | |
| , completionKey = xK_Tab | |
| } | |
| ------------------------------------------------------------------------ | |
| -- Key bindings. Add, modify or remove key bindings here. | |
| -- | |
| myKeys bins = \conf@(XConfig {XMonad.modMask = modMask}) -> M.fromList $ | |
| [ ((modMask, xK_Return), spawn $ XMonad.terminal conf) | |
| , ((modMask .|. shiftMask, xK_Return), spawn "urxvt -e screen -D -RR") | |
| , ((modMask .|. shiftMask, xK_p), shellPrompt myXPConfig ) | |
| , ((modMask, xK_p), shellPrompt myXPConfig ) | |
| -- , ((modMask, xK_p), spawn "gnome-do" ) | |
| {-, ((modMask .|. shiftMask, xK_p), inputPromptWithCompl myXPConfig "run in terminal" (mkComplFunFromList bins) ?+ \s -> spawn ("urxvt -e " ++ s) )-} | |
| , ((modMask, xK_d), inputPrompt myXPConfig "send to clipboard" ?+ \s -> spawn ("/home/jan/scripts/args2clipboard.sh " ++ s)) | |
| , ((modMask .|. shiftMask, xK_d), inputPrompt myXPConfig "find password" ?+ \s -> spawn ("/home/jan/scripts/password2clipboard " ++ s)) | |
| , ((modMask, xK_o), AL.launchApp myXPConfig "xdg-open" ) | |
| , ((modMask, xK_m), spawn "urxvt -e mc" ) | |
| , ((modMask .|. shiftMask, xK_m), spawn "nautilus ~" ) | |
| , ((modMask, xK_t), spawn "urxvt -e vim /home/jan/documents/jan.org") | |
| , ((modMask .|. shiftMask, xK_t), appendFilePrompt myXPConfig "/home/jan/documents/jan.org") | |
| , ((modMask, xK_slash), manPrompt myXPConfig) | |
| , ((modMask, xK_c), themePrompt myXPConfig) | |
| , ((modMask, xK_quoteleft), workspacePrompt myXPConfig (windows . W.greedyView) ) | |
| , ((modMask .|. shiftMask, xK_quoteleft), workspacePrompt myXPConfig (windows . W.shift) ) | |
| , ((modMask, xK_quoteright), sshPrompt myXPConfig) | |
| , ((modMask, xK_a), xmonadPrompt myXPConfig) | |
| , ((modMask, xK_v), windows copyToAll) | |
| , ((modMask .|. shiftMask, xK_v), killAllOtherCopies) | |
| , ((modMask .|. shiftMask, xK_c ), kill1) | |
| , ((modMask .|. shiftMask .|. mod1Mask, xK_c ), kill) | |
| -- , ((modMask, xK_BackSpace), focusUrgent) | |
| , ((modMask, xK_space ), sendMessage NextLayout) | |
| , ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf) | |
| , ((modMask, xK_BackSpace), inputPromptWithCompl myXPConfig "Jump to layout" (mkComplFunFromList ["Tall", "Mirror Tall", "Grid", "Full"]) ?+ (\s -> sendMessage $ JumpToLayout s) ) | |
| , ((modMask, xK_f ), sendMessage $ JumpToLayout "Full" ) | |
| , ((modMask, xK_n ), refresh) | |
| , ((modMask, xK_Tab ), toggleWS) | |
| , ((modMask, xK_g ), windowPromptGoto myXPConfig) | |
| , ((modMask .|. shiftMask, xK_g ), windowPromptBring myXPConfig) | |
| , ((modMask, xK_j ), windows W.focusDown) | |
| , ((modMask .|. shiftMask, xK_j ), windows W.swapDown ) | |
| , ((modMask, xK_k ), windows W.focusUp ) | |
| , ((modMask .|. shiftMask, xK_k ), windows W.swapUp ) | |
| , ((modMask, xK_semicolon), windows W.focusMaster ) | |
| , ((modMask, xK_h ), sendMessage Shrink) | |
| , ((modMask, xK_l ), sendMessage Expand) | |
| -- , ((modMask, xK_s ), submap $ searchEngineMap $ promptSearch myXPConfig) | |
| , ((modMask, xK_s ), spawn "tracker-search-tool" ) | |
| , ((modMask .|. shiftMask, xK_s ), withFocused $ windows . W.sink) | |
| -- Increment the number of windows in the master area | |
| , ((modMask , xK_equal ), sendMessage (IncMasterN 1)) | |
| , ((modMask , xK_period ), nextWS) | |
| , ((modMask .|. shiftMask, xK_period ), shiftToNext) | |
| , ((modMask , xK_Right ), nextScreen) | |
| , ((modMask .|. shiftMask, xK_Right ), shiftNextScreen) | |
| -- Deincrement the number of windows in the master area | |
| , ((modMask , xK_minus), sendMessage (IncMasterN (-1))) | |
| , ((modMask , xK_comma),prevWS) | |
| , ((modMask .|. shiftMask, xK_comma),shiftToPrev) | |
| , ((modMask , xK_Left), prevScreen) | |
| , ((modMask .|. shiftMask, xK_Left), shiftPrevScreen) | |
| , ((modMask , xK_b ), withFocused toggleBorder) | |
| , ((modMask .|. shiftMask, xK_b ), sendMessage ToggleStruts) | |
| , ((modMask .|. shiftMask, xK_q ), spawn "gnome-session-quit") | |
| , ((modMask , xK_q ), restart "xmonad" True) | |
| , ((modMask .|. shiftMask, xK_l ), spawn "gnome-screensaver-command -l") | |
| ] | |
| ++ | |
| -- | |
| -- mod-[1..9], Switch to workspace N | |
| -- mod-shift-[1..9], Move client to workspace N | |
| -- mod-left alt-shift-[1..9], Copy to workspace N | |
| -- | |
| [((m .|. modMask, k), windows $ f i) | |
| | (i, k) <- zip (XMonad.workspaces conf) $ concat [[xK_1 .. xK_9], [xK_0]] | |
| , (f, m) <- [(W.view, 0), (W.shift, shiftMask), (copy, shiftMask .|. mod1Mask)]] | |
| ++ | |
| -- | |
| -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3 | |
| -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3 | |
| -- | |
| [((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f)) | |
| | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..] | |
| , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]] | |
| ------------------------------------------------------------------------ | |
| -- Mouse bindings: default actions bound to mouse events | |
| -- | |
| myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $ | |
| -- mod-button1, Set the window to floating mode and move by dragging | |
| [ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w | |
| >> windows W.shiftMaster)) | |
| -- mod-button2, Raise the window to the top of the stack | |
| , ((modMask, button2), (\w -> focus w >> windows W.shiftMaster)) | |
| -- mod-button3, Set the window to floating mode and resize by dragging | |
| , ((modMask, button3), (\w -> focus w >> mouseResizeWindow w | |
| >> windows W.shiftMaster)) | |
| -- you may also bind events to the mouse scroll wheel (button4 and button5) | |
| ] | |
| ------------------------------------------------------------------------ | |
| -- Layouts: | |
| -- You can specify and transform your layouts by modifying these values. | |
| -- If you change layout bindings be sure to use 'mod-shift-space' after | |
| -- restarting (with 'mod-q') to reset your layout state to the new | |
| -- defaults, as xmonad preserves your old layout settings by default. | |
| -- | |
| -- The available layouts. Note that each layout is separated by |||, | |
| -- which denotes layout choice. | |
| -- | |
| myLayout = avoidStruts | |
| $ onWorkspace "9" simpleFloat | |
| $ onWorkspace "0" (noBorders Full) | |
| $ smartBorders (average ||| Mirror average ||| tiled ||| Mirror tiled ||| Grid ||| ThreeCol 1 (3/100) (1/2) ||| Dishes 2 (1/6) ||| noBorders Full) | |
| where | |
| rosters = skypeRoster `Or` pidginRoster | |
| pidginRoster = (ClassName "Pidgin") `And` (Role "buddy_list") | |
| skypeRoster = (ClassName "Skype") `And` (Title "binaryxie - Skype™ (Beta)") | |
| average = Tall 1 (3/100) (1/2) | |
| tiled = Tall nmaster delta ratio -- default tiling algorithm partitions the screen into two panes | |
| nmaster = 1 -- The default number of windows in the master pane | |
| ratio = 2/3 -- Default proportion of screen occupied by master pane | |
| delta = 3/100 -- Percent of screen to increment by when resizing panes | |
| ------------------------------------------------------------------------ | |
| -- Window rules: | |
| -- Execute arbitrary actions and WindowSet manipulations when managing | |
| -- a new window. You can use this to, for example, always float a | |
| -- particular program, or have a client always appear on a particular | |
| -- workspace. | |
| -- | |
| -- To find the property name associated with a program, use | |
| -- > xprop | grep WM_CLASS | |
| -- and click on the client you're interested in. | |
| -- | |
| -- To match on the WM_NAME, you can use 'title' in the same way that | |
| -- 'className' and 'resource' are used below. | |
| -- | |
| myManageHook = composeAll | |
| [ className =? "MPlayer" --> doFloat | |
| , className =? "Umplayer" --> doFloat | |
| , className =? "Artha" --> doFloat | |
| , className =? "Zenity" --> doFloat | |
| , className =? "Pino" --> doFloat | |
| , className =? "Hotot" --> doFloat | |
| , className =? "Catfish.pyc" --> doFloat | |
| , className =? "Pinot" --> doFloat | |
| , className =? "Pinot-prefs" --> doFloat | |
| , className =? "Tracker-preferences" --> doFloat | |
| , className =? "Tracker-search-tool" --> doFloat | |
| , className =? "net-sourceforge-jnlp-runtime-Boot" --> doFloat | |
| , className =? "Sonata" --> doFloat | |
| , className =? "Gimp-2.6" --> doFloat | |
| , className =? "Gimp" --> doFloat | |
| , className =? "Wicd-client.py" --> doFloat | |
| , className =? "Nm-connection-editor" --> doFloat | |
| , className =? "Dia" --> doFloat | |
| , className =? "Shutter" --> doFloat | |
| , className =? "Stardict" --> doFloat | |
| , className =? "Battstat-applet-2" --> doFloat | |
| , className =? "Swiftweasel" --> doShift "1" | |
| , className =? "Chromium" --> doShift "1" | |
| , title =? "Chromium Preferences" --> doFloat | |
| , title =? "Search Engines" <&&> className =? "Chromium" --> doFloat | |
| , title =? "Add to Panel" <&&> className =? "Gnome-panel" --> doFloat | |
| , className =? "Gran Paradiso" --> doShift "1" | |
| , className =? "Namoroka" --> doShift "1" | |
| , className =? "Shiretoko" --> doShift "1" | |
| , className =? "Pidgin" --> doShift "9" | |
| , className =? "Skype" --> doShift "9" | |
| , className =? "Xchat" --> doShift "9" | |
| , className =? "Qterm" --> doShift "0" | |
| , className =? "Fqterm.bin" --> doShift "0" | |
| , className =? "stalonetray" --> doIgnore | |
| , className =? "Do" --> doIgnore | |
| , resource =? "desktop_window" --> doIgnore | |
| , resource =? "kdesktop" --> doIgnore | |
| , isFullscreen --> doFullFloat | |
| , manageDocks ] | |
| prettyPrinter :: Connection -> PP | |
| prettyPrinter dbus = defaultPP | |
| { ppOutput = dbusOutput dbus | |
| , ppTitle = pangoColor "white" . pangoSanitize | |
| , ppCurrent = pangoColor "green" . wrap "[" "]" . pangoSanitize | |
| , ppVisible = pangoColor "green" . pangoSanitize | |
| , ppHidden = pangoSanitize | |
| , ppUrgent = pangoColor "red" | |
| , ppLayout = pangoColor "white" . pangoSanitize | |
| , ppSep = " | " | |
| } | |
| getWellKnownName :: Connection -> IO () | |
| getWellKnownName dbus = tryGetName `catchDyn` (\(DBus.Error _ _) -> getWellKnownName dbus) | |
| where | |
| tryGetName = do | |
| namereq <- newMethodCall serviceDBus pathDBus interfaceDBus "RequestName" | |
| addArgs namereq [String "org.xmonad.Log", Word32 5] | |
| sendWithReplyAndBlock dbus namereq 0 | |
| return () | |
| dbusOutput :: Connection -> String -> IO () | |
| dbusOutput dbus str = do | |
| msg <- newSignal "/org/xmonad/Log" "org.xmonad.Log" "Update" | |
| addArgs msg [String ("<b>" ++ str ++ "</b>")] | |
| -- If the send fails, ignore it. | |
| send dbus msg 0 `catchDyn` (\(DBus.Error _ _) -> return 0) | |
| return () | |
| pangoColor :: String -> String -> String | |
| pangoColor fg = wrap left right | |
| where | |
| left = "<span foreground=\"" ++ fg ++ "\">" | |
| right = "</span>" | |
| pangoSanitize :: String -> String | |
| pangoSanitize = foldr sanitize "" | |
| where | |
| sanitize '>' xs = ">" ++ xs | |
| sanitize '<' xs = "<" ++ xs | |
| sanitize '\"' xs = """ ++ xs | |
| sanitize '&' xs = "&" ++ xs | |
| sanitize x xs = x:xs | |
| ------------------------------------------------------------------------ | |
| -- Now run xmonad with all the defaults we set up. | |
| -- Run xmonad with the settings you specify. No need to modify this. | |
| -- | |
| main = withConnection Session $ \dbus -> do | |
| getWellKnownName dbus | |
| bins <- getCommands | |
| xmonad $ gnomeConfig | |
| { -- simple stuff | |
| terminal = "urxvt" | |
| , modMask = mod4Mask | |
| , focusFollowsMouse = True | |
| , borderWidth = 1 | |
| , workspaces = myWorkspaces | |
| , normalBorderColor = "#333333" | |
| , focusedBorderColor = "#4c7899" | |
| -- key bindings | |
| , keys = myKeys bins | |
| , mouseBindings = myMouseBindings | |
| -- hooks, layouts | |
| , layoutHook = myLayout | |
| , manageHook = myManageHook | |
| , logHook = dynamicLogWithPP (prettyPrinter dbus) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment