-- $HOME/.xmonad/xmonad.hs for i531 --
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.Named
import XMonad.Layout.NoBorders
import XMonad.Layout.PerWorkspace
import XMonad.Layout.ShowWName
import XMonad.Layout.ResizableTile
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 =? "Smplayer" --> doFloat -- place the following in the floating layer --
, className =? "feh" --> doCenterFloat -- same as above, but centered on the screen --
, className =? "MPlayer" --> doCenterFloat --
, className =? "Epdfview" --> doShiftAndGo "8:pdf" -- move these to the specified workspace --
, className =? "Firefox" --> doShiftAndGo "1:web" --
, className =? "Gimp" --> doShiftAndGo "7:gimp" --
, className =? "Gpodder" --> doShiftAndGo "4:aud" --
, className =? "Iceweasel" --> doShiftAndGo "1:web" --
, className =? "Keepassx" --> doShiftAndGo "1:web" --
, className =? "MPlayer" --> doShiftAndGo "5:vid" --
, className =? "Smplayer" --> doShiftAndGo "5:vid" --
, className =? "VirtualBox" --> doShiftAndGo "6:vbox" --
, title =? "screen" --> doShiftAndGo "2:scr" --
, title =? "ssh" --> doShiftAndGo "3:ssh" --
-- full screen web video correctly like youtube or anything that uses full screen window property, like many presentation apps,
-- mplayer uses a different method, but works well as long as its floating --
, isFullscreen --> doFullFloat
, (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, with a keybind below --
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
, ppUrgent = xmobarColor "#00ffff" "" -- highlight workspace with the specified color when nick is highlighted in irssi --
}
>> updatePointer (Relative 0.5 0.5) -- move the pointer to the center of a newly focused window --
myShowWName = showWName' defaultSWNConfig -- show the workspace number:name '[1:wsp]' when switching workspaces 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
}
myModMask = mod4Mask
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:vbox", "7:gimp", "8:pdf", "9:misc", "NSP"]
myScratchPads =
-- run calc in urxvtc, find it by title and place the window 1/6 of screen width from the left, --
-- 1/6 of screen height from the top and 1/3 of screen width by 1/3 of screen height --
[NS "calc" "urxvtc -e calc" (title =? "calc") (customFloating $ W.RationalRect (1/6) (1/6) (1/3) (1/3)) ,
-- run gvim, find by role, with notes.txt opened and place the window 1/6 of screen width from the left, --
-- 1/6 of screen height from the top and 1/3 of screen width by 1/3 of screen height, --
-- notes.txt will be saved in $HOME/documents/ --
NS "notes" "gvim --role notes $HOME/documents/notes.txt" (role =? "notes") (customFloating $ W.RationalRect (1/6) (1/6) (1/3) (1/3)) ,
-- run htop in urxvtc, find it by title and place the window 1/6 of screen width from the left, --
-- 1/6 of screen height from the top and 1/2 of screen width by 1/2 of screen height --
NS "htop" "urxvtc -e htop" (title =? "htop") (customFloating $ W.RationalRect (1/6) (1/6) (1/2) (1/2)) ,
-- run iotop in urxvtc, find it by title and place the window 1/6 of screen width from the left, --
-- 1/6 of screen height from the top and 1/2 of screen width by 1/2 of screen height --
NS "iotop" "urxvtc -e iotop" (title =? "iotop") (customFloating $ W.RationalRect (1/6) (1/6) (1/2) (1/2)) ,
-- run screen-NSP.sh in urxvtc, find it by title and place the window 1/6 of screen width from the left, --
-- 1/6 of screen height from the top and 1/2 of screen width by 1/2 of screen height --
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 open in 7:gimp --
, ("M-g p", runOrRaiseMaster "gpodder" (className =? "Gpodder" )) -- and open in 4:aud --
, ("M-m o", spawn "monitor-standby.sh" ) -- send monitor to standby --
, ("M-m p", runOrRaiseMaster "smplayer" (className =? "Smplayer" )) -- and open in 5:vid --
, ("M-x e", runOrRaiseMaster "epdfview" (className =? "Epdfview" )) -- and open in 8:pdf --
, ("M-x f", runOrRaiseMaster "firefox" (className =? "Firefox" )) -- and open in 1:web --
, ("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 open in 2:scr --
, ("M-x v", runOrRaiseMaster "virtualbox" (className =? "VirtualBox" )) -- and open in 6:vbox --
, ("M-x x", runOrRaiseMaster "keepassx" (className =? "Keepassx" )) -- and open in 1:web --
, ("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 --
, ("<XF86AudioMute>", spawn "amixer -q set Master toggle" ) -- mute --
, ("<XF86AudioLowerVolume>", spawn "amixer -q set Master 1- unmute" ) -- lowerVolume --
, ("<XF86AudioRaiseVolume>", 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 s", goToSelected defaultGSConfig ) -- switches to selected window's workspace and focuses that window --
, ("M-g w", gridselectWorkspace defaultGSConfig 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 --
-- screenshots --
, ("<Print>", spawn "scrot -e 'mv $f /tmp/'" ) -- take a full screenshot, file is saved in /tmp/ --
, ("C-<Print>", 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 firefox tab or
, ("b", S.debbts ) -- window depending how firefox is setup --
, ("d", S.dictionary ) --
, ("e", S.deb ) --
, ("g", S.google ) -- for the list of the search engines currently used look at --
, ("i", S.imdb ) -- $HOME/downloads/xmonad/darcs/XMonadContrib/XMonad/Actions/Search.hs --
, ("t", S.thesaurus ) --
-- mySearchEngines --
, ("h", S.searchEngine "isohunt" "https://isohunt.com/torrents/?ihq=" ) -- these search engines are not included in Search.hs --
, ("s", S.searchEngine "scroogle" "https://ssl.scroogle.org/cgi-bin/nbbwssl.cgi?Gw=" )
, ("p", S.searchEngine "tpb" "https://thepiratebay.org/search/" )
, ("w", S.searchEngine "wikipedia" "https://secure.wikimedia.org/wikipedia/en/wiki/Special:Search?go=Go&search=")
]