https://wiki.haskell.org/index.php?title=Xmonad/Config_archive/Brent_Yorgey%27s_Config.hs&feed=atom&action=history
Xmonad/Config archive/Brent Yorgey's Config.hs - Revision history
2024-03-28T20:14:40Z
Revision history for this page on the wiki
MediaWiki 1.35.5
https://wiki.haskell.org/index.php?title=Xmonad/Config_archive/Brent_Yorgey%27s_Config.hs&diff=16656&oldid=prev
Gwern at 21:56, 6 November 2007
2007-11-06T21:56:39Z
<p></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 21:56, 6 November 2007</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Line 321:</td>
<td colspan="2" class="diff-lineno">Line 321:</td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>urgencyHook = dzenUrgencyHook (7 `seconds`)</div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>urgencyHook = dzenUrgencyHook (7 `seconds`)</div></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></haskell></div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></haskell></div></td>
</tr>
<tr>
<td colspan="2" class="diff-empty"> </td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"></td>
</tr>
<tr>
<td colspan="2" class="diff-empty"> </td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>[[Category:XMonad configuration]]</div></td>
</tr>
<!-- diff cache key wikidb_haskell:diff:wikidiff2:1.12:old-16271:rev-16656:1.10.0 -->
</table>
Gwern
https://wiki.haskell.org/index.php?title=Xmonad/Config_archive/Brent_Yorgey%27s_Config.hs&diff=16271&oldid=prev
Byorgey: my Config.hs
2007-10-23T16:33:42Z
<p>my Config.hs</p>
<p><b>New page</b></p><div><haskell><br />
-----------------------------------------------------------------------------<br />
-- |<br />
-- Module : Config.hs<br />
-- Copyright : (c) Spencer Janssen 2007<br />
-- License : BSD3-style (see LICENSE)<br />
--<br />
-- Maintainer : dons@galois.com<br />
-- Stability : stable<br />
-- Portability : portable<br />
--<br />
-- This module specifies configurable defaults for xmonad. If you change<br />
-- values here, be sure to recompile and restart (mod-q) xmonad,<br />
-- for the changes to take effect.<br />
--<br />
------------------------------------------------------------------------<br />
<br />
module Config where<br />
<br />
--<br />
-- Useful imports<br />
--<br />
import XMonad<br />
import Operations<br />
import qualified StackSet as W<br />
import Data.Ratio<br />
import Data.Bits ((.|.))<br />
import qualified Data.Map as M<br />
import System.Exit<br />
import Graphics.X11.Xlib<br />
<br />
-- % Extension-provided imports<br />
<br />
import XMonadContrib.RotView<br />
import XMonadContrib.ViewPrev<br />
import XMonadContrib.DynamicLog<br />
import XMonadContrib.Spiral<br />
import XMonadContrib.WindowNavigation<br />
import XMonadContrib.NoBorders<br />
import XMonadContrib.ToggleLayouts<br />
<br />
import XMonadContrib.UrgencyHook<br />
import XMonadContrib.Dzen<br />
<br />
import XMonadContrib.Tabbed<br />
import qualified XMonadContrib.FlexibleManipulate as Flex<br />
<br />
-- | The default number of workspaces (virtual screens) and their names.<br />
-- By default we use numeric strings, but any string may be used as a<br />
-- workspace name. The number of workspaces is determined by the length<br />
-- of this list.<br />
--<br />
-- A tagging example:<br />
--<br />
-- > workspaces = ["web", "irc", "code" ] ++ map show [4..9]<br />
--<br />
workspaces :: [WorkspaceId]<br />
workspaces = ["1:web", "2:irc", "3:code", "4:code", "5:ref" ]<br />
++ map show [6 .. 9 :: Int]<br />
<br />
-- | modMask lets you specify which modkey you want to use. The default<br />
-- is mod1Mask ("left alt"). You may also consider using mod3Mask<br />
-- ("right alt"), which does not conflict with emacs keybindings. The<br />
-- "windows key" is usually mod4Mask.<br />
--<br />
modMask :: KeyMask<br />
modMask = mod4Mask<br />
<br />
-- | The mask for the numlock key. Numlock status is "masked" from the<br />
-- current modifier status, so the keybindings will work with numlock on or<br />
-- off. You may need to change this on some systems.<br />
--<br />
-- You can find the numlock modifier by running "xmodmap" and looking for a<br />
-- modifier with Num_Lock bound to it:<br />
--<br />
-- > $ xmodmap | grep Num<br />
-- > mod2 Num_Lock (0x4d)<br />
--<br />
-- Set numlockMask = 0 if you don't have a numlock key, or want to treat<br />
-- numlock status separately.<br />
--<br />
numlockMask :: KeyMask<br />
numlockMask = mod2Mask<br />
<br />
-- | Width of the window border in pixels.<br />
--<br />
borderWidth :: Dimension<br />
borderWidth = 2<br />
<br />
-- | Border colors for unfocused and focused windows, respectively.<br />
--<br />
normalBorderColor, focusedBorderColor :: String<br />
normalBorderColor = "#dddddd"<br />
focusedBorderColor = "#0033ff"<br />
<br />
-- | Default offset of drawable screen boundaries from each physical<br />
-- screen. Anything non-zero here will leave a gap of that many pixels<br />
-- on the given edge, on the that screen. A useful gap at top of screen<br />
-- for a menu bar (e.g. 15)<br />
--<br />
-- An example, to set a top gap on monitor 1, and a gap on the bottom of<br />
-- monitor 2, you'd use a list of geometries like so:<br />
--<br />
-- > defaultGaps = [(18,0,0,0),(0,18,0,0)] -- 2 gaps on 2 monitors<br />
--<br />
-- Fields are: top, bottom, left, right.<br />
--<br />
defaultGaps :: [(Int,Int,Int,Int)]<br />
defaultGaps = [(18,0,0,0)] -- 15 for default dzen font<br />
<br />
------------------------------------------------------------------------<br />
-- Window rules<br />
<br />
-- | Execute arbitrary actions and WindowSet manipulations when managing<br />
-- a new window. You can use this to, for example, always float a<br />
-- particular program, or have a client always appear on a particular<br />
-- workspace.<br />
--<br />
manageHook :: Window -- ^ the new window to manage<br />
-> String -- ^ window title<br />
-> String -- ^ window resource name<br />
-> String -- ^ window resource class<br />
-> X (WindowSet -> WindowSet)<br />
<br />
-- Always float various programs:<br />
manageHook w _ _ c | c `elem` floats = fmap (W.float w . snd) (floatLocation w)<br />
where floats = ["MPlayer", "Gimp", "Volume", "XClock", "Network-admin"]<br />
<br />
-- Desktop panels and dock apps should be ignored by xmonad:<br />
manageHook w _ n _ | n `elem` ignore = reveal w >> return (W.delete w)<br />
where ignore = ["gnome-panel", "desktop_window", "kicker", "kdesktop"]<br />
<br />
-- Automatically send Firefox windows to the "web" workspace:<br />
-- If a workspace named "web" doesn't exist, the window will appear on the<br />
-- current workspace.<br />
-- manageHook _ _ "Gecko" _ = return $ W.shift "1:web"<br />
<br />
-- The default rule: return the WindowSet unmodified. You typically do not<br />
-- want to modify this line.<br />
manageHook _ _ _ _ = return id<br />
<br />
------------------------------------------------------------------------<br />
-- Extensible layouts<br />
<br />
-- | The list of possible layouts. Add your custom layouts to this list.<br />
layouts :: [Layout Window]<br />
layouts = [ Layout tiled<br />
, Layout $ Mirror tiled<br />
-- Add extra layouts you want to use here:<br />
-- % Extension-provided layouts<br />
, Layout $ spiral (3%4)<br />
, Layout $ noBorders $ tabbed shrinkText defaultTConf<br />
]<br />
where<br />
-- default tiling algorithm partitions the screen into two panes<br />
tiled = Tall nmaster delta ratio<br />
<br />
-- The default number of windows in the master pane<br />
nmaster = 1<br />
<br />
-- Default proportion of screen occupied by master pane<br />
ratio = 1%2<br />
<br />
-- Percent of screen to increment by when resizing panes<br />
delta = 3%100<br />
<br />
-- | The top level layout switcher. Most users will not need to modify this binding.<br />
--<br />
-- By default, we simply switch between the layouts listed in `layouts'<br />
-- above, but you may program your own selection behaviour here. Layout<br />
-- transformers, for example, would be hooked in here.<br />
--<br />
layoutHook :: Layout Window<br />
layoutHook = Layout $ withUrgencyHook $<br />
windowNavigation $ <br />
toggleLayouts (noBorders Full) $<br />
Select layouts<br />
<br />
-- | Register with xmonad a list of layouts whose state we can preserve over restarts.<br />
-- There is typically no need to modify this list, the defaults are fine.<br />
--<br />
serialisedLayouts :: [Layout Window]<br />
serialisedLayouts = layoutHook : layouts<br />
<br />
------------------------------------------------------------------------<br />
-- Logging<br />
<br />
-- | Perform an arbitrary action on each internal state change or X event.<br />
-- Examples include:<br />
-- * do nothing<br />
-- * log the state to stdout<br />
--<br />
-- See the 'DynamicLog' extension for examples.<br />
--<br />
logHook :: X ()<br />
logHook = dynamicLogWithPP byorgeyPP<br />
<br />
------------------------------------------------------------------------<br />
-- Key bindings:<br />
<br />
-- | The xmonad key bindings. Add, modify or remove key bindings here.<br />
--<br />
-- (The comment formatting character is used when generating the manpage)<br />
--<br />
keys :: M.Map (KeyMask, KeySym) (X ())<br />
keys = M.fromList $<br />
-- launching and killing programs<br />
[ ((modMask .|. shiftMask, xK_x ), spawn "urxvt-custom") -- %! Launch an xterm<br />
, ((modMask, xK_p ), spawn "exe=`dmenu_path | dmenu` && eval \"exec $exe\"") -- %! Launch dmenu<br />
, ((modMask .|. shiftMask, xK_p ), spawn "gmrun") -- %! Launch gmrun<br />
, ((modMask .|. shiftMask, xK_a ), kill) -- %! Close the focused window<br />
<br />
, ((modMask, xK_space ), sendMessage NextLayout) -- %! Rotate through the available layout algorithms<br />
, ((modMask .|. shiftMask, xK_space ), setLayout layoutHook) -- %! Reset the layouts on the current workspace to default<br />
<br />
, ((modMask, xK_n ), refresh) -- %! Resize viewed windows to the correct size<br />
<br />
-- move focus up or down the window stack<br />
, ((modMask, xK_Tab ), windows W.focusDown) -- %! Move focus to the next window<br />
, ((modMask, xK_j ), windows W.focusDown) -- %! Move focus to the next window<br />
, ((modMask, xK_k ), windows W.focusUp ) -- %! Move focus to the previous window<br />
, ((modMask, xK_m ), windows W.focusMaster ) -- %! Move focus to the master window<br />
<br />
-- modifying the window order<br />
, ((modMask, xK_Return), windows W.swapMaster) -- %! Swap the focused window and the master window<br />
, ((modMask .|. shiftMask, xK_j ), windows W.swapDown ) -- %! Swap the focused window with the next window<br />
, ((modMask .|. shiftMask, xK_k ), windows W.swapUp ) -- %! Swap the focused window with the previous window<br />
<br />
-- resizing the master/slave ratio<br />
, ((modMask, xK_h ), sendMessage Shrink) -- %! Shrink the master area<br />
, ((modMask, xK_l ), sendMessage Expand) -- %! Expand the master area<br />
<br />
-- floating layer support<br />
, ((modMask, xK_t ), withFocused $ windows . W.sink) -- %! Push window back into tiling<br />
<br />
-- increase or decrease number of windows in the master area<br />
, ((modMask , xK_comma ), sendMessage (IncMasterN 1)) -- %! Increment the number of windows in the master area<br />
, ((modMask , xK_period), sendMessage (IncMasterN (-1))) -- %! Deincrement the number of windows in the master area<br />
<br />
-- toggle the status bar gap<br />
, ((modMask , xK_b ), modifyGap (\i n -> let x = (defaultGaps ++ repeat (0,0,0,0)) !! i in if n == x then (0,0,0,0) else x)) -- %! Toggle the status bar gap<br />
<br />
-- quit, or restart<br />
, ((modMask .|. shiftMask, xK_q ), io (exitWith ExitSuccess)) -- %! Quit xmonad<br />
, ((modMask , xK_q ), broadcastMessage ReleaseResources >> restart Nothing True) -- %! Restart xmonad<br />
<br />
-- % Extension-provided key bindings<br />
, ((modMask .|. controlMask, xK_Right), rotView True)<br />
, ((modMask .|. controlMask, xK_Left), rotView False) <br />
<br />
-- switch to previous workspace<br />
, ((modMask, xK_z), viewPrev)<br />
<br />
-- lock the screen with xscreensaver<br />
, ((modMask .|. shiftMask, xK_l), spawn "xscreensaver-command -lock")<br />
<br />
-- some programs to start with keybindings.<br />
, ((modMask .|. shiftMask, xK_f), spawn "firefox")<br />
, ((modMask .|. shiftMask, xK_n), spawn "gksudo network-admin")<br />
, ((modMask .|. shiftMask, xK_c), spawn "xchat")<br />
, ((modMask .|. shiftMask, xK_v), spawn "gnome-volume-control --class=Volume")<br />
, ((modMask .|. shiftMask, xK_t), spawn "xclock")<br />
, ((modMask .|. shiftMask .|. controlMask, xK_t), spawn "xclock -update 1")<br />
<br />
-- window navigation keybindings.<br />
, ((modMask, xK_Right), sendMessage $ Go R)<br />
, ((modMask, xK_Left ), sendMessage $ Go L)<br />
, ((modMask, xK_Up ), sendMessage $ Go U)<br />
, ((modMask, xK_Down ), sendMessage $ Go D)<br />
, ((modMask .|. shiftMask, xK_Right), sendMessage $ Swap R)<br />
, ((modMask .|. shiftMask, xK_Left ), sendMessage $ Swap L)<br />
, ((modMask .|. shiftMask, xK_Up ), sendMessage $ Swap U)<br />
, ((modMask .|. shiftMask, xK_Down ), sendMessage $ Swap D) <br />
<br />
-- toggle to fullscreen.<br />
, ((modMask .|. controlMask, xK_space), sendMessage ToggleLayout)<br />
<br />
]<br />
++<br />
-- mod-[1..9] %! Switch to workspace N<br />
-- mod-shift-[1..9] %! Move client to workspace N<br />
[((m .|. modMask, k), windows $ f i)<br />
| (i, k) <- zip workspaces [xK_1 .. xK_9]<br />
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]<br />
++<br />
-- mod-{w,e,r} %! Switch to physical/Xinerama screens 1, 2, or 3<br />
-- mod-shift-{w,e,r} %! Move client to screen 1, 2, or 3<br />
[((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))<br />
| (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]<br />
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]<br />
<br />
-- % Extension-provided key bindings lists<br />
<br />
-- | Mouse bindings: default actions bound to mouse events<br />
--<br />
mouseBindings :: M.Map (KeyMask, Button) (Window -> X ())<br />
mouseBindings = M.fromList $<br />
-- mod-button1 %! Set the window to floating mode and move by dragging<br />
[ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w))<br />
-- mod-button2 %! Raise the window to the top of the stack<br />
, ((modMask, button2), (\w -> focus w >> windows W.swapMaster))<br />
-- mod-button3 %! Set the window to floating mode and resize by dragging<br />
, ((modMask, button3), (\w -> focus w >> Flex.mouseWindow Flex.linear w))<br />
-- you may also bind events to the mouse scroll wheel (button4 and button5)<br />
<br />
-- % Extension-provided mouse bindings<br />
]<br />
<br />
-- % Extension-provided definitions<br />
<br />
-- define a custom pretty-print mode for DynamicLog<br />
byorgeyPP :: PP<br />
byorgeyPP = defaultPP { ppHiddenNoWindows = \wsId -> if (':' `elem` wsId) then wsId ++ " " else ""<br />
, ppHidden = (++"*")<br />
, ppCurrent = dzenColor "black" "#a8a3f7" . (++"*")<br />
, ppSep = " | "<br />
, ppTitle = shorten 80<br />
, ppOrder = reverse }<br />
<br />
urgencyHook :: Window -> X ()<br />
urgencyHook = dzenUrgencyHook (7 `seconds`)<br />
</haskell></div>
Byorgey