-- $HOME/.xmonad/xmonad.hs for i531 -- {-# LANGUAGE NoMonomorphismRestriction #-} import System.IO import XMonad hiding ( (|||) ) import XMonad.Actions.CycleWS import XMonad.Actions.DynamicWorkspaces import XMonad.Actions.GridSelect import XMonad.Actions.UpdatePointer import XMonad.Actions.WindowGo import XMonad.Actions.WithAll import XMonad.Hooks.DynamicLog import XMonad.Hooks.EwmhDesktops import XMonad.Hooks.ManageDocks import XMonad.Hooks.ManageHelpers import XMonad.Hooks.UrgencyHook import XMonad.Layout hiding ( (|||) ) import XMonad.Layout.ComboP import XMonad.Layout.Grid import XMonad.Layout.LayoutCombinators import XMonad.Layout.Named import XMonad.Layout.NoBorders import XMonad.Layout.ResizableTile import XMonad.Layout.ShowWName import XMonad.Layout.ToggleLayouts import XMonad.Layout.TwoPane import XMonad.Prompt import XMonad.Prompt.AppendFile import XMonad.Prompt.Man import XMonad.Prompt.RunOrRaise import XMonad.Prompt.Shell import XMonad.Prompt.Ssh import XMonad.Prompt.Window import XMonad.Util.EZConfig import XMonad.Util.NamedScratchpad import XMonad.Util.Run (runInTerm, spawnPipe) import XMonad.Util.WindowProperties import XMonad.Util.WorkspaceCompare import qualified XMonad.Actions.Search as S import qualified XMonad.Actions.Submap as SM import qualified XMonad.Layout.Magnifier as M import qualified XMonad.Prompt as P import qualified XMonad.StackSet as W myManageHook = namedScratchpadManageHook myScratchPads <+> composeAll [ className =? "MPlayer" --> doFloat , className =? "Smplayer" --> doFloat , className =? "feh" --> doCenterFloat , className =? "Gcolor2" --> doCenterFloat , className =? "XCalc" --> doCenterFloat , isFullscreen --> doFullFloat -- fullscreen anything that uses the fullscreen window property , (role =? "gimp-toolbox" <||> role =? "gimp-image-window") --> (ask >>= doF . W.sink) ]where role = stringProperty "WM_WINDOW_ROLE" myLayoutHook = avoidStruts $ myShowWName $ smartBorders $ toggleLayouts Full $ layoutHook defaultConfig ||| (Mirror $ tall) ||| Full ||| Grid ||| tall ||| (named "M.Grid" $ M.magnifier (Grid)) ||| (named "M.Mirror RzTall" $ M.magnifier (Mirror tall)) ||| (named "M.RzTall" $ M.magnifier (tall)) ||| noBorders (gimpLayout) where gimpLayout = named "GimpL" $ combineTwoP (TwoPane 0.04 0.86) (Full) (Full) (Not (Role "gimp-toolbox")) tall = named "RzTall" $ ResizableTall 1 (3/100) (1/2) [] myShowWName = showWName' defaultSWNConfig { swn_bgcolor = "#000000" , swn_color = "#ffffff" , swn_fade = 2 , swn_font = "xft:DejaVu Sans Mono:pixelsize=20:antialias=true" } myLogHook xmproc = dynamicLogWithPP xmobarPP { ppCurrent = \(c) -> [] -- do not show , ppHidden = \(h) -> [] -- , ppOrder = \(ws:l:_) -> [l,ws] -- show: layout then workspace , ppOutput = hPutStrLn xmproc , ppSort = fmap (namedScratchpadFilterOutWorkspace.) (ppSort xmobarPP) -- hide NSP from the workspace list , ppUrgent = xmobarColor "#000000" "#ffff00" -- highlight urgent workspace[s] with the specified colors["fg" "bg"] }>> updatePointer (Relative 0.5 0.5) -- move the pointer to the center of a newly focused window myXPConfig = defaultXPConfig { autoComplete = Just 500000 -- Just x[in microseconds]: if only one completion remains, auto-select it , bgColor = "#000000" , bgHLight = "#ffffff" , borderColor = "#000000" , fgColor = "#ffffff" , fgHLight = "#000000" , font = "xft:DejaVu Sans Mono:pixelsize=13:antialias=true" , height = 16 , historySize = 0 -- do not save to $HOME/.xmonad/history , position = Top } scratchpadSize1 = W.RationalRect (1/6) (1/6) (1/2) (1/2) scratchpadSize2 = W.RationalRect (1/6) (1/6) (1/3) (1/3) mySPFloat1 = customFloating scratchpadSize1 mySPFloat2 = customFloating scratchpadSize2 myScratchPads = [ NS "htop" "urxvtc -e htop" (title =? "htop") mySPFloat1 , NS "iotop" "urxvtc -e iotop" (title =? "iotop") mySPFloat1 , NS "notes" "gvim --role notes $HOME/NOTES" (role =? "notes") mySPFloat2 , NS "xcalc" "xcalc" (title =? "xcalc") mySPFloat2 , NS "NSP" "screen-NSP.sh" (title =? "NSP") mySPFloat1 ]where role = stringProperty "WM_WINDOW_ROLE" myGSConfig = defaultGSConfig {gs_font = "xft:DejaVu Sans Mono:pixelsize=11:antialias=true"} mySpawnList = ["screen.sh", "screen-mail.sh", "screen-sync.sh"] myUrgencyConfig = urgencyConfig {suppressWhen = XMonad.Hooks.UrgencyHook.Never} myWorkSpaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "NSP"] myKeys = -- cycleWS [ ("M-x ,", moveTo Prev (WSIs notNSP )) -- change to the _Previous_ workspace, except NSP , ("M-x .", moveTo Next (WSIs notNSP )) -- _Next_ , ("M-x /", myToggleWS ) -- toggle to the workspace displayed previously, except NSP , ("M-C-,", windows . W.greedyView =<< findWorkspace getSortByIndexNoNSP Prev HiddenNonEmptyWS 1) -- focus _Previous_ HiddenNonEmpty workspace, except NSP , ("M-C-.", windows . W.greedyView =<< findWorkspace getSortByIndexNoNSP Next HiddenNonEmptyWS 1) -- _Next_ , ("M-C-", windows . W.greedyView =<< findWorkspace getSortByIndexNoNSP Prev EmptyWS 1 ) -- focus _Previous_ NonEmpty workspace, except NSP , ("M-C-", windows . W.greedyView =<< findWorkspace getSortByIndexNoNSP Next EmptyWS 1 ) -- _Next_ , ("M-S-p", shiftAndView' Prev ) -- move window to _Previous_ and focus HiddenNonEmpty workspace, except NSP , ("M-S-n", shiftAndView' Next ) -- _Next_ , ("M-S-,", windows . W.shift =<< findWorkspace getSortByIndexNoNSP Prev HiddenNonEmptyWS 1 ) -- move window to _Previous_ HiddenNonEmpty workspace, except NSP , ("M-S-.", windows . W.shift =<< findWorkspace getSortByIndexNoNSP Next HiddenNonEmptyWS 1 ) -- _Next_ , ("M-S-", windows . W.shift =<< findWorkspace getSortByIndexNoNSP Prev EmptyWS 1 ) -- move window to _Previous_ NonEmpty workspace, except NSP , ("M-S-", windows . W.shift =<< findWorkspace getSortByIndexNoNSP Next EmptyWS 1 ) -- _Next_ -- dynamicWorkspaces , ("M-d a", addWorkspacePrompt myXPConfig) -- add a new workspace with the given name , ("M-d r", renameWorkspace myXPConfig) -- rename the current workspace , ("M-d s", selectWorkspace myXPConfig) -- goto the selected workspace , ("M-S-", removeWorkspace ) -- remove the current workspace -- gridSelect , ("M-g b", bringSelected myGSConfig ) -- brings the selected window to the current workspace , ("M-g g", goToSelected myGSConfig ) -- switches to selected window's workspace and focuses that window , ("M-g m", gridselectWorkspace myGSConfig (\ws -> W.greedyView ws . W.shift ws)) -- move and follow the focused window to the selected workspace , ("M-g s", spawnSelected myGSConfig $ mySpawnList ) -- select an application to spawn from a given list , ("M-g w", gridselectWorkspace myGSConfig W.greedyView ) -- select a workspace and view it using the given function -- misc , ("M-f", sendMessage (Toggle "Full" )) -- toggle Full layout with the current layout; on the focused window , ("M-u", focusUrgent ) -- focus the most recently urgent window , ("M-g i", runOrRaiseMaster "gimp" (className =? "Gimp" )) , ("M-g p", runOrRaiseMaster "gpodder" (className =? "Gpodder" )) , ("M-m a", raiseMaybe (runInTerm "-title mail" "screen -raAd mail") (title =? "mail" )) -- reattach to sessionName _mail_ in the current workspace or if already attached; give it focus , ("M-m i", runOrRaiseMaster "midori" (className =? "Midori" )) , ("M-m m", windows W.focusMaster ) -- move focus to the master window , ("M-m o", spawn "monitor-standby.sh" ) , ("M-m p", runOrRaiseMaster "smplayer" (className =? "Smplayer" )) , ("M-m ,", sendMessage (IncMasterN 1 )) -- increment the number of windows in the master area , ("M-m .", sendMessage (IncMasterN (-1) )) -- deincrement the number of windows in the master area , ("M-t s", sendMessage (ToggleStruts )) -- hides *bar , ("M-t t", withFocused $ windows . W.sink ) -- push window back into tiling , ("M-x c", runOrRaiseMaster "chromium-browser" (className =? "Chromium-browser" )) , ("M-x f", runOrRaiseMaster "firefox" (className =? "Firefox" )) , ("M-x k", runOrRaiseMaster "keepassx" (className =? "Keepassx" )) , ("M-x l", spawn "xset dpms force off" >> moveTo Next EmptyWS >> spawn "xtrlock" ) -- move to the Next available empty workspace and lock X , ("M-x r", raiseMaybe (runInTerm "-title sync" "screen -raAd sync") (title =? "sync" )) -- reattach to sessionName _sync_ in the current workspace or if already attached; give it focus , ("M-x s", raiseMaybe (runInTerm "-title screen" "screen -raAd screen") (title =? "screen")) -- _screen_ , ("M-x v", runOrRaiseMaster "virtualbox" (className =? "VirtualBox" )) , ("M-C-S-a", killAll ) -- killAll the windows on the current workspace -- multimedia; alsa , ("", spawn "amixer -q set Master toggle" ) , ("", spawn "amixer -q set Master 1- unmute") , ("", spawn "amixer -q set Master 1+ unmute") -- myScratchPads , ("C-s c", namedScratchpadAction myScratchPads "xcalc") -- run _xcalc_ in a floating NSP , ("C-s h", namedScratchpadAction myScratchPads "htop" ) -- run _htop_ , ("C-s i", namedScratchpadAction myScratchPads "iotop") -- run _iotop_ , ("C-s n", namedScratchpadAction myScratchPads "notes") -- run _gvim_ , ("C-s s", namedScratchpadAction myScratchPads "NSP" ) -- run _screen-NSP.sh_ -- prompts , ("M-S-a", appendFilePrompt myXPConfig "$HOME/NOTES") -- a prompt for appending a single line of text to a file , ("M-S-b", windowPromptBring myXPConfig) , ("M-S-e", shellPrompt myXPConfig) , ("M-S-g", windowPromptGoto myXPConfig) , ("M-S-h", sshPrompt myXPConfig) , ("M-S-m", manPrompt myXPConfig) , ("M-S-r", runOrRaisePrompt myXPConfig) , ("M-S-z", shellPrompt myXPConfig) -- resizing , ("M-C-e", sendMessage MirrorExpand ) -- _Expand_ a window in a ResizableTile Layout , ("M-C-s", sendMessage MirrorShrink ) -- _Shrink_ , ("M-C-l", sendMessage M.MagnifyLess) -- magnify _Less_ a window in a Magnfier Layout , ("M-C-m", sendMessage M.MagnifyMore) -- _More_ -- screenshots , ("", spawn "scrot -e 'mv $f /tmp/'" ) -- take a full screenshot; save in /tmp/ , ("C-", spawn "sleep 0.2; scrot -s -e 'mv $f /tmp/'") -- take a screenshot of a selected window, C-Print then click on a window; save in /tmp/ ]-- end of regular keybindings -- M-S-#: move and follow the focused window to a workspace[1-9] ++ [("M-" ++ m ++ k, windows $ f i) | (i, k) <- zip myWorkSpaces (map show [1 .. 9]), (f, m) <- [(W.greedyView, ""), (\w -> W.greedyView w. W.shift w, "S-")]] -- use X.A.GridSelect and X.L.LayoutCombinators to switch Layouts, from the list below ++ [("M-g l", switch ["Tall", "Mirror RzTall", "Full", "Grid", "RzTall", "M.Grid", "M.Mirror RzTall", "M.RzTall", "GimpL"])] -- search ++ [("M-s " ++ k, S.promptSearch myXPConfig f) | (k,f) <- searchList] ++ [("M-S-s " ++ k, S.selectSearch f) | (k,f) <- searchList] -- continues below -- skip NSP workspace while using CycleWS where notNSP = (return $ ("NSP" /=) . W.tag) :: X (WindowSpace -> Bool) getSortByIndexNoNSP = fmap (.namedScratchpadFilterOutWorkspace) getSortByIndex shiftAndView' dir = findWorkspace getSortByIndexNoNSP dir EmptyWS 1 >>= \t -> (windows . W.shift $ t) >> (windows . W.greedyView $ t) myToggleWS = windows $ W.view =<< W.tag . head . filter ((\x -> x /= "NSP" && x /= "SP") . W.tag) . W.hidden -- switch Layouts using X.A.GridSelect and X.L.LayoutCombinators switch :: [String] -> X () switch layouts = (gridselect myGSConfig (zip layouts layouts)) >>= maybe (return ()) (sendMessage . JumpToLayout) -- search engines/list keybindings searchList = [ ("a", S.alpha ) -- M-s + * Prompts you for a search string, then opens a new browser tab or , ("b", S.debbts ) -- window depending how the browser is setup. , ("e", S.deb ) -- M-S-s + * "If you select something in whatever application and hit , ("i", S.imdb ) -- mod-shift-s + g/h/w it will search the selected string with the specified engine." , ("o", S.google ) , ("p", S.debpts ) , ("y", S.wayback) -- mySearchEngines , ("d", S.searchEngine "duckduckgo-ssl" "https://duckduckgo.com/?kp=-1&kl=us-en&kg=p&kd=1&kn=1&q=" ) -- these search engines are not included in Search.hs , ("g", S.searchEngine "google-ssl" "https://encrypted.google.com/search?num=100&q=" ) -- $HOME/downloads/xmonad/darcs/XMonadContrib/XMonad/Actions/Search.hs , ("h", S.searchEngine "hayoo" "http://holumbus.fh-wedel.de/hayoo/hayoo.html?query=" ) -- for the list of the default search engines currently used look at , ("k", S.searchEngine "wiktionary-ssl" "https://secure.wikimedia.org/wiktionary/en/wiki/Special:Search?go=Go&search=") -- http://code.haskell.org/XMonadContrib/XMonad/Actions/Search.hs , ("s", S.searchEngine "scroogle-ssl" "https://ssl.scroogle.org/cgi-bin/nbbwssl.cgi?Gw=" ) , ("w", S.searchEngine "wikipedia-ssl" "https://secure.wikimedia.org/wikipedia/en/wiki/Special:Search?go=Go&search=" ) , ("x", S.searchEngine "isohunt-ssl" "https://isohunt.com/torrents/?ihq=" ) , ("z", S.searchEngine "tpb-ssl" "https://thepiratebay.org/search/" ) ] main = do xmproc <- spawnPipe "xmobar" -- assumes xmobar in $PATH and config in $HOME/.xmobarrc xmonad $ withUrgencyHookC NoUrgencyHook myUrgencyConfig $ ewmh defaultConfig { borderWidth = 1 , layoutHook = myLayoutHook , logHook = myLogHook xmproc , manageHook = myManageHook <+> manageDocks <+> manageHook defaultConfig , modMask = mod4Mask , startupHook = return () >> checkKeymap defaultConfig myKeys -- check for unparseable or duplicate key sequences , terminal = "urxvtc" , workspaces = myWorkSpaces } `additionalKeysP` myKeys