-- $HOME/.xmonad/xmonad.hs for i531 -- {-# LANGUAGE NoMonomorphismRestriction #-} import System.IO import XMonad import XMonad.Actions.CycleWS 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.LayoutHints 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.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 qualified XMonad.Actions.Submap as SM import qualified XMonad.Actions.Search as S import qualified XMonad.Layout.Magnifier as Mag import qualified XMonad.Prompt as P 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 = myModMask , terminal = myTerminal , workspaces = myWorkSpaces } `additionalKeysP` myKeys myManageHook = composeAll [ className =? "MPlayer" --> doFloat -- place the following in the floating layer -- , className =? "Smplayer" --> doFloat -- , className =? "feh" --> doCenterFloat -- , className =? "Chromium-browser" --> doShiftAndGo "1:web" -- move these to the specified workspace -- , className =? "Firefox" --> doShiftAndGo "1:web" -- , className =? "Gimp" --> doShiftAndGo "7:gimp" -- , className =? "Gpodder" --> doShiftAndGo "4:aud" -- , className =? "Midori" --> doShiftAndGo "1:web" -- , className =? "MPlayer" --> doShiftAndGo "5:vid" -- , className =? "Smplayer" --> doShiftAndGo "5:vid" -- , className =? "VirtualBox" --> doShiftAndGo "8:vbox" -- , title =? "mail" --> doShiftAndGo "6:mail" -- , title =? "screen" --> doShiftAndGo "2:scr" -- , title =? "ssh" --> doShiftAndGo "3:ssh" -- , title =? "sshfs" --> doShiftAndGo "3:ssh" -- , isFullscreen --> doFullFloat -- full screen anything that uses the full screen window property , (role =? "gimp-toolbox" <||> role =? "gimp-image-window") --> (ask >>= doF . W.sink) -- gimpLayout -- ] where role = stringProperty "WM_WINDOW_ROLE" doShiftAndGo :: WorkspaceId -> ManageHook doShiftAndGo ws = doF (W.greedyView ws) <+> doShift ws myLayoutHook = avoidStruts $ smartBorders $ onWorkspace "7:gimp" gimpLayout $ -- display the gimpLayout only in "7:gimp" -- toggleLayouts Full $ -- toggle Full layout with the current layout; on the focused window -- layoutHints $ layoutHook defaultConfig ||| 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")) -- gimpLayout -- tall = ResizableTall 1 (3/100) (1/2) [] myLogHook xmproc = dynamicLogWithPP xmobarPP { ppCurrent= xmobarColor "#ffffff" "" . wrap "[" "]" -- highlight the current workspace with the specified color '[1:wsp]' -- , ppOrder = \(ws:l:_) -> [ws,l] -- display workspace, then layout -- [1:wsp] [2:wsp] : Tall -- , ppOutput = hPutStrLn xmproc , ppSort = fmap (namedScratchpadFilterOutWorkspace.) (ppSort xmobarPP) -- hide 'NSP' from the workspace list -- , ppUrgent = xmobarColor "#00ffff" "" -- highlight urgent workspaces with the specified color -- } >> 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 } myGSConfig = defaultGSConfig { gs_font = "xft:DejaVu Sans Mono:pixelsize=11:antialias=true" } myModMask = mod4Mask mySpawnList = ["screen.sh", "screen-mail.sh", "screen-sshfs.sh"] myTerminal = "urxvtc" -- run a client terminal from the urxvt terminal deamon[urxvtd] -- myUrgencyConfig = urgencyConfig { suppressWhen = XMonad.Hooks.UrgencyHook.Never } myWorkSpaces = ["1:web", "2:scr", "3:ssh", "4:aud", "5:vid", "6:mail", "7:gimp", "8:vbox", "9:misc", "NSP"] myScratchPads = [ NS "calc" "urxvtc -e calc" (title =? "calc") (customFloating $ W.RationalRect (1/6) (1/6) (1/3) (1/3)) , 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 "NSP" "screen-NSP.sh" (title =? "NSP") (customFloating $ W.RationalRect (1/6) (1/6) (1/2) (1/2)) ] where role = stringProperty "WM_WINDOW_ROLE" myKeys = -- misc -- [ ("M-g i", runOrRaiseMaster "gimp" (className =? "Gimp" )) -- and move to 7:gimp -- , ("M-g p", runOrRaiseMaster "gpodder" (className =? "Gpodder" )) -- and move to 4:aud -- , ("M-g s", spawnSelected myGSConfig $ mySpawnList ) -- select an application to spawn from a given list -- , ("M-m o", spawn "monitor-standby.sh" ) -- send monitor to standby -- , ("M-m p", runOrRaiseMaster "smplayer" (className =? "Smplayer" )) -- and move to 5:vid -- , ("M-m a", raiseMaybe (runInTerm "-title mail" "screen -raAd mail") (title =? "mail" )) -- reattach to sessionname 'mail' and move to 6:mail; if not switch to 6:mail -- , ("M-x c", runOrRaiseMaster "chromium-browser" (className =? "Chromium-browser" )) -- and move to 1:web -- , ("M-x f", runOrRaiseMaster "firefox" (className =? "Firefox" )) -- and move to 1:web -- , ("M-x h", raiseMaybe (runInTerm "-title sshfs" "screen -raAd sshfs") (title =? "sshfs" )) -- reattach to sessionname 'sshfs' and move to 3:ssh; if not switch to 3:ssh -- , ("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 s", raiseMaybe (runInTerm "-title screen" "screen -raAd screen") (title =? "screen")) -- reattach to sessionname 'screen' and move to 2:scr; if not switch to 2:scr -- , ("M-x v", runOrRaiseMaster "virtualbox" (className =? "VirtualBox" )) -- and move to 8:vbox -- , ("M-S-f", sendMessage (Toggle "Full" )) -- toggle Full layout with the current layout; on the focused window -- , ("M-S-t", sendMessage (ToggleStruts )) -- toggleStruts on or off, to free screen space; ie.. hide xmobar -- -- multimedia: volume - alsa -- , ("", spawn "amixer -q set Master toggle" ) -- mute -- , ("", spawn "amixer -q set Master 1- unmute" ) -- lowerVolume -- , ("", spawn "amixer -q set Master 1+ unmute" ) -- raiseVolume -- -- myScratchPads -- , ("C-s c", namedScratchpadAction myScratchPads "calc" ) -- run calc in a floating scratchpad -- , ("C-s h", namedScratchpadAction myScratchPads "htop" ) -- run htop in a floating scratchpad -- , ("C-s i", namedScratchpadAction myScratchPads "iotop" ) -- run iotop in a floating scratchpad -- , ("C-s n", namedScratchpadAction myScratchPads "notes" ) -- run gvim in a floating scratchpad, for taking notes -- , ("C-s s", namedScratchpadAction myScratchPads "NSP" ) -- run screen-NSP.sh in a floating scratchpad -- -- navigation -- , ("M-g b", bringSelected myGSConfig ) -- brings selected window to the current workspace -- , ("M-g g", goToSelected myGSConfig ) -- switches to selected window's workspace and focuses that window -- , ("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 ,", prevWS ) -- change to previous workspace -- , ("M-x .", nextWS ) -- change to next workspace -- , ("M-x /", toggleWS ) -- toggle previous workspace -- , ("M-S-,", shiftToPrev >> prevWS ) -- move the current selected window to the previous workspace -- , ("M-S-.", shiftToNext >> nextWS ) -- move the current selected window to the next workspace -- , ("M-S-/", moveTo Next EmptyWS ) -- change to the next available empty workspace -- -- prompts -- , ("M-S-a", appendFilePrompt myXPConfig "$HOME/documents/notes.txt" ) -- a prompt for appending a single line of text to a file -- , ("M-S-p", shellPrompt myXPConfig ) -- a shell prompt -- , ("M-S-b", windowPromptBring myXPConfig ) -- a prompt that brings window's to you -- , ("M-S-g", windowPromptGoto myXPConfig ) -- a prompt that takes you to window's -- , ("M-S-h", sshPrompt myXPConfig ) -- a ssh prompt -- , ("M-S-m", manPrompt myXPConfig ) -- a manual page prompt -- -- resizing -- -- depends on window selected, whether it shrinks or expands -- , ("M-S-s", sendMessage MirrorShrink ) -- shrink/expand the current window in a ResizableTile Layout -- , ("M-S-e", sendMessage MirrorExpand ) -- shrink/expand the current window in a ResizableTile Layout -- , ("M-S-", sendMessage Mag.MagnifyMore ) -- magnify more the current window in a Magnfiier Layout -- , ("M-S-", sendMessage Mag.MagnifyLess ) -- magnify less the current window in a Magnifier Layout -- -- screenshots -- , ("", spawn "scrot -e 'mv $f /tmp/'" ) -- take a full screenshot, file is saved 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, file is saved in /tmp/ -- ] -- end of regular keybindings -- -- follow the window when using mod-S-# to move a window to another workspace -- ++ [("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-")] ] -- searching -- ++ [("M-s " ++ k, S.promptSearch myXPConfig f) | (k,f) <- searchList ] searchList :: [(String, S.SearchEngine)] 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 -- , ("d", S.dictionary ) -- , ("e", S.deb ) -- , ("i", S.imdb ) -- for the list of the default search engines currently used look at -- , ("o", S.google ) -- $HOME/downloads/xmonad/darcs/XMonadContrib/XMonad/Actions/Search.hs -- , ("t", S.thesaurus ) -- and/or http://code.haskell.org/XMonadContrib/XMonad/Actions/Search.hs -- -- mySearchEngines -- , ("g", S.searchEngine "google-ssl" "https://encrypted.google.com/search?num=100&q=" ) -- these search engines are not included in Search.hs -- , ("h", S.searchEngine "isohunt-ssl" "https://isohunt.com/torrents/?ihq=" ) , ("s", S.searchEngine "scroogle-ssl" "https://ssl.scroogle.org/cgi-bin/nbbwssl.cgi?Gw=" ) , ("p", S.searchEngine "tpb-ssl" "https://thepiratebay.org/search/" ) , ("q", S.searchEngine "ddg-ssl" "https://duckduckgo.com/?kp=-1&kl=us-en&kg=p&kd=1&kn=1&q=" ) , ("w", S.searchEngine "wikipedia-ssl" "https://secure.wikimedia.org/wikipedia/en/wiki/Special:Search?go=Go&search=") ]