All pastes #1936442 Raw Edit

ml|

public text v1 · immutable
#1936442 ·published 2010-09-09 11:04 UTC
rendered paste body
-- $HOME/.xmonad/xmonad.hs for i531 --{-# LANGUAGE NoMonomorphismRestriction #-}import System.IOimport XMonadimport XMonad.Actions.CycleWSimport XMonad.Actions.DynamicWorkspacesimport XMonad.Actions.GridSelectimport XMonad.Actions.UpdatePointerimport XMonad.Actions.WindowGoimport XMonad.Hooks.DynamicLogimport XMonad.Hooks.EwmhDesktopsimport XMonad.Hooks.ManageDocksimport XMonad.Hooks.ManageHelpersimport XMonad.Hooks.UrgencyHookimport XMonad.Layoutimport XMonad.Layout.ComboPimport XMonad.Layout.Gridimport XMonad.Layout.LayoutHintsimport XMonad.Layout.Namedimport XMonad.Layout.NoBordersimport XMonad.Layout.PerWorkspaceimport XMonad.Layout.ResizableTileimport XMonad.Layout.ShowWNameimport XMonad.Layout.ToggleLayoutsimport XMonad.Layout.TwoPaneimport XMonad.Promptimport XMonad.Prompt.AppendFileimport XMonad.Prompt.Manimport XMonad.Prompt.RunOrRaiseimport XMonad.Prompt.Shellimport XMonad.Prompt.Sshimport XMonad.Prompt.Windowimport XMonad.Util.EZConfigimport XMonad.Util.NamedScratchpadimport XMonad.Util.Run (runInTerm, spawnPipe)import XMonad.Util.WindowPropertiesimport XMonad.Util.WorkspaceCompareimport qualified XMonad.Actions.Search   as Simport qualified XMonad.Layout.Magnifier as Magimport qualified XMonad.StackSet         as Wmain = 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` myKeysmyManageHook = composeAll      [ className =? "MPlayer"          --> doFloat       -- place the following in the floating layer --      , className =? "Smplayer"         --> doFloat       --      , className =? "feh"              --> 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"doShiftAndGo :: WorkspaceId -> ManageHookdoShiftAndGo ws = doF (W.greedyView ws) <+> doShift wsmyLayoutHook = avoidStruts            $      smartBorders                    $      toggleLayouts Full              $ -- toggle Full layout with the current layout; on the focused window --      layoutHints                     $      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 "#ffffff" "" . wrap "[" "]" -- highlight the current workspace with the specified colors["fg" "bg"]      , 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 "#000000" "#00ffff" -- highlight urgent workspaces 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      }myGSConfig      = defaultGSConfig { gs_font = "xft:DejaVu Sans Mono:pixelsize=11:antialias=true" }myModMask       = mod4MaskmySpawnList     = ["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", "2", "3", "4", "5", "6", "7", "8", "9", "NSP"]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"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 o", spawn            "monitor-standby.sh"                                               )      , ("M-m p", runOrRaiseMaster "smplayer"         (className =? "Smplayer"                       ))      , ("M-m a", raiseMaybe  (runInTerm "-title mail"   "screen -raAd mail")   (title =? "mail"     )) -- reattach to sessionName 'mail' in the current workspace or if already attached focus it --      , ("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 focus it --      , ("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 m", runOrRaiseMaster "midori"           (className =? "Midori"                         ))      , ("M-x s", raiseMaybe  (runInTerm "-title screen" "screen -raAd screen") (title =? "screen"   )) -- reattach to sessionname 'screen' in the current workspace or if already attached focus it --      , ("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-<Backspace>", removeWorkspace                                                           ) -- remove the current workspace --      -- multimedia: volume - alsa --      , ("<XF86AudioMute>",        spawn "amixer -q set Master toggle"                                ) -- mute/unmute --      , ("<XF86AudioLowerVolume>", spawn "amixer -q set Master 1- unmute"                             ) -- unmute and lowerVolume --      , ("<XF86AudioRaiseVolume>", 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 w", gridselectWorkspace myGSConfig W.greedyView                                         ) -- select a workspace and view it using the given function --      , ("M-g m", gridselectWorkspace myGSConfig (\ws -> W.greedyView ws . W.shift ws                )) -- move and follow the focused window to the selected workspace --      , ("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-<L>", windows . W.greedyView =<< findWorkspace getSortByIndexNoNSP Prev EmptyWS 1       ) -- focus [previous] NonEmpty workspace --      , ("M-C-<R>", 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-<L>", windows . W.shift =<< findWorkspace getSortByIndexNoNSP Prev EmptyWS 1            ) -- move window to [previous] NonEmpty workspace --      , ("M-S-<R>", 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 window's to you --      , ("M-S-g", windowPromptGoto  myXPConfig                                                        ) -- ""         "" takes you to window's --      , ("M-S-h", sshPrompt         myXPConfig                                                        ) -- a ssh prompt --      , ("M-S-m", manPrompt         myXPConfig                                                        ) -- a man page prompt --      , ("M-S-p", shellPrompt       myXPConfig                                                        ) -- a shell prompt --            , ("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-<Page_Up>",   sendMessage Mag.MagnifyMore                                               ) -- magnify [more] the current window in a Magnfiier Layout --      , ("M-C-<Page_Down>", sendMessage Mag.MagnifyLess                                               ) --         [less]                                          --      -- screenshots --      , ("<Print>",   spawn "scrot -e 'mv $f /tmp/'"                                                  ) -- take a full screenshot; save 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; saved in /tmp/ --      ] -- end of regular keybindings --      -- M-S-#: move and follow the focused window to a workspace listed in myWorkSpaces --      ++ [("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 ]      -- skip NSP workspace when using CycleWS --      where notNSP  = (return $ ("NSP" /=) . W.tag) :: X (WindowSpace -> Bool)getSortByIndexNoNSP = fmap (.namedScratchpadFilterOutWorkspace) getSortByIndex      -- search engines/list --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=")      ]