import XMonad import Data.Monoid import System.Exit import Text.Regex.Posix ((=~)) import XMonad.Util.EZConfig(additionalKeysP) import qualified XMonad.StackSet as W import XMonad.Actions.Navigation2D import XMonad.Actions.WorkspaceNames import qualified Data.Map as M import XMonad.Util.Scratchpad (scratchpadSpawnAction, scratchpadManageHook, scratchpadFilterOutWorkspace) import XMonad.Hooks.UrgencyHook import XMonad.Hooks.ManageHelpers import XMonad.Util.Run (hPutStrLn, spawnPipe, runInTerm) import XMonad.Prompt import XMonad.Prompt.Shell import XMonad.Prompt.Theme import XMonad.Layout.BinarySpacePartition hiding (Swap) import qualified XMonad.Layout.BinarySpacePartition as BSP import XMonad.Layout.EqualSpacing import XMonad.Layout.Gaps import XMonad.Layout.Mosaic import XMonad.Layout.MosaicAlt import XMonad.Layout.MouseResizableTile import XMonad.Layout.MultiToggle import XMonad.Layout.MultiToggle.Instances import XMonad.Layout.NoBorders import XMonad.Layout.Renamed import XMonad.Layout.Simplest import XMonad.Layout.SubLayouts import XMonad.Layout.Tabbed 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 import System.IO myStartupHook = startup startup = do spawn "setxkbmap gb" main = do status <- spawnPipe myDzenStatus conky <- spawnPipe myDzenConky xmonad $ withNavigation2DConfig defaultNavigation2DConfig $ withUrgencyHook NoUrgencyHook $ defaultConfig { terminal = myTerminal , normalBorderColor = "#3f3f3f" , workspaces = myWorkspaces , focusedBorderColor = "#f0dfaf" , logHook = updatePointer (Relative 0.95 0.95) <+> myLogHook status , modMask = mod4Mask , layoutHook = myLayoutHook , focusFollowsMouse = myFocusFollowsMouse , manageHook = myManageHook <+> manageHook defaultConfig , startupHook = myStartupHook , keys = \c -> myKeys c } q ~? x = fmap (=~ x) q myTerminal = "xterm" myFocusFollowsMouse = True myBorderWidth = 1 altMask = mod1Mask myWorkspaces = clickable . (map dzenEscape) $ ["1","2","3","4","5"] where clickable l = [ "^ca(1,xdotool key super+" ++ show (n) ++ ")" ++ ws ++ "^ca()" | (i,ws) <- zip [1..] l, let n = i ] myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $ [ ((modm .|. shiftMask, xK_Return ), spawn $ XMonad.terminal conf) , ((modm, xK_p ), spawn "lighthouse | sh") , ((modm, xK_b ), spawn "firefox-developer-edition") , ((modm, xK_c ), spawn "dwb") , ((modm, xK_f ), spawn "firefox") , ((modm, xK_t ), spawn "xterm -name ranger -e ranger") , ((modm, xK_m ), spawn "xterm -name mutt -e mutt") , ((modm .|.shiftMask, xK_m ), spawn "xterm -name mpsyt -e mpsyt") , ((modm, xK_Escape ), spawn "pygtk-shutdown-systemd") , ((modm .|. shiftMask, xK_n ), spawn "mpd && xterm -name ncmpcpp -e ncmpcpp") , ((modm .|. shiftMask, xK_s ), scratchpadSpawnAction defaultConfig { terminal = myTerminal }) , ((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) , ((0, 0x1008ff11 ), spawn "dvol.sh -d 2") , ((0, 0x1008ff13 ), spawn "dvol.sh -i 2") , ((0, 0x1008ff14 ), spawn "mpc toggle") , ((modm .|. shiftMask, xK_l ), sendMessage $ ExpandTowards R) , ((modm .|. shiftMask, xK_h ), sendMessage $ ExpandTowards L) , ((modm .|. shiftMask, xK_j ), sendMessage $ ExpandTowards D) , ((modm .|. shiftMask, xK_k ), sendMessage $ ExpandTowards U) , ((modm, xK_Down ), windows W.focusDown) , ((modm, xK_Up ), windows W.focusUp) , ((modm .|. altMask, xK_m ), windows W.swapMaster) , ((modm, xK_s ), sendMessage $ BSP.Swap) , ((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:M+1m:size=14" , bgColor = "snow1" , fgColor = "#505050" , fgHLight = "#505050" , bgHLight = "snow1" , promptBorderWidth = 1 , position = Bottom , height = 20 , historySize = 32 , defaultText = [] } myLayoutHook = smartBorders $ avoidStruts $ myLayouts myLayouts = mkToggle (single FULL) (myLayout3 ||| myLayout1 ||| myLayout2) where myMRT = mouseResizableTile { draggerType = FixedDragger 0 8 } myBSP = emptyBSP myLayout1 = renamed [Replace "|"] $ myMRT myLayout2 = renamed [Replace "-"] $ myMRT { isMirrored = True } myLayout3 = renamed [Replace "B"] $ equalSpacing 36 6 1 1 $ myBSP myFull = renamed [Replace "O"] $ Full myLayout1 = mouseResizableTile { draggerType = FixedDragger 0 8 } myLayout2 = myLayout1 { isMirrored = True } myManageHook = composeAll [ className =? "MPlayer" --> doFloat , className =? "smplayer" --> doFloat , className =? "Gimp" --> doFloat , className =? "Pygtk-shutdown-systemd" --> doFloat , resource =? "lighthouse" --> doFloat , className =? "Dwb" --> doShift (myWorkspaces !! 0) , className =? "Firefox-developer-edition" --> doShift (myWorkspaces !! 4) , className =? "firefox" --> doShift (myWorkspaces !! 4) , className =? "chromium" --> doShift (myWorkspaces !! 4) , resource =? "ncmpcpp" --> doShift (myWorkspaces !! 1) , resource =? "gedit" --> doShift (myWorkspaces !! 5) , resource =? "ranger" --> doShift (myWorkspaces !! 2) , resource =? "mutt" --> doShift (myWorkspaces !! 1) , className ~? "^libreoffice" --> doShift (myWorkspaces !! 6) , className ~? "libreoffice-writer" --> doShift (myWorkspaces !! 6) , resource =? "desktop_window" --> doIgnore , resource =? "kdesktop" --> doIgnore ] <+> manageScratchPad manageScratchPad :: ManageHook manageScratchPad = scratchpadManageHook (W.RationalRect l t w h) where role = stringProperty "WM_WINDOW_ROLE" h = 0.25 -- terminal height, 10% w = 0.4 -- terminal width, 100% t = 0.30 - h -- distance from top edge l = 0.97 - w -- distance from left edge myLogHook h = dynamicLogWithPP $ myDzenPP { ppOutput = hPutStrLn h } myDzenStatus = "dzen2 -w '500' -y '880' -ta 'l'" ++ myDzenStyle myDzenConky = "conky -c ~/.conkyrc-monsterwm | dzen2 -y '880' -x '500' -w '1100' -ta 'r'" ++ myDzenStyle myDzenStyle = " -h '20' -fg '#777777' -bg '#3f3f3f' -fn 'M+1m:size=14'" myDzenPP = dzenPP { ppCurrent = dzenColor "#3399ff" "" . wrap " " " " , ppSort = fmap (namedScratchpadFilterOutWorkspace .) (ppSort defaultPP) , ppHidden = dzenColor "#dddddd" "" . wrap " " " " , ppHiddenNoWindows = dzenColor "#777777" "" . wrap " " " " , ppUrgent = dzenColor "#ff0000" "" . wrap " " " " , ppSep = " " , ppLayout = dzenColor "#aaaaaa" "" . wrap "^ca(1,xdotool key super+space)· " " ·^ca()" , ppTitle = dzenColor "#ffffff" "" . wrap "^ca(1,xdotool key super+k)^ca(2,xdotool key super+shift+c)" " ^ca()^ca()" . shorten 50 . dzenEscape }