All pastes #1938491 Raw Edit

ml|

public text v1 · immutable
#1938491 ·published 2010-09-11 22:18 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.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.Actions.Submap   as SMimport qualified XMonad.Layout.Magnifier as Magimport qualified XMonad.Prompt           as Pimport qualified XMonad.StackSet         as Wmain = do    xmproc <- spawnPipe "xmobar" -- assumes xmobar in $PATH and config in $HOME/.xmobarrc --    xmonad $ withUrgencyHookC NoUrgencyHook myUrgencyConfig $ ewmh defaultConfig      { borderWidth= 1      , manageHook = myManageHook <+> manageDocks <+> manageHook defaultConfig      , layoutHook = myLayoutHook      , logHook    = myLogHook xmproc      , modMask    = mod4Mask      , terminal   = "urxvtc"      , workspaces = myWorkSpaces      } `additionalKeysP` myKeysmyManageHook = namedScratchpadManageHook myScratchPads <+> 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 $      myShowWName          $      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 "GimpL"      $ combineTwoP (TwoPane 0.04 0.86) (Full) (Full) (Not (Role "gimp-toolbox"))            tall = ResizableTall 1 (3/100) (1/2) []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"      , swn_fade    = 2      }myLogHook xmproc  = dynamicLogWithPP xmobarPP      { ppCurrent = \(c) -> [] -- do not show --       , ppHidden  = \(h) -> [] -- ""       "" --       , ppOrder   = \(ws:l:_) -> [l,ws]       -- display 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       -- 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-sync.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-<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 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-<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 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-<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[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-")] ]      -- search; continues below --      ++ [("M-s " ++ k, S.promptSearch myXPConfig f) | (k,f) <- searchList ]      ++ [("M-S-s " ++ k, S.selectSearch f) | (k,f) <- searchList ]      -- skip the NSP workspace while 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. --      , ("e", S.deb                                                                                   ) --      , ("i", S.imdb                                                                                  ) --      , ("o", S.google                                                                                ) --      , ("p", S.debpts                                                                                ) -- M-S-s + * If you select something in whatever application and hit      , ("y", S.wayback                                                                               ) -- mod-shift-s + g/h/w it will search the selected string with the specified engine. --      -- 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="                              )      , ("h", S.searchEngine "isohunt-ssl"    "https://isohunt.com/torrents/?ihq="                                          )      , ("s", S.searchEngine "scroogle-ssl"   "https://ssl.scroogle.org/cgi-bin/nbbwssl.cgi?Gw="                            ) -- 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=") -- $HOME/downloads/xmonad/darcs/XMonadContrib/XMonad/Actions/Search.hs --      , ("w", S.searchEngine "wikipedia-ssl"  "https://secure.wikimedia.org/wikipedia/en/wiki/Special:Search?go=Go&search=" ) -- and/or at the darcs repo:      , ("x", S.searchEngine "tpb-ssl"        "https://thepiratebay.org/search/"                                            ) -- http://code.haskell.org/XMonadContrib/XMonad/Actions/Search.hs --       ]