Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Imports {{{
- import XMonad
- import XMonad.Actions.CycleWS (toggleWS)
- import XMonad.Actions.UpdatePointer
- import XMonad.Hooks.DynamicLog
- import XMonad.Hooks.FadeInactive
- import XMonad.Hooks.ManageHelpers
- import XMonad.Hooks.ManageDocks
- import XMonad.Hooks.UrgencyHook
- import XMonad.Layout.IM
- import XMonad.Layout.LayoutHints (layoutHintsWithPlacement)
- import XMonad.Layout.NoBorders
- import XMonad.Layout.PerWorkspace (onWorkspace)
- import XMonad.Layout.ResizableTile
- import XMonad.Util.EZConfig (additionalKeysP)
- import XMonad.Util.Loggers (maildirNew,dzenColorL,wrapL)
- import XMonad.Util.Run (spawnPipe)
- import XMonad.Util.Scratchpad
- import XMonad.Util.WindowProperties (getProp32s)
- import XMonad.Util.WorkspaceCompare (getSortByXineramaRule)
- import Data.List
- import Data.Monoid
- import Data.Ratio
- import System.IO
- import qualified Data.Map as M
- import qualified XMonad.StackSet as W
- -- }}}
- -- Main {{{
- main = do
- d <- spawnPipe myLeftBar -- spawn the left statusbar
- spawn myRightBar -- spawn the right statusbar
- spawn "conky" -- spawn a standard conky
- -- and finally, start xmonad
- xmonad $ withUrgencyHook myUrgencyHook $ defaultConfig
- { terminal = myTerminal
- , modMask = myModMask
- , workspaces = myWorkspaces
- , borderWidth = myBorderWidth
- , normalBorderColor = myNormalBorderColor
- , focusedBorderColor = myFocusedBorderColor
- , layoutHook = myLayout
- , manageHook = myManageHook
- , logHook = myLogHook d
- } `additionalKeysP` myKeys
- -- }}}
- -- Theme {{{
- --
- -- adjust these variables, they are used throughout
- --
- myXFTFont = "xft:Verdana-8" -- see 'Status Bars' for the dzen font
- conkyFile = "~/.dzen_conkyrc" -- populates right status bar
- colorBG = "#303030" -- background
- colorFG = "#606060" -- foreground
- colorFG2 = "#909090" -- foreground w/ emphasis
- colorFG3 = "#ffffff" -- foreground w/ strong emphasis
- colorUrg = "#ffa824" -- urgent
- barHeight = 17
- monitorWidth = 1920 -- two statusbars will span this width
- leftBarWidth = 960 -- right bar will span difference
- -- }}}
- -- Options {{{
- --
- -- you should adjust the terminal
- --
- -- if you change workspace names, be sure to update them throughout
- --
- myTerminal = "urxvt"
- myWorkspaces = ["1-main","2-web","3-chat"] ++ map show [4..9]
- myNormalBorderColor = colorBG
- myFocusedBorderColor = colorFG3
- myBorderWidth = 1
- myModMask = mod4Mask
- -- }}}
- -- Layouts {{{
- myLayout = avoidStruts $ onWorkspace "2-web" webLayouts
- $ onWorkspace "3-chat" imLayout
- $ standardLayouts
- where
- standardLayouts = tiled ||| Mirror tiled ||| full
- webLayouts = full ||| tiled ||| Mirror tiled
- -- im roster on left tenth, standardLayouts in other nine tenths
- imLayout = withIM (1/10) imProp standardLayouts
- -- WMROLE = "roster" is Gajim.py's buddy list
- imProp = Role "roster"
- tiled = hinted (ResizableTall nmaster delta ratio [])
- full = hinted (noBorders Full)
- -- like hintedTile but for any layout
- hinted l = layoutHintsWithPlacement (0,0) l
- nmaster = 1
- delta = 3/100
- ratio = toRational (2/(1 + sqrt 5 :: Double)) -- golden ratio
- -- }}}
- -- ManageHook {{{
- myManageHook = (composeAll . concat $
- [ [resource =? r --> doIgnore | r <- myIgnores] -- ignore desktop
- , [className =? c --> doShift "2-web" | c <- myWebs ] -- move webs to web
- , [title =? t --> doShift "3-chat" | t <- myChatT ] -- move chats to chat
- , [className =? c --> doShift "3-chat" | (c,_) <- myIM ] -- move chats to chat
- , [className =? c <&&> role /=? r --> doFloat | (c,r) <- myIM ] -- float all ims but roster
- , [className =? c --> doCenterFloat | c <- myFloats ] -- float my floats
- , [name =? n --> doCenterFloat | n <- myNames ] -- float my names
- , [isFullscreen --> myDoFullFloat ]
- ]) <+> manageTypes <+> manageDocks <+> manageScratchPad
- where
- role = stringProperty "WM_WINDOW_ROLE"
- name = stringProperty "WM_NAME"
- -- [("ClassName","Role")]
- myIM = [("Gajim.py","roster","Pidgin","Pidgin.py")]
- -- titles
- myChatT = ["irssi","claws"]
- -- classnames
- myFloats = ["MPlayer","Zenity","VirtualBox","Xmessage","Save As...","XFontSel"]
- myWebs = ["Navigator","Shiretoko","Firefox","Uzbl","uzbl","Google-chrome", "Chromium"]
- -- resources
- myIgnores = ["desktop","desktop_window"]
- -- names
- myNames = ["gmrun","Google Chrome Options","Chromium Options"]
- -- a trick for fullscreen but stil allow focusing of other WSs
- myDoFullFloat :: ManageHook
- myDoFullFloat = doF W.focusDown <+> doFullFloat
- -- manage the scratchpad
- manageScratchPad :: ManageHook
- manageScratchPad = scratchpadManageHook (W.RationalRect l t w h)
- where
- -- bottom 10% of the monitor
- h = 0.1
- w = 1
- t = 1 - h
- l = 1 - w
- -- modified version of manageDocks
- manageTypes :: ManageHook
- manageTypes = checkType --> doCenterFloat
- checkType :: Query Bool
- checkType = ask >>= \w -> liftX $ do
- m <- getAtom "_NET_WM_WINDOW_TYPE_MENU"
- d <- getAtom "_NET_WM_WINDOW_TYPE_DIALOG"
- u <- getAtom "_NET_WM_WINDOW_TYPE_UTILITY"
- mbr <- getProp32s "_NET_WM_WINDOW_TYPE" w
- case mbr of
- Just [r] -> return $ elem (fromIntegral r) [m,d,u]
- _ -> return False
- -- }}}
- -- Status Bars {{{
- --
- -- build two dzen2 bars
- --
- -- for non xft use something like this instead:
- --
- -- myDzenFont = "-*-terminus-medium-*-*-*-12-*-*-*-*-*-*-*"
- --
- myDzenFont :: String
- myDzenFont = drop 4 myXFTFont -- strip the 'xft:' part
- makeDzen :: Int -> Int -> Int -> Int -> String -> String
- makeDzen x y w h a = "dzen2 -p" ++
- " -ta " ++ a ++
- " -x " ++ show x ++
- " -y " ++ show y ++
- " -w " ++ show w ++
- " -h " ++ show h ++
- " -fn '" ++ myDzenFont ++ "'" ++
- " -fg '" ++ colorFG ++ "'" ++
- " -bg '" ++ colorBG ++ "' -e 'onstart=lower'"
- -- define the bars
- myLeftBar = makeDzen 0 0 leftBarWidth barHeight "l"
- myRightBar = "conky -c " ++ conkyFile ++ " | " ++ makeDzen leftBarWidth 0 (monitorWidth - leftBarWidth) barHeight "r"
- -- }}}
- -- LogHook {{{
- myLogHook :: Handle -> X ()
- myLogHook h = (dynamicLogWithPP $ defaultPP
- { ppCurrent = dzenColor colorBG colorFG2 . pad
- , ppVisible = dzenColor colorBG colorFG2 . pad
- , ppUrgent = dzenColor colorBG colorUrg . dzenStrip . pad
- , ppLayout = dzenFG colorFG2 . myRename
- , ppHidden = dzenFG colorFG2 . noScratchPad
- , ppTitle = shorten 100
- , ppHiddenNoWindows = namedOnly
- , ppSort = getSortByXineramaRule
- , ppExtras = [myAllMail, myInMail]
- , ppSep = " "
- , ppWsSep = ""
- , ppOutput = hPutStrLn h
- }) >> updatePointer (Relative 0.95 0.95)
- where
- -- thanks byorgey (this filters out NSP too)
- namedOnly ws = if any (`elem` ws) ['a'..'z'] then pad ws else ""
- -- my own filter out scratchpad function
- noScratchPad ws = if ws == "NSP" then "" else pad ws
- -- L needed for loggers
- dzenFG c = dzenColor c ""
- dzenFGL c = dzenColorL c ""
- myAllMail = wrapL " Mail: " "" . dzenFGL colorFG2 $ maildirNew myArchive
- myInMail = wrapL "[" "]" . dzenFGL colorFG2 $ maildirNew myInbox
- myArchive = "/home/patrick/Mail/GMail/archive" -- All Mail
- myInbox = "/home/patrick/Mail/GMail/INBOX" -- Inbox
- myRename = (\x -> case x of
- "Hinted ResizableTall" -> " / /-/ "
- "Mirror Hinted ResizableTall" -> " /-,-/ "
- "Hinted Tabbed Bottom Simplest" -> " /.../ "
- "Hinted TwoPane" -> " / / / "
- "Hinted Full" -> " / / "
- _ -> " " ++ x ++ " "
- ) . stripIM
- stripIM s = if "IM " `isPrefixOf` s then drop (length "IM ") s else s
- -- }}}
- -- My SpawnHook {{{
- --
- -- spawn an arbitrary command on urgent
- --
- data MySpawnHook = MySpawnHook String deriving (Read, Show)
- instance UrgencyHook MySpawnHook where
- urgencyHook (MySpawnHook s) w = spawn $ s
- -- 'ding!' on urgent (gajim has fairly unnannoying sounds thankfully)
- myUrgencyHook = MySpawnHook "ossplay -q /usr/share/sounds/purple/receive.wav"
- -- }}}
- -- Key Bindings {{{
- --
- -- only those which override/change defaults
- --
- -- custom scripts at http://pbrisbin.com:8080/pages/scripts.html
- --
- myKeys = [
- -- opening apps with Win
- ("M1-t" , scratchPad ) -- Spawn scratch pad terminal
- , ("M1-m" , spawn myMail ) -- Open mail client
- , ("M1-b" , spawn myBrowser ) -- Open web client
- , ("M1-i" , spawn myIRC ) -- Open/attach IRC client in screen
- , ("M1-l" , spawn myLock ) -- Alt-l to lock screen
- , ("M1-r" , spawn myTorrents ) -- Open/attach rtorrent in screen
- -- extended workspace navigations
- , ("M-`" , toggleWS ) -- Switch to the most recently vewed ws
- , ("M-<Backspace>" , focusUrgent ) -- Focus most recently urgent window
- , ("M-S-<Backspace>" , clearUrgents ) -- Make urgents go away
- -- extended window movements
- , ("M-o" , sendMessage MirrorShrink) -- Shink slave panes vertically
- , ("M-i" , sendMessage MirrorExpand) -- Expand slave panes vertically
- -- custom restart/quit commands
- , ("M-q" , spawn myRestart ) -- Restart xmonad
- ]
- where
- -- use myTerminal as the scratchPad terminal
- scratchPad = scratchpadSpawnActionTerminal myTerminal
- -- my apps
- myMail = "claws"
- myBrowser = "firefox"
- myLock = "slock"
- -- see http://pbrisbin.com:8080/pages/screen_tricks.html
- myIRC = myScreen "irssi"
- myTorrents = myScreen "rtorrent"
- myScreen s = myTerminal ++ " -title " ++ s
- ++ " -e bash -cl \"SCREEN_CONF=" ++ s
- ++ " screen -S " ++ s
- ++ " -R -D " ++ s
- ++ "\""
- -- see http://pbrisbin.com:8080 recent post 9
- mPlay s = "echo " ++ s ++ " > $HOME/.mplayer_fifo"
- -- kill all conky/dzen2 before executing default restart command
- myRestart = "for pid in `pgrep conky`; do kill -9 $pid; done && " ++
- "for pid in `pgrep dzen2`; do kill -9 $pid; done && " ++
- "xmonad --recompile && xmonad --restart"
- -- }}}
- -- vim:foldmethod=marker
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement