import XMonad import Data.Monoid import System.Exit import Text.Regex.Posix ((=~)) import qualified XMonad.StackSet as W import XMonad.Actions.CycleWindows import qualified Data.Map as M import XMonad.Util.Scratchpad (scratchpadSpawnAction, scratchpadManageHook, scratchpadFilterOutWorkspace) import XMonad.Hooks.UrgencyHook import XMonad.Layout.NoBorders import XMonad.Util.Run (hPutStrLn, spawnPipe, runInTerm) import XMonad.Prompt import XMonad.Prompt.Shell import XMonad.Prompt.Theme import XMonad.Layout.SimpleFloat import XMonad.Layout.Grid import XMonad.Layout.Named import qualified XMonad.Layout.Magnifier as Mag import XMonad.Layout.LayoutHints import XMonad.Layout.PerWorkspace (onWorkspace) import XMonad.Layout.Spacing import XMonad.Layout.IM import XMonad.Layout.WindowNavigation import XMonad.Layout.Reflect import Data.Ratio ((%)) import XMonad.Actions.Search import XMonad.Util.NamedScratchpad import qualified XMonad.Prompt as P import qualified XMonad.Actions.Submap as SM import qualified XMonad.Actions.Search as S import XMonad.Hooks.DynamicLog import XMonad.Hooks.ManageDocks import XMonad.Actions.UpdatePointer import XMonad.Util.WorkspaceCompare q ~? x = fmap (=~ x) q myTerminal = "urxvtc" myFocusFollowsMouse = True myBorderWidth = 1 myModMask = mod4Mask myWorkspaces = ["1","2","3","4","5"] ++ map show [6..9] myNormalBorderColor = "#3f3f3f" myFocusedBorderColor = "#f0dfaf" myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $ [ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf) , ((modm, xK_p ), spawn "/home/paul/scripts/launcher") , ((modm, xK_d ), spawn "/home/paul/scripts/todo1") , ((modm .|. shiftMask, xK_d ), spawn "/home/paul/scripts/delete-prompt-history.sh") , ((modm, xK_c ), spawn "chromium") , ((modm, xK_f ), spawn "firefox") , ((modm, xK_t ), spawn "thunar") , ((modm, xK_v ), spawn "vlc") , ((modm, xK_r ), spawn "urxvtc -e ranger") , ((modm, xK_m ), spawn "urxvtc -e mc -S nicedark") , ((modm, xK_q ), spawn "obshutdown") , ((modm .|. shiftMask, xK_n ), spawn "mpd && urxvtc -e ncmpcpp") , ((modm .|. shiftMask, xK_s ), scratchpadSpawnAction defaultConfig { terminal = myTerminal }) , ((modm, xK_s ), SM.submap $ searchEngineMap $ S.promptSearchBrowser paulXPConfig "chromium") , ((modm, xK_a ), shellPrompt paulXPConfig) , ((modm .|. shiftMask, xK_c ), kill) , ((modm, xK_Return), spawn myTerminal) , ((modm, xK_space ), sendMessage NextLayout) , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf) , ((modm, xK_n ), refresh) , ((modm, xK_j ), windows W.focusDown) , ((modm, xK_k ), windows W.focusUp ) , ((modm .|. shiftMask, xK_j ), windows W.swapDown ) , ((modm .|. shiftMask, xK_k ), windows W.swapUp ) , ((modm, xK_h ), sendMessage Shrink) , ((modm, xK_l ), sendMessage Expand) , ((modm, xK_comma ), sendMessage (IncMasterN (1))) , ((modm, xK_period), sendMessage (IncMasterN (-1))) , ((modm .|. shiftMask, xK_q ), io (exitWith ExitSuccess)) , ((modm .|. shiftMask, xK_r ), spawn "xmonad --recompile && xmonad --restart") ] ++ [((m .|. modm, k), windows $ f i) | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9] , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]] ++ [((m .|. modm, 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)]] paulXPConfig = defaultXPConfig { font = "xft:arial:bold:size=9" , bgColor = "snow1" , fgColor = "#505050" , fgHLight = "#505050" , bgHLight = "snow1" , promptBorderWidth = 1 , position = Bottom , height = 19 , historySize = 32 , defaultText = [] } searchEngineMap method = M.fromList $ [ ((0, xK_g), method S.google) , ((0, xK_w), method $ S.searchEngine "Wikipedia" "http://en.wikipedia.org/w/index.php?title=Special:Search&redirs=0&search=") , ((0, xK_i), method $ S.searchEngine "Imdb" "http://www.imdb.com/find?s=all&q=") , ((0, xK_y), method S.youtube) , ((0, xK_d), method S.dictionary) , ((0, xK_b), method $ S.searchEngine "archbbs" "http://bbs.archlinux.org/search.php?action=search&keywords=") , ((0, xK_t), method $ S.searchEngine "Rotten" "http://www.rottentomatoes.com/search/?search=") , ((0, xK_r), method $ S.searchEngine "archwiki" "http://wiki.archlinux.org/index.php/Special:Search?search=") , ((0, xK_p), method $ S.searchEngine "Play" "http://www.play.com/Search.aspx?searchtype=allproducts&searchstring=") , ((0, xK_a), method $ S.searchEngine "Amazon" "http://www.amazon.co.uk/s/ref=nb_ss?url=search-alias%3Daps&field-keywords=") , ((0, xK_u), method $ S.searchEngine "Urban" "http://urbandictionary.com/define.php?term=") , ((0, xK_e), method $ S.searchEngine "Epguides" "http://www.google.com/search?hl=en&q=allintitle%3A&q=site%3Aepguides.com&q=") ] myLayout = avoidStruts $ windowNavigation $ onWorkspace "1" webLayout $ onWorkspace "2" webLayout $ windowNavigation $ onWorkspace "3" fileLayout $ onWorkspace "4" imLayout $ windowNavigation $ onWorkspace "5" magLayout $ standardLayout where imLayout = IM (1%5) (Or (Title "Buddy List") (And (Resource "main") (ClassName "pidgin"))) fileLayout = tiled ||| simpleFloat ||| Grid screenLayout = Full webLayout = Full ||| spaced magLayout = named "Grid" $ Mag.magnifiercz 1.15 $ Grid standardLayout = avoidStruts $ windowNavigation $ tiled ||| Grid ||| Full ||| simpleFloat ||| spaced tiled = Tall nmaster delta ratio grid = layoutHints Grid spaced = named "Spaced" $ spacing 10 $ Tall 1 (3/100) (1/2) nmaster = 1 ratio = toRational (2/(1 + sqrt 5 :: Double)) delta = 3/100 newManageHook = myManageHook <+> manageHook defaultConfig myDzenFont = "arial:bold:size=9" conkyFile = "conky -c ~/.conkyrc0" colorWhite = "snow1" colorOrange = "orange" colorRed = "red" colorBrown = "#663300" colorZburn = "#3f3f3f" colorZburn1 = "#80d4aa" colorZburn2 = "#f0dfaf" colorRed1 = "#543532" colorBlack = "#000000" colorGrey1 = "#808080" colorGrey2 = "#808080" colorGrey3 = "#CCCCCC" myManageHook = scratchpadManageHook (W.RationalRect l t w h) <+> (composeAll $ [ className =? "MPlayer" --> doFloat , className =? "Gimp" --> doFloat , className =? "obshutdown" --> doIgnore , resource =? "thunar" --> doShift "3" , resource =? "firefox" --> doShift "1" , resource =? "ncmpcpp" --> doShift "5" , resource =? "chromium" --> doShift "1" , resource =? "gedit" --> doShift "6" , resource =? "ranger" --> doShift "3" , className =? "Pidgin" <&&> title =? "Buddy List" --> doShift "4" , className ~? "^libreoffice" --> doShift "7" , className ~? "libreoffice-writer" --> doShift "7" , resource =? "mousepad" --> doShift "6" , className =? "stalonetray" --> doIgnore , resource =? "desktop_window" --> doIgnore , resource =? "kdesktop" --> doIgnore ]) where role = stringProperty "WM_WINDOW_ROLE" h = 0.4 w = 0.75 t = 0.85 - h l = 0.87 - w myStartupHook = startup startup = do spawn "setxkbmap gb" spawn "stalonetray" spawn "pidgin" spawn "gnome-sound-applet" spawn "nm-applet" main = do din <- spawnPipe myStatusBar din2 <- spawnPipe myStatusBar2 din3 <- spawnPipe myStatusBar3 xmonad $ withUrgencyHook NoUrgencyHook $ defaultConfig { terminal = myTerminal , normalBorderColor = myNormalBorderColor , workspaces = myWorkspaces , focusedBorderColor = myFocusedBorderColor , logHook = myLogHook din , modMask = myModMask , layoutHook = myLayout , focusFollowsMouse = myFocusFollowsMouse , manageHook = newManageHook <+> manageDocks , startupHook = myStartupHook , keys = \c -> myKeys c } myLogHook h = (dynamicLogWithPP $ defaultPP { ppSort = fmap (.scratchpadFilterOutWorkspace) getSortByTag , ppCurrent = dzenColor colorZburn1 colorZburn . pad , ppHidden = dzenFG colorZburn2 . pad , ppHiddenNoWindows = namedOnly , ppUrgent = myWrap colorRed "{" "}" . pad , ppTitle = dzenColor colorZburn2 colorZburn . shorten 55 , ppWsSep = "" , ppSep = " : " , ppOutput = hPutStrLn h , ppLayout = dzenColor colorZburn2 "". (\x -> case x of "Tall" -> "^i(/home/paul/icons/rob/tall.xbm)" "Full" -> "^i(/home/paul/icons/rob/full.xbm)" "spaced" -> "^i(/home/paul/icons/rob/float.xbm)" "Grid" -> "^i(/home/paul/icons/rob/dragpane.xbm)" "IM" -> "^i(/home/paul/icons/rob/msn.xbm)" ) }) -- >> updatePointer (Relative 0.95 0.95) where dzenFG c = dzenColor c "" myWrap c l r = wrap (dzenFG c l) (dzenFG c r) namedOnly ws = if any (`elem` ws) ['a'..'z'] then pad ws else "" myStatusBar = "/home/paul/bin/dzen2 -y '584' -w '500' -ta 'l'" ++ myDzenStyle myStatusBar2 = "/home/paul/bin/conky -c ~/.conkyrc | /home/paul/bin/dzen2 -x '500' -y '584' -w '464' -ta 'r'" ++ myDzenStyle myStatusBar3 = "/home/paul/bin/conky -c ~/.conkyrc1 | /home/paul/bin/dzen2 -x '0' -y '0' -w '1024'" ++ myDzenStyle myDzenStyle = " -h '16' -fg '#777777' -bg '#3f3f3f' -fn 'arial:bold:size=9'"