-- $HOME/.xmonad/xmonad.hs for i531 -- {-# LANGUAGE NoMonomorphismRestriction #-} import System.IO import XMonad import XMonad.Actions.CycleWS import XMonad.Actions.DynamicWorkspaces import XMonad.Actions.GridSelect import XMonad.Actions.UpdatePointer import XMonad.Actions.WindowGo import XMonad.Hooks.DynamicLog import XMonad.Hooks.EwmhDesktops import XMonad.Hooks.ManageDocks import XMonad.Hooks.ManageHelpers import XMonad.Hooks.UrgencyHook import XMonad.Layout import XMonad.Layout.ComboP import XMonad.Layout.Grid import XMonad.Layout.Named import XMonad.Layout.NoBorders import XMonad.Layout.PerWorkspace 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.Layout.Magnifier as Mag import qualified XMonad.StackSet as W main = do xmproc <- spawnPipe "xmobar" -- assumes xmobar in $PATH and config in $HOME/.xmobarrc -- xmonad $ withUrgencyHookC NoUrgencyHook myUrgencyConfig $ ewmh defaultConfig { manageHook = namedScratchpadManageHook myScratchPads <+> manageDocks <+> myManageHook <+> manageHook defaultConfig , layoutHook = myShowWName myLayoutHook , logHook = myLogHook xmproc , modMask = mod4Mask , terminal = "urxvtc" , workspaces = myWorkSpaces } `additionalKeysP` myKeys myManageHook = composeAll [ className =? "MPlayer" --> doFloat -- place the following in the floating layer -- , className =? "Smplayer" --> doFloat -- , className =? "feh" --> doCenterFloat -- , className =? "Gcolor2" --> doCenterFloat -- , className =? "XCalc" --> doCenterFloat -- , isFullscreen --> doFullFloat -- full screen anything that uses the full screen window property -- , (role =? "gimp-toolbox" <||> role =? "gimp-image-window") --> (ask >>= doF . W.sink) ]where role = stringProperty "WM_WINDOW_ROLE" myLayoutHook = avoidStruts $ smartBorders $ toggleLayouts Full $ -- toggle Full layout with the current layout; on the focused window -- layoutHook defaultConfig ||| gimpLayout ||| Grid ||| (named "ResizableTall" $ tall) ||| (named "Mag Mirror ResizableTall" $ Mag.magnifier (Mirror tall)) ||| (named "Mag ResizableTall" $ Mag.magnifier (tall)) where gimpLayout = named "Gimp" $ combineTwoP (TwoPane 0.04 0.86) (Full) (Full) (Not (Role "gimp-toolbox")) tall = ResizableTall 1 (3/100) (1/2) [] myLogHook xmproc = dynamicLogWithPP xmobarPP { ppCurrent = xmobarColor "#00ffff" "" . wrap "[" "]" -- highlight the current workspace with the specified colors["fg" "bg"] -- , ppOrder = \(ws:l:_) -> [ws,l] -- display workspace, then layout -- , 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 -- myShowWName = showWName' defaultSWNConfig -- when switching workspaces, show the workspace on the screen -- { swn_bgcolor = "#000000" , swn_color = "#ffffff" , swn_font = "xft:DejaVu Sans Mono:pixelsize=20:antialias=true" } myXPConfig = defaultXPConfig -- mainly options for XMonad.Prompt.*; but for some others as well -- { autoComplete = Just 500000 -- Just x[in microseconds]: if only one completion remains, auto-select it -- , bgColor = "#000000" , bgHLight = "#00ffff" , borderColor = "#000000" , fgColor = "#00ffff" , fgHLight = "#000000" , font = "xft:DejaVu Sans Mono:pixelsize=13:antialias=true" , historySize = 0 -- do not save anything to $HOME/.xmonad/history -- , position = Top } myScratchPads = [ NS "htop" "urxvtc -e htop" (title =? "htop") (customFloating $ W.RationalRect (1/6) (1/6) (1/2) (1/2)) , NS "iotop" "urxvtc -e iotop" (title =? "iotop") (customFloating $ W.RationalRect (1/6) (1/6) (1/2) (1/2)) , NS "notes" "gvim --role notes $HOME/documents/notes.txt" (role =? "notes") (customFloating $ W.RationalRect (1/6) (1/6) (1/3) (1/3)) , NS "xcalc" "xcalc" (title =? "xcalc") (customFloating $ W.RationalRect (1/6) (1/6) (1/3) (1/3)) , NS "NSP" "screen-NSP.sh" (title =? "NSP") (customFloating $ W.RationalRect (1/6) (1/6) (1/2) (1/2)) ]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-sshfs.sh"] myUrgencyConfig = urgencyConfig { suppressWhen = XMonad.Hooks.UrgencyHook.Never } myWorkSpaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "NSP"] myKeys = -- misc -- [ ("M-d r", renameWorkspace myXPConfig ) -- rename[s] are only temporary; M-q resets them -- , ("M-g i", runOrRaiseMaster "gimp" (className =? "Gimp" )) , ("M-g p", runOrRaiseMaster "gpodder" (className =? "Gpodder" )) , ("M-g s", spawnSelected myGSConfig $ mySpawnList ) -- select an application to spawn from a given list -- , ("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-x c", runOrRaiseMaster "chromium-browser" (className =? "Chromium-browser" )) , ("M-x f", runOrRaiseMaster "firefox" (className =? "Firefox" )) , ("M-x h", raiseMaybe (runInTerm "-title sshfs" "screen -raAd sshfs") (title =? "sshfs" )) -- reattach to sessionName 'sshfs' in the current workspace or if already attached; give it focus -- , ("M-x k", runOrRaiseMaster "keepassx" (className =? "Keepassx" )) , ("M-x l", spawn "xset dpms force off" >> moveTo Next EmptyWS >> spawn "xtrlock" ) -- focus the next available empty workspace and lock X -- , ("M-x s", raiseMaybe (runInTerm "-title screen" "screen -raAd screen") (title =? "screen" )) -- reattach to sessionname 'screen' in the current workspace or if already attached; give it focus -- , ("M-x v", runOrRaiseMaster "virtualbox" (className =? "VirtualBox" )) , ("M-S-f", sendMessage (Toggle "Full" )) -- toggle 'Full' layout with the current layout; on the focused window -- , ("M-S-t", sendMessage (ToggleStruts )) -- hide xmobar -- , ("M-S-", removeWorkspace ) -- remove the current workspace -- -- multimedia: volume - alsa -- , ("", spawn "amixer -q set Master toggle" ) -- mute/unmute -- , ("", spawn "amixer -q set Master 1- unmute" ) -- unmute and lowerVolume -- , ("", spawn "amixer -q set Master 1+ unmute" ) -- unmute and raiseVolume -- -- 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 "" "" -- -- navigation -- , ("M-d s", selectWorkspace myXPConfig ) -- goto the selected workspace -- , ("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 w", gridselectWorkspace myGSConfig W.greedyView ) -- select a workspace and view it using the given function -- , ("M-x u", focusUrgent ) -- focus the most recently urgent window -- , ("M-x ,", moveTo Prev (WSIs notNSP )) -- change to the [previous] workspace, except for NSP -- , ("M-x .", moveTo Next (WSIs notNSP )) -- [next] -- , ("M-x /", toggleWS ) -- toggle to the workspace displayed previously -- , ("M-C-,", windows . W.greedyView =<< findWorkspace getSortByIndexNoNSP Prev HiddenNonEmptyWS 1) -- focus [previous] HiddenNonEmpty workspace -- , ("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 -- , ("M-C-", windows . W.greedyView =<< findWorkspace getSortByIndexNoNSP Next EmptyWS 1 ) -- [next] -- , ("M-S-,", windows . W.shift =<< findWorkspace getSortByIndexNoNSP Prev HiddenNonEmptyWS 1 ) -- move window to [previous] HiddenNonEmpty workspace -- , ("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 -- , ("M-S-", windows . W.shift =<< findWorkspace getSortByIndexNoNSP Next EmptyWS 1 ) -- [next] -- -- prompts -- , ("M-S-a", appendFilePrompt myXPConfig "$HOME/documents/notes.txt" ) -- a prompt for appending a single line of text to a file -- , ("M-S-b", windowPromptBring myXPConfig ) -- a prompt that brings windows to you -- , ("M-S-g", windowPromptGoto myXPConfig ) -- "" "" takes you to windows -- , ("M-S-h", sshPrompt myXPConfig ) , ("M-S-m", manPrompt myXPConfig ) , ("M-S-p", shellPrompt myXPConfig ) , ("M-S-r", runOrRaisePrompt myXPConfig ) -- a prompt which will run a program, open a file, or raise an already running program, depending on context -- -- resizing -- -- depends on window selected, whether it shrinks or expands -- , ("M-C-s", sendMessage MirrorShrink ) -- shrink/expand the current window in a ResizableTile Layout -- , ("M-C-e", sendMessage MirrorExpand ) -- "" "" -- , ("M-C-", sendMessage Mag.MagnifyMore ) -- magnify [more] the current window in a Magnfiier Layout -- , ("M-C-", sendMessage Mag.MagnifyLess ) -- [less] -- -- 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; saved 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-")] ] -- skip the NSP workspace while using CycleWS -- where notNSP = (return $ ("NSP" /=) . W.tag) :: X (WindowSpace -> Bool) getSortByIndexNoNSP = fmap (.namedScratchpadFilterOutWorkspace) getSortByIndex