Created
October 27, 2014 10:19
-
-
Save zampino/600b55d7573db8192d68 to your computer and use it in GitHub Desktop.
~/.xmonad/xmonad.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- === MODULE SECTION === | |
import XMonad | |
-- import XMonad.Config.Gnome | |
import qualified XMonad.StackSet as W | |
import XMonad.Util.EZConfig (additionalKeys) | |
import qualified Data.Map as M | |
import XMonad.Hooks.DynamicLog | |
import XMonad.Prompt | |
import XMonad.Prompt.Shell | |
import System.Exit | |
import XMonad.Layout.NoBorders | |
import XMonad.Layout.ResizableTile | |
import XMonad.Layout.Reflect | |
import XMonad.Layout.IM | |
import XMonad.Layout.Tabbed | |
import XMonad.Layout.PerWorkspace (onWorkspace) | |
import XMonad.Layout.Grid | |
import XMonad.Layout.Named | |
-- Actions | |
import XMonad.Actions.TagWindows -- window tagging | |
import XMonad.Actions.CycleWS -- switch to next screen | |
import XMonad.Actions.FindEmptyWorkspace | |
import XMonad.Actions.GridSelect | |
import XMonad.Actions.GridSelect | |
import XMonad.Actions.PhysicalScreens | |
-- Data.Ratio for IM layout | |
import Data.Ratio ((%)) | |
import Data.List (isInfixOf) | |
-- ewmh | |
import XMonad.Hooks.EwmhDesktops | |
-- avoidStruts | |
import XMonad.Hooks.ManageDocks | |
-- urgency hooks | |
import XMonad.Hooks.UrgencyHook | |
-- hGetChar, hGetContents, hGetLine, hPrint, hPutChar, hPutStr: | |
import System.IO | |
-- runOrRais (thunderbird) | |
import XMonad.Prompt.RunOrRaise | |
import XMonad.Util.Run(spawnPipe) | |
-- startupHook | |
import XMonad.Hooks.SetWMName | |
import Data.Monoid | |
import qualified Data.Map as M | |
import XMonad.Prompt | |
import XMonad.Prompt.Window | |
import Control.Monad | |
-- === Keyconfiguration & -bindings (Begin of variable section) | |
-- which Modkey to use. (1-leftAlt; 3-rightAlt; 4-windoof) | |
myModMask = mod4Mask | |
-- Whether focus follows the mouse pointer. | |
myFocusFollowsMouse :: Bool | |
myFocusFollowsMouse = False | |
-- Key bindings. Add, modify or remove key bindings here. | |
myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $ | |
-- === Launch applications | |
-- launch a terminal | |
[ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf) | |
-- launch dmenu application starter | |
-- , ((modm, xK_p ), spawn "gmrun") | |
, ((modm, xK_p ), spawn "exe=`dmenu_path | dmenu -b -nb white` && eval \"exec $exe\"") | |
-- spawn xscreensaver to lock screen and disable monitor to reduce power consumption | |
, ((modm, xK_y ), spawn "xscreensaver-command -lock && xset dpms force off") | |
-- spawn keybind cheatsheet with leafpad | |
, ((modm, xK_m ), spawn "leafpad $HOME/.config/panorama3000/keybinds.txt") | |
-- spawn password manager (??) | |
--, ((modm xK_? ), spawn "xfce4-terminal $HOME/.config/panorama3000/shell.rb") | |
, ((modm .|. shiftMask, xK_F11 ), spawn "sudo /sbin/shutdown") | |
-- = process windows = | |
-- close focused window | |
, ((modm, xK_c ), kill) | |
-- Resize viewed windows to the correct size | |
, ((modm, xK_r ), refresh) | |
-- Move focus to the next window | |
, ((modm, xK_Tab ), windows W.focusDown) | |
-- Move focus to the previous window | |
--, ((modm, xK_k ), windows W.focusUp ) | |
-- Swap the focused window with the next window | |
, ((modm .|. shiftMask, xK_j ), windows W.swapDown ) | |
-- Swap the focused window with the previous window | |
, ((modm .|. shiftMask, xK_k ), windows W.swapUp ) | |
-- Shrink the master area | |
, ((modm, xK_h ), sendMessage Shrink) | |
-- Expand the master area | |
, ((modm, xK_l ), sendMessage Expand) | |
-- Push window back into tiling | |
, ((modm, xK_t ), withFocused $ windows . W.sink) | |
-- Michas cool 'find the window' thing :) | |
, ((modm, xK_g ), goToSelected defaultGSConfig) | |
-- = configure layouts = | |
-- 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) | |
-- = strange stuff = | |
-- 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) | |
-- = basic xmonad related = | |
-- Quit xmonad | |
, ((modm .|. shiftMask, xK_q ), io (exitWith ExitSuccess)) | |
-- Restart xmonad | |
, ((modm , xK_q ), spawn "xmonad --recompile; xmonad --restart") | |
] | |
++ | |
-- = windows in relation to workspaces = | |
-- mod-[1..9], Switch to workspace N | |
-- mod-shift-[1..9], Move client to workspace N | |
-- | |
[((m .|. modm, k), windows $ f i) | |
| (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9] | |
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]] | |
++ | |
-- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3 | |
-- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3 | |
-- | |
[((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f)) | |
| (key, sc) <- zip [xK_w, xK_e, xK_r] [0..] | |
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]] | |
-- = mouse bindings = | |
-- default actions bound to mouse events | |
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)) | |
-- you may also bind events to the mouse scroll wheel (button4 and button5) | |
] | |
-- == end of keybinds == | |
-- ==== VARIABLE SECTION ==== | |
-- == manage windows in relation to workspaces == | |
-- To find the property name associated with a program, use | |
-- > xprop | grep WM_CLASS | |
-- To match on the WM_NAME, you can use 'title' in the same way that | |
-- 'className' and 'resource' are used below. | |
myManageHook = composeAll | |
[ className =? "XChromium" --> doF (W.shift "9") | |
-- , className =? "Xchat" --> doF (W.shift "1chat") | |
-- , className =? "Pidgin" --> doF (W.shift "8") | |
-- , className =? "Skype" --> doF (W.shift "1chat")] <+> manageDocks | |
, resource =? "kdesktop" --> doIgnore ] | |
-- = applications = | |
-- which terminal to use by keybind | |
myTerminal = "gnome-terminal" | |
-- == cosmetics == | |
-- Width of the window border in pixels. | |
myBorderWidth = 2 | |
-- color of window boarders | |
myNormalBorderColor = "#FFFFFF" | |
myFocusedBorderColor = "#62B1E1" | |
-- names of workspaces | |
myWorkspaces = ["1","2","3","4","5","6","7","8","9"] | |
-- == LAYOUTS == | |
myLayoutHook = named "Tabs" (tabbed shrinkText defaultTheme) ||| Tall 1 (1/20) (1/2) ||| Mirror (Tall 1 (1/20) (1/2)) ||| Grid ||| reflectHoriz (Tall 1 (1/20) (1/2)) | |
-- onWorkspace "2chat" Tall $ -- layout Tall will be used on workspace "2chat". ??? | |
-- = pretty printing format = | |
myPP = defaultPP { | |
ppCurrent = xmobarColor "blue" "" . wrap "[" "]" | |
, ppVisible = wrap "(" ")" | |
, ppUrgent = xmobarColor "red" "yellow" | |
, ppTitle = xmobarColor "blue" "" . shorten 40 | |
-- , ppSep = xmobarColor "green" "" . wrap " "" " | |
} | |
-- ==== MAIN SECTION ==== | |
--MyStatusBar = "bash ~/scripts/dzen/fourth.sh | dzen2 -y 1034 -ta l -fg black -bg white -h 15 " | |
-- main = xmonad defaults | |
main = do | |
g <- spawnPipe "xmobar ~/.xmobar/xmobarrc_top" | |
xmonad $ defaultConfig { | |
-- simple stuff | |
terminal = myTerminal, | |
focusFollowsMouse = myFocusFollowsMouse, | |
borderWidth = myBorderWidth, | |
modMask = myModMask, | |
workspaces = myWorkspaces, | |
normalBorderColor = myNormalBorderColor, | |
focusedBorderColor = myFocusedBorderColor, | |
-- key bindings | |
keys = myKeys, | |
mouseBindings = myMouseBindings, | |
manageHook = manageDocks <+> myManageHook, | |
layoutHook = smartBorders $ avoidStruts $ myLayoutHook, | |
logHook = ( dynamicLogWithPP $ myPP { ppOutput = hPutStrLn g } ), | |
handleEventHook = dockHack | |
} | |
dockHack :: Event -> X All | |
dockHack (ConfigureEvent {}) = dockHack' | |
dockHack (MapNotifyEvent {}) = dockHack' | |
dockHack (UnmapEvent {}) = dockHack' | |
dockHack (DestroyWindowEvent {}) = dockHack' | |
dockHack _ = return (All True) | |
dockHack' :: X All | |
dockHack' = withDisplay $ \d -> do | |
r <- asks theRoot | |
wM_WINDOW_TYPE <- getAtom "_NET_WM_WINDOW_TYPE" | |
wM_WINDOW_DOCK <- fromIntegral `fmap` getAtom "_NET_WM_WINDOW_TYPE_DOCK" | |
io $ do | |
(_,_,ws) <- queryTree d r | |
forM_ ws $ \w -> do | |
p <- getWindowProperty32 d w wM_WINDOW_TYPE | |
case p of | |
Nothing -> return () | |
Just ps -> forM_ ps $ \p -> when (p == wM_WINDOW_DOCK) $ raiseWindow d w | |
return (All True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment