Created
June 21, 2012 16:42
-
-
Save qnikst/2966908 to your computer and use it in GitHub Desktop.
This file contains 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
-- | |
-- xmonad example config file. | |
-- | |
-- A template showing all available configuration hooks, | |
-- and how to override the defaults in your own xmonad.hs conf file. | |
-- | |
-- Normally, you'd only override those defaults you care about. | |
-- | |
import System.Exit | |
import System.IO | |
import XMonad hiding ( (|||) ) | |
import qualified System.IO.UTF8 | |
import Codec.Binary.UTF8.String | |
import XMonad.Hooks.XPropManage | |
-- Layouts | |
-- | |
-- import XMonad | |
import XMonad.Layout.Reflect | |
import XMonad.Layout.Tabbed | |
import XMonad.Layout.LayoutCombinators | |
import XMonad.Layout.WindowNavigation | |
import XMonad.Layout.NoBorders | |
import XMonad.Layout.PerWorkspace | |
import XMonad.Layout.SimpleFloat | |
import XMonad.Layout.Minimize | |
import XMonad.Layout.OneBig | |
import XMonad.Layout.IM | |
import XMonad.Layout.ComboP | |
import XMonad.Layout.Named | |
import XMonad.Layout.ResizableTile | |
import XMonad.Layout.DwmStyle | |
import XMonad.Layout.DragPane | |
import XMonad.Layout.Magnifier | |
-- Layout Additional | |
import XMonad.Layout.Combo | |
import XMonad.Layout.WindowArranger | |
import XMonad.Layout.CenteredMaster | |
import XMonad.Layout.TwoPane | |
import XMonad.Layout.MouseResizableTile | |
import XMonad.Layout.MagicFocus | |
import XMonad.Layout.Spacing | |
-- Layout Experimental | |
import XMonad.Layout.Column | |
import XMonad.Layout.Grid | |
-- Prompt | |
import XMonad.Prompt | |
import XMonad.Prompt.Man | |
import XMonad.Prompt.Shell | |
import XMonad.Prompt.Ssh | |
import XMonad.Prompt.Window | |
import XMonad.Prompt.XMonad | |
-- Util | |
import XMonad.Util.Themes | |
import XMonad.Util.EZConfig | |
import XMonad.Util.Run (spawnPipe) | |
import XMonad.Util.WorkspaceCompare | |
import XMonad.Util.WindowProperties (getProp32s) | |
import XMonad.Util.NamedScratchpad | |
-- Actions | |
import XMonad.Actions.CycleWS | |
import XMonad.Actions.CycleRecentWS | |
import XMonad.Actions.DwmPromote | |
import XMonad.Actions.Warp | |
import XMonad.Actions.FocusNth | |
import XMonad.Actions.MouseResize --Not found | |
import XMonad.Actions.Promote | |
import XMonad.Actions.WindowGo | |
-- Actions test | |
import XMonad.Actions.Commands -- TODO: use custom commands 2010-12 upto 2011 | |
import XMonad.Actions.GridSelect -- TODO: use grid for selecting smth 2010-12 upto 2011 | |
--Hooks | |
import XMonad.Hooks.SetWMName | |
import XMonad.Hooks.DynamicLog | |
import XMonad.Hooks.ManageDocks | |
import XMonad.Hooks.EwmhDesktops | |
import XMonad.Hooks.UrgencyHook | |
import XMonad.Hooks.ManageHelpers | |
import XMonad.Hooks.ICCCMFocus | |
import qualified XMonad.StackSet as W | |
import qualified Data.Map as M | |
--Types | |
import Foreign.C.Types(CLong) | |
import Control.Monad | |
import Data.Ratio | |
import Data.Char | |
import Data.Maybe | |
import Data.List | |
import Graphics.X11.Xlib.Extras | |
import Graphics.X11.ExtraTypes.XF86 | |
import DBus.Client.Simple | |
import System.Taffybar.XMonadLog (dbusLog) | |
-- The preferred terminal program, which is used in a binding below and by | |
-- certain contrib modules. | |
-- | |
myTerminal = "urxvtc" | |
-- Width of the window border in pixels. | |
-- | |
myBorderWidth = 1 | |
-- 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 | |
-- The mask for the numlock key. Numlock status is "masked" from the | |
-- current modifier status, so the keybindings will work with numlock on or | |
-- off. You may need to change this on some systems. | |
-- | |
-- You can find the numlock modifier by running "xmodmap" and looking for a | |
-- modifier with Num_Lock bound to it: | |
-- | |
-- > $ xmodmap | grep Num | |
-- > mod2 Num_Lock (0x4d) | |
-- | |
-- Set numlockMask = 0 if you don't have a numlock key, or want to treat | |
-- numlock status separately. | |
-- | |
myNumlockMask = mod2Mask | |
-- 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 = ["1:main","2:code","3:web","4:chat","5:experimental"] ++ map show [6..9] | |
-- Border colors for unfocused and focused windows, respectively. | |
-- | |
myNormalBorderColor = "#333000" | |
myFocusedBorderColor = "#fedb73" | |
gridApps :: [String] | |
gridApps = ["urxvtc","firefox","oowriter","dia","netbeans"] | |
------------------------------------------------------------------------ | |
-- Key bindings. Add, modify or remove key bindings here. | |
-- | |
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $ | |
-- launch a terminal | |
[ ((modMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf) | |
-- launch dmenu | |
, ((modMask, xK_p) , spawn "dmenu_run") | |
-- launch gmrun | |
, ((modMask .|. shiftMask, xK_p ), spawn "gmrun") | |
-- close focused window | |
, ((modMask .|. shiftMask, xK_c ), kill) | |
-- Rotate through the available layout algorithms | |
, ((modMask, xK_space ), sendMessage NextLayout) | |
-- Reset the layouts on the current workspace to default | |
, ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf) | |
-- Resize viewed windows to the correct size | |
, ((modMask, xK_n ), refresh) | |
-- Move focus to the next window | |
, ((modMask, xK_Tab ), windows W.focusDown) | |
-- Move focus to the next window | |
, ((modMask, xK_j ), windows W.focusDown) | |
-- Move focus to the previous window | |
, ((modMask, xK_k ), windows W.focusUp ) | |
-- Move focus to the master window | |
--, ((modMask, xK_m ), windows W.focusMaster ) | |
-- Swap the focused window and the master window | |
, ((modMask, xK_Return), windows W.swapMaster) | |
-- Swap the focused window with the next window | |
, ((modMask .|. shiftMask, xK_j ), windows W.swapDown ) | |
-- Swap the focused window with the previous window | |
, ((modMask .|. shiftMask, xK_k ), windows W.swapUp ) | |
-- Shrink the master area | |
, ((modMask, xK_h ), sendMessage Shrink) | |
-- Expand the master area | |
, ((modMask, xK_l ), sendMessage Expand) | |
-- Push window back into tiling | |
, ((modMask, xK_t ), withFocused $ windows . W.sink) | |
-- Increment the number of windows in the master area | |
, ((modMask , xK_comma ), sendMessage (IncMasterN 1)) | |
-- Deincrement the number of windows in the master area | |
, ((modMask , xK_period), sendMessage (IncMasterN (-1))) | |
-- Quit xmonad | |
, ((modMask .|. shiftMask, xK_q ), io (exitWith ExitSuccess)) | |
-- Restart xmonad | |
, ((modMask , xK_q ), restart "xmonad" True) | |
-- Test Actions | |
, ((modMask, xK_Tab), cycleRecentWS [xK_Tab] xK_Tab xK_grave) | |
, ((modMask .|. controlMask, xK_y), commands >>= runCommand) | |
-- Actions.GridSelect | |
, ((modMask, xK_g), goToSelected defaultGSConfig) | |
, ((modMask, xK_s), spawnSelected defaultGSConfig gridApps ) | |
-- Actions minimize | |
-- , ((modMask , xK_m ), withFocused -> (\f -> sendMessage (MinimizeWin f))) | |
-- , ((modMask .|. shiftMask, xK_m ), sendMessage -> RestoreNextMinimizedWin) | |
] | |
++ | |
-- | |
-- mod-[1..9], Switch to workspace N | |
-- mod-shift-[1..9], Move client to workspace N | |
-- | |
[((m .|. modMask, k), windows $ f i) | |
| (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9] | |
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]] | |
++ | |
[ | |
((modMask, xK_F1 ), manPrompt defaultXPConfig) | |
, ((modMask, xK_F2 ), sshPrompt defaultXPConfig) | |
] | |
++ | |
-- | |
-- 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 .|. modMask, 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)]] | |
commands :: X [ (String, X()) ] | |
commands = defaultCommands | |
------------------------------------------------------------------------ | |
-- Mouse bindings: default actions bound to mouse events | |
-- | |
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList | |
-- mod-button1, Set the window to floating mode and move by dragging | |
[ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w)) | |
-- mod-button2, Raise the window to the top of the stack | |
, ((modMask, button2), (\w -> focus w >> windows W.swapMaster)) | |
-- mod-button3, Set the window to floating mode and resize by dragging | |
, ((modMask, button3), (\w -> focus w >> mouseResizeWindow w)) | |
-- you may also bind events to the mouse scroll wheel (button4 and button5) | |
] | |
------------------------------------------------------------------------ | |
-- Layouts: | |
basicLayout = Tall nmaster delta ratio | |
where | |
nmaster = 1 -- the default number of windows in master | |
ratio = 1/2 -- default proportion of screens occupied by master | |
delta = 3/100 -- Percent of screen increment | |
tallLayout = minimize basicLayout | |
-- ^ standard layout | |
fullLayout = noBorders Full | |
-- ^ full screen | |
gridLayout = Grid | |
tabbedLayout = noBorders simpleTabbed | |
imGrid = reflectHoriz $ Tall nmaster delta ratio | |
where | |
nmaster = 1 | |
ratio = 1/8 | |
delta = 3/100 | |
normalLayout = tallLayout ||| fullLayout ||| tabbedLayout | |
------------------------ | |
-- Experimental Layouts | |
magnifierLayout = magnifier Grid | |
oneBigLayout = OneBig (3/4) (3/4) | |
experimentalLayout = gridLayout ||| magnifierLayout ||| oneBigLayout | |
gimpLayout = combineTwoP (TwoPane 0.04 0.82) (tabbedLayout) (Full) (Not (Role "gimp-toolbox")) | |
{- | |
gimpLayout = withIM (254%1280) (Role "gimp-toolbox") $ | |
reflectHoriz $ | |
withIM (276%1280) (Role "gimp-dock") Full | |
-} | |
--myLayout = gaps [(U,14)] $ | |
myLayout = | |
onWorkspace "1:main" ( tallLayout ||| | |
Grid ||| | |
noBorders Full ) $ | |
onWorkspace "4:chat" imGrid $ | |
onWorkspace "2:code" ( tabbedLayout ||| fullLayout ) $ | |
onWorkspace "5:experimental" (experimentalLayout|||gimpLayout){-$-} normalLayout | |
------------------------------------------------------------------------ | |
-- 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 = manageDocks <+> manageMenus <+> manageDialogs <+> composeAll | |
--myManageHook = manageDocks <+> composeAll | |
[ className =? "Firefox" --> doShift "3:web" | |
, className =? "Firefox" <&&> resource =? "Dialog" --> doFloat | |
, className =? "MPlayer" --> doFloat | |
, appName =? "VLC" --> doFullFloat | |
, className =? "Gimp" --> (ask >>= doF . W.sink) --doFloat | |
, resource =? "desktop_window" --> doIgnore | |
, resource =? "kdesktop" --> doIgnore | |
, composeOne [ isFullscreen -?> doFullFloat ] | |
] | |
-- Whether focus follows the mouse pointer. | |
myFocusFollowsMouse :: Bool | |
myFocusFollowsMouse = False -- True | |
------------------------------------------------------------------------ | |
-- 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. | |
-- Fix java problems | |
myStartupHook = setWMName "LG3D" | |
------------------------------------------------------------------------- | |
-- Float all Menus and Dialogs | |
-- --------------------------- | |
-- manage helpers | |
-- | |
manageMenus = checkMenu --> doFloat | |
manageDialogs = checkDialog --> doFloat | |
checkMenu = checkAtom "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_MENU" | |
checkDialog = checkAtom "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DIALOG" | |
checkAtom :: String -> String -> Query Bool | |
checkAtom name value = ask >>= \w -> liftX $ do | |
val <- getAtom value | |
mbr <- getProp32s name w | |
return $ maybe False (\([r]) -> fromIntegral r==val) mbr | |
------------------------------------------------------------------------ | |
-- Now run xmonad with all the defaults we set up. | |
-- Run xmonad with the settings you specify. No need to modify this. | |
-- | |
-- | |
main = do | |
client <- connectSession | |
-- let pp = defaultPP | |
xmonad defaultConfig { | |
-- simple stuff | |
terminal = myTerminal, | |
focusFollowsMouse = myFocusFollowsMouse, | |
borderWidth = myBorderWidth, | |
modMask = myModMask, | |
workspaces = myWorkspaces, | |
normalBorderColor = myNormalBorderColor, | |
focusedBorderColor = myFocusedBorderColor, | |
keys = myKeys, | |
mouseBindings = myMouseBindings, | |
layoutHook = smartBorders ( avoidStruts myLayout ), | |
manageHook = myManageHook, | |
logHook = dbusLog client, | |
startupHook = myStartupHook | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment