Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
xmonad with urgency hooks
import System.IO
import Data.Ratio
import Control.Monad (liftM2)
import XMonad
-- import XMonad.Config.Gnome
import Data.Monoid
import System.Exit
import XMonad.Actions.CycleWS
import XMonad.Actions.FloatKeys
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.InsertPosition
import XMonad.Hooks.ManageDocks
-- import XMonad.Hooks.EwmhDesktops
-- import XMonad.Hooks.ManageHelpers
-- import XMonad.Hooks.SetWMName
import XMonad.Hooks.UrgencyHook
-- import XMonad.Layout
import XMonad.Layout.Grid
import XMonad.Layout.Reflect
-- import XMonad.Layout.CenteredMaster
import XMonad.Layout.Accordion
-- import XMonad.Layout.Circle
import XMonad.Layout.Tabbed
-- import XMonad.Layout.Spiral
-- import XMonad.Layout.IM
-- import XMonad.Layout.NoBorders
import XMonad.Layout.PerWorkspace
-- import XMonad.Layout.ResizableTile
-- import XMonad.Layout.StackTile
-- import XMonad.Config.Desktop
import qualified XMonad.StackSet as W
import XMonad.Util.Run(spawnPipe)
-- import XMonad.Util.EZConfig(additionalKeys)
import qualified Data.Map as M
-- The preferred terminal program, which is used in a binding below and by
-- certain contrib modules.
--
myTerminal :: String
myTerminal = "terminator"
-- Whether focus follows the mouse pointer.
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = False
-- Width of the window border in pixels.
myBorderWidth :: Dimension
myBorderWidth = 3
-- modMask lets you specify which modkey you want to use. The default
-- is mod1Mask ("left alt"). You may also consider using mod3Mask
-- ("right alt"), which does not conflict with emacs keybindings. The
-- "windows key" is usually mod4Mask.
--
-- myModMask = mod4Mask
myModMask :: KeyMask
myModMask = mod1Mask
-- The default number of workspaces (virtual screens) and their names.
-- By default we use numeric strings, but any string may be used as a
-- workspace name. The number of workspaces is determined by the length
-- of this list.
--
-- A tagging example:
--
-- > workspaces = ["web", "irc", "code" ] ++ map show [4..9]
--
myWorkspaces :: [String]
myWorkspaces = [ "^ vim"
, "1 /"
, "2 pdf"
, "3 web"
, "4 twit"
, "5 radio"
, "6 mail"
, "7 irc"
, "8 grphx"
, "9 misc"
, "0 emacs"
]
-- Border colors for unfocused and focused windows, respectively.
myNormalBorderColor :: String
myNormalBorderColor = "#000000"
myFocusedBorderColor :: String
myFocusedBorderColor = "#ffa71a" -- Day[9]'s yellow :-)
------------------------------------------------------------------------
-- Key bindings. Add, modify or remove key bindings here.
--
myKeys :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
-- launch a terminal/dmenu/gmrun
[ ((modm, xK_F1 ), spawn $ XMonad.terminal conf)
, ((mod4Mask, xK_F1 ), spawn "gvim")
, ((modm, xK_F2 ), spawn "exe=`dmenu_path | dmenu` && eval \"exec $exe\"")
, ((mod4Mask, xK_F2 ), spawn "emacs")
, ((modm, xK_F3 ), spawn "gmrun")
-- close focused window
, ((modm, xK_F4 ), kill)
, ((modm .|. shiftMask, xK_c ), kill)
-- Rotate through the available layout algorithms
, ((modm, xK_space ), sendMessage NextLayout)
-- Reset the layouts on the current workspace to default
, ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
-- on laptop disabling the touchpad is quite handy
, ((mod4Mask , xK_space ), spawn "synclient TouchpadOff=$(synclient -l | grep -c 'TouchpadOff.*=.*0')")
-- -- Resize viewed windows to the correct size
-- , ((modm, xK_n ), refresh)
-- Move focus to the next/previous window
, ((modm, xK_Tab ), windows W.focusDown)
, ((modm .|. shiftMask, xK_Tab ), windows W.focusUp)
-- Move window to the next/previous position
, ((mod4Mask, xK_Tab ), windows W.swapDown)
, ((mod4Mask .|. shiftMask, xK_Tab ), windows W.swapUp)
-- Move focus to the master window
, ((modm, xK_m ), windows W.focusMaster )
-- Swap the focused window and the master window
-- , ((modm, xK_u ), windows W.swapMaster)
-- Swap the focused window and the master window
, ((modm, xK_Return ), windows W.swapMaster)
, ((modm, xK_Escape ), windows W.swapMaster)
-- -- Swap the focused window with the next window
-- , ((modm .|. shiftMask, xK_i ), windows W.swapDown )
--
-- -- Swap the focused window with the previous window
-- , ((modm .|. shiftMask, xK_a ), windows W.swapUp )
-- Shrink/Expand the master area
, ((modm, xK_comma ), sendMessage Shrink)
, ((modm, xK_period ), sendMessage Expand)
-- Push window back into tiling
, ((modm, xK_j ), withFocused $ windows . W.sink)
, ((modm .|. shiftMask, xK_Left ), withFocused $ keysMoveWindow (-10,0))
, ((modm .|. shiftMask, xK_Up ), withFocused $ keysMoveWindow (0,-10))
, ((modm .|. shiftMask, xK_Right ), withFocused $ keysMoveWindow (10,0))
, ((modm .|. shiftMask, xK_Down ), withFocused $ keysMoveWindow (0,10))
, ((mod4Mask.|. shiftMask, xK_Left ), withFocused $ keysResizeWindow (-10,0) (1%2,1%2))
, ((mod4Mask.|. shiftMask, xK_Up ), withFocused $ keysResizeWindow (0 ,-10) (1%2,1%2))
, ((mod4Mask.|. shiftMask, xK_Right ), withFocused $ keysResizeWindow (10 ,0) (1%2,1%2))
, ((mod4Mask.|. shiftMask, xK_Down ), withFocused $ keysResizeWindow (0 ,20) (1%2,1%2))
-- , ((modm, xK_J ), withFocused $ \w -> focus w >> mouseResizeWindow w
-- >> windows W.shiftMaster)
, ((mod4Mask , xK_x ), focusUrgent)
-- De/Increment the number of windows in the master area
, ((modm .|. shiftMask, xK_comma ), sendMessage (IncMasterN 1))
, ((modm .|. shiftMask, xK_period ), sendMessage (IncMasterN (-1)))
-- Toggle the status bar gap
-- Use this binding with avoidStruts from Hooks.ManageDocks.
-- See also the statusBar function from Hooks.DynamicLog.
--
-- , ((modm , xK_b ), sendMessage ToggleStruts)
-- Quit xmonad
, ((modm .|. shiftMask , xK_F5 ), io exitSuccess)
-- , ((modm .|. shiftMask , xK_F5 ), spawn "gnome-session-save --gui --kill")
-- Restart xmonad
, ((modm , xK_F5 ), spawn "xmonad --recompile; xmonad --restart")
-- Screensaver
, ((mod4Mask , xK_l ), spawn "xscreensaver-command -lock")
-- VolumeControl
-- , ((mod4Mask , xK_v ), spawn "xfce4-mixer")
-- FileManager
, ((mod4Mask , xK_f ), spawn "pcmanfm")
, ((mod4Mask .|. shiftMask, xK_p ), spawn "evince")
, ((mod4Mask , xK_p ), spawn "okular")
-- Opera
, ((mod4Mask , xK_w ), spawn "opera")
, ((mod4Mask .|. shiftMask, xK_w ), spawn "opera-next")
-- make ScreenPicture in .2 seconds
, ((controlMask , xK_Print), spawn "sleep 0.2; scrot -s")
-- make ScreenPicture NOW
, ((0 , xK_Print), spawn "scrot")
-- Special Keys
--
-- XF68XK_AudioMute
, ((0 , 0x1008FF12), spawn "amixer -q set Master toggle")
, ((shiftMask , 0x1008FF12), spawn "amixer -q set Front toggle; amixer -q set Side toggle; amixer -q set Surround toggle")
--
-- -- playpause/previous/next Track
, ((mod4Mask , 0x1008FF14), spawn "banshee --toggle-playing")
, ((mod4Mask , 0x1008FF11), spawn "banshee --restart-or-previous")
, ((mod4Mask , 0x1008FF13), spawn "banshee --next")
, ((0 , 0x1008FF14), spawn "rhythmbox-client --play-pause")
, ((shiftMask , 0x1008FF11), spawn "rhythmbox-client --previous")
, ((shiftMask , 0x1008FF13), spawn "rhythmbox-client --next")
--
-- -- XF68XK_Audio[Lower/Raise]Volume
, ((0 , 0x1008FF11), spawn "amixer -q set Master 5%- unmute")
, ((0 , 0x1008FF13), spawn "amixer -q set Master 5%+ unmute")
-- XF68XK_Calculator
, ((0 , 0x1008ff1d), spawn "gvim")
-- XF68XK_Calculator
, ((shiftMask , 0x1008ff1d), spawn "gcalctool")
]
++
-- mod-[1..9], Switch to workspace N
-- mod4-[1..9], Move client to workspace N
--
[((0 .|. m, k), windows $ f i)
| (i, k) <- zip (XMonad.workspaces conf) ([0xFE52]++[xK_1 .. xK_9]++[xK_0])
, (f, m) <- [(W.greedyView, modm), (W.shift, mod4Mask)]]
++
-- mod-{1,2,3}, Switch to physical/Xinerama screens 1, 2, or 3
-- mod-shift-{1,2,3}, Move client to screen 1, 2, or 3
--
[((shiftMask .|. m, key), screenWorkspace sc >>= flip whenJust (windows . f))
| (key, sc) <- zip [xK_1, xK_2, xK_3] [0..]
, (f, m) <- [(W.view, modm), (W.shift, mod4Mask)]]
------------------------------------------------------------------------
-- Mouse bindings: default actions bound to mouse events
--
myMouseBindings :: XConfig t -> M.Map (KeyMask, Button) (Window -> X ())
myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList
-- mod-button1, Set the window to floating mode and move by dragging
[ ((modm, button1), \w -> focus w >> mouseMoveWindow w
>> windows W.shiftMaster)
-- mod-button2, Raise the window to the top of the stack
, ((modm, button2), \w -> focus w >> windows W.shiftMaster)
-- mod-button3, Set the window to floating mode and resize by dragging
, ((modm, button3), \w -> focus w >> mouseResizeWindow w
>> windows W.shiftMaster)
, ((modm, button4), \w -> focus w >> prevWS)
, ((modm, button5), \w -> focus w >> nextWS)
, ((shiftMask.|. modm , button4), \w -> focus w >> shiftToNext)
, ((shiftMask.|. modm , button5), \w -> focus w >> shiftToPrev)
, ((mod4Mask, button4), \w -> focus w >> windows W.focusUp)
, ((mod4Mask, button5), \w -> focus w >> windows W.focusDown)
-- you may also bind events to the mouse scroll wheel (button4 and button5)
]
------------------------------------------------------------------------
-- Layouts:
-- You can specify and transform your layouts by modifying these values.
-- If you change layout bindings be sure to use 'mod-shift-space' after
-- restarting (with 'mod-q') to reset your layout state to the new
-- defaults, as xmonad preserves your old layout settings by default.
--
-- The available layouts. Note that each layout is separated by |||,
-- which denotes layout choice.
myLayout = onWorkspaces ["2 pdf", "5 radio"] (
avoidStruts ( reflectHoriz tiled
||| reflectHoriz Grid
||| simpleTabbed )) $
avoidStruts ( reflectHoriz tiled
||| reflectHoriz Grid
||| reflectHoriz (Mirror Accordion)
||| Accordion
||| simpleTabbed)
where
-- default tiling algorithm partitions the screen into two panes
tiled = Tall nmaster delta ratio
-- The default number of windows in the master pane
nmaster = 1
-- Default proportion of screen occupied by master pane
ratio = 1/2
-- Percent of screen to increment by when resizing panes
delta = 1/100
------------------------------------------------------------------------
-- Window rules:
-- Execute arbitrary actions and WindowSet manipulations when managing
-- a new window. You can use this to, for example, always float a
-- particular program, or have a client always appear on a particular
-- workspace.
--
-- To find the property name associated with a program, use
-- > xprop | grep WM_CLASS
-- and click on the client you're interested in.
--
-- To match on the WM_NAME, you can use 'title' in the same way that
-- 'className' and 'resource' are used below.
--
myManageHook :: Query (Endo WindowSet)
myManageHook = composeAll
[ className =? "Ardour2" --> doFloat
, className =? "Banshee" --> doShift "5 radio"
, className =? "banshee" --> doShift "5 radio"
, className =? "Chromium-browser" --> doShift "3 web"
, resource =? "desktop_window" --> doIgnore
, className =? "Emacs" --> doShift "0 emacs"
, className =? "Evince" --> doShift "2 pdf"
, className =? "Exe" --> doFloat
, className =? "Gimp-2.6" --> doShift "8 grphx" <+> doFloat
, className =? "Gimp" --> doShift "8 grphx" <+> doFloat
, className =? "Gpodder" --> doFloat
, className =? "Guake" --> doFloat
, className =? "Gvim" --> viewShift "^ vim"
, className =? "Hotot" --> doShift "4 twit"
, className =? "Icedove" --> doShift "6 mail"
, className =? "Inkscape" --> doShift "8 grphx"
, resource =? "kdesktop" --> doIgnore
, className =? "Okular" --> doShift "2 pdf"
, className =? "Opera" --> doShift "3 web"
, className =? "OperaNext" --> doShift "3 web"
, className =? "Operapluginwrapper" --> doFloat
, className =? "operapluginwrapper-native" --> doFloat
, className =? "Operapluginwrapper-native" --> doFloat
, className =? "Pidgin" --> doShift "7 irc" <+> doFloat
, className =? "Plugin-container" --> doFloat
, className =? "Qjackctl.real" --> doFloat
, className =? "Qt Jambi application" --> doFloat
, className =? "Rhythmbox" --> doShift "5 radio"
, className =? "Skype" --> doFloat
, className =? "Transmission-gtk" --> doFloat
, className =? "Volumeicon" --> doFloat
, className =? "W" --> doFloat
, className =? "Xfce4-mixer" --> doFloat
, className =? "Xpdf" --> doShift "2 pdf"
, title =? "Copying Files" --> doFloat ]
where viewShift = doF . liftM2 (.) W.greedyView W.shift
------------------------------------------------------------------------
-- Event handling
-- * EwmhDesktops users should change this to ewmhDesktopsEventHook
--
-- Defines a custom handler function for X Events. The function should
-- return (All True) if the default handler is to be run afterwards. To
-- combine event hooks use mappend or mconcat from Data.Monoid.
--
myEventHook :: Event -> X All
myEventHook = mempty
------------------------------------------------------------------------
-- Status bars and logging
-- Perform an arbitrary action on each internal state change or X event.
-- See the 'XMonad.Hooks.DynamicLog' extension for examples.
-- rmalBorderColor :: [Char]
--
-- myLogHook = dynamicLogWithPP dzenPP
myLogHook :: Handle -> X ()
myLogHook dest = dynamicLogWithPP defaultPP { ppOutput = hPutStrLn dest,
ppVisible = wrap "(" ")"
}
------------------------------------------------------------------------
-- Startup hook
-- Perform an arbitrary action each time xmonad starts or is restarted
-- with mod-q. Used by, e.g., XMonad.Layout.PerWorkspace to initialize
-- per-workspace layout choices.
--
-- By default, do nothing.
myStartupHook :: X ()
myStartupHook = return ()
------------------------------------------------------------------------
-- Now run xmonad with all the defaults we set up.
-- Run xmonad with the settings you specify. No need to modify this.
--
main :: IO ()
main = do
xmproc <- spawnPipe "/usr/bin/xmobar"
xmonad $ withUrgencyHook NoUrgencyHook $ defaultConfig {
-- simple stuff
terminal = myTerminal,
focusFollowsMouse = myFocusFollowsMouse,
borderWidth = myBorderWidth,
modMask = myModMask,
workspaces = myWorkspaces,
normalBorderColor = myNormalBorderColor,
focusedBorderColor = myFocusedBorderColor,
-- key and mouse bindings
keys = myKeys,
mouseBindings = myMouseBindings,
-- hooks, layouts
manageHook = manageDocks <+> insertPosition Above Newer
<+> myManageHook,
layoutHook = myLayout,
logHook = myLogHook xmproc,
handleEventHook = myEventHook,
startupHook = myStartupHook
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.