Skip to content

Instantly share code, notes, and snippets.

@mreschke
Created November 13, 2015 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mreschke/7ee5333943eed99488b9 to your computer and use it in GitHub Desktop.
Save mreschke/7ee5333943eed99488b9 to your computer and use it in GitHub Desktop.
xmonad.hs config file for nice blue xmonad
-------------------------------------------------------------------------------
-- xmonad.hs
-- Taken from default config + Mr.Elendigs file + mReschke Custom Additions
-------------------------------------------------------------------------------
-- Compiler flags --
{-# LANGUAGE NoMonomorphismRestriction #-}
-- Imports --
-- stuff
import XMonad
import Data.Monoid
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import System.Exit
-- actions
import XMonad.Actions.GridSelect
-- hooks
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.UrgencyHook
import XMonad.Hooks.InsertPosition
import XMonad.Hooks.EwmhDesktops
-- layouts
import XMonad.Layout.NoBorders
import XMonad.Layout.ResizableTile
import XMonad.Layout.Named
import XMonad.Layout.Tabbed
import XMonad.Layout.Spiral
--import XMonad.Layout.Dishes
import XMonad.Layout.ThreeColumns
--import XMonad.Layout.ToggleLayouts
import XMonad.Layout.MultiToggle
import XMonad.Layout.MultiToggle.Instances
--import XMonad.Layout.Spacing
--import XMonad.Layout.IndependentScreens
-- The preferred terminal program, which is used in a binding below and by
-- certain contrib modules.
--
myTerminal = "x-terminal-emulator"
-- Whether focus follows the mouse pointer.
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = True
-- Width of the window border in pixels.
--
myBorderWidth = 2
-- 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 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 = ["One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"]
-- Border colors for unfocused and focused windows, respectively.
--
myNormalBorderColor = "#333333"
myFocusedBorderColor = "#58B1DE"
------------------------------------------------------------------------
-- Bar Look
-- Arch dark blue #1793D1
-- Arch middle blue #1893D1
-- Arch light blue #58B1DE
customPP = defaultPP { ppCurrent = xmobarColor "#666666" "" . wrap "<" ">"
, ppHidden = xmobarColor "#1893D1" ""
, ppHiddenNoWindows = xmobarColor "#1793D1" ""
, ppUrgent = xmobarColor "#FFFFAF" "" . wrap "[" "]"
, ppLayout = xmobarColor "#1893D1" ""
, ppTitle = xmobarColor "#1793D1" "" . shorten 80
, ppSep = xmobarColor "#999999" "" " | "
}
-- GridSelect
myGSConfig = defaultGSConfig { gs_cellwidth = 160 }
-- urgent notification
urgentConfig = UrgencyConfig { suppressWhen = Focused, remindWhen = Dont }
------------------------------------------------------------------------
-- tabs
-- , activeColor = "#a6c292"
tabTheme1 = defaultTheme { decoHeight = 16
, activeColor = "#cccccc"
, activeBorderColor = "#a6c292"
, activeTextColor = "#000000"
, inactiveBorderColor = "#000000"
}
------------------------------------------------------------------------
-- Key bindings. Add, modify or remove key bindings here.
--
toggleStrutsKey :: XConfig Layout -> (KeyMask, KeySym)
toggleStrutsKey XConfig {XMonad.modMask = modMask} = (modMask, xK_b)
myKeys :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
-- launching and killing programs
[ ((modMask, xK_Return), spawn $ XMonad.terminal conf)
, ((modMask, xK_d ), spawn "dmenu_run")
, ((modMask .|. shiftMask, xK_r ), spawn "gmrun")
, ((modMask .|. shiftMask, xK_m ), spawn "claws-mail")
, ((modMask .|. shiftMask, xK_c ), kill)
, ((0, xK_Print ), spawn "shutter -s")
, ((mod1Mask, xK_Print ), spawn "sleep 0.2; scrot -s")
-- grid
, ((modMask, xK_g ), goToSelected myGSConfig)
-- layouts
, ((modMask, xK_space ), sendMessage NextLayout)
, ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
--, ((modMask, xK_f ), sendMessage (Toggle "Full"))
--, ((modMask .|. shiftMask, xK_f ), sendMessage ToggleLayout)
--, ((modMask .|. controlMask, xK_space), sendMessage ToggleLayout)
, ((modMask, xK_f ), sendMessage $ Toggle FULL)
-- floating layer stuff
, ((modMask, xK_t ), withFocused $ windows . W.sink)
-- refresh
, ((modMask, xK_n ), refresh)
-- focus
, ((modMask, xK_Tab ), windows W.focusDown)
, ((modMask, xK_j ), windows W.focusDown)
, ((modMask, xK_k ), windows W.focusUp)
, ((modMask, xK_m ), windows W.focusMaster)
-- swapping
, ((modMask .|. shiftMask, xK_Return), windows W.swapMaster)
, ((modMask .|. shiftMask, xK_j ), windows W.swapDown )
, ((modMask .|. shiftMask, xK_k ), windows W.swapUp )
-- increase or decrease number of windows in the master area
, ((modMask , xK_comma ), sendMessage (IncMasterN 1))
, ((modMask , xK_period), sendMessage (IncMasterN (-1)))
-- resizing
, ((modMask, xK_h ), sendMessage Shrink)
, ((modMask, xK_l ), sendMessage Expand)
, ((modMask .|. shiftMask, xK_h ), sendMessage MirrorShrink)
, ((modMask .|. shiftMask, xK_l ), sendMessage MirrorExpand)
-- quit, or restart
, ((modMask .|. shiftMask, xK_o ), io (exitWith ExitSuccess))
, ((modMask , xK_o ), spawn "xmonad --recompile; xmonad --restart")
]
++
-- 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)]]
++
-- mod-[w,e,q] %! switch to twinview screen 1/2/3
-- mod-shift-[w,e,q] %! move window to screen 1/2/3
[((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
| (key, sc) <- zip [xK_q, xK_w, xK_e] [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)
]
------------------------------------------------------------------------
-- 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.
--
-- * NOTE: XMonad.Hooks.EwmhDesktops users must remove the obsolete
-- ewmhDesktopsLayout modifier from layoutHook. It no longer exists.
-- Instead use the 'ewmh' function from that module to modify your
-- defaultConfig as a whole. (See also logHook, handleEventHook, and
-- startupHook ewmh notes.)
--
-- The available layouts. Note that each layout is separated by |||,
-- which denotes layout choice.
--
-- myLayout = tiled ||| Mirror tiled ||| Full
-- 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 = 3/100
-- tab layout
myLayout = tile ||| mtile ||| tc ||| tcm ||| sp ||| tab ||| full
where
rt = ResizableTall 1 (2/100) (1/2) []
tile = named "Tile" $ smartBorders rt
mtile = named "HTile" $ smartBorders $ Mirror rt
tc = named "ThreeCol" $ ThreeCol 1 (3/100) (1/2)
tcm = named "ThreeColMid" $ ThreeColMid 1 (3/100) (1/2)
sp = named "Spiral" $ spiral (6/7)
tab = named "Tab" $ noBorders $ tabbed shrinkText tabTheme1
full = named "Full" $ noBorders Full
------------------------------------------------------------------------
-- 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, the className is the second of
-- the two quoted strings
--
-- To match on the WM_NAME, you can use 'title' in the same way that
-- 'className' and 'resource' are used below.
--
myManageHook = composeAll
[
className =? "MPlayer" --> doFloat
, className =? "Gimp" --> doFloat
, className =? "Vlc" --> doFloat
, className =? "feh" --> doFloat
, className =? "Kcalc" --> doFloat
, className =? "Lxpanel" --> doFloat
, className =? "Komodo Edit" --> doFloat
, className =? "Vncviewer" --> doFloat
, className =? "Namoroka" --> doFloat
, className =? "XCalc" --> doFloat
, className =? "rdesktop" --> unfloat
, className =? "Evolution" --> doFloat
, className =? "Chromium" --> doFloat
, className =? "Thunar" --> doFloat
, className =? "Icedove" --> doFloat
, className =? "Thunderbird" --> doFloat
, className =? "Dolphin" --> doFloat
, className =? "Gwenview" --> doFloat
, className =? "Remmina" --> doFloat
, className =? "Claws-mail" --> doFloat
]
where
unfloat = ask >>= doF . W.sink
-- , resource =? "desktop_window" --> doIgnore
-- , resource =? "kdesktop" --> doIgnore ]
------------------------------------------------------------------------
-- Event handling
-- 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.
--
-- * NOTE: EwmhDesktops users should use the 'ewmh' function from
-- XMonad.Hooks.EwmhDesktops to modify their defaultConfig as a whole.
-- It will add EWMH event handling to your custom event hooks by
-- combining them with ewmhDesktopsEventHook.
--
--myEventHook = mempty
-- Allows chromium to go full screen
-- https://wiki.archlinux.org/index.php/xmonad#Chromium.2FChrome_will_not_go_fullscreen
myEventHook = fullscreenEventHook
------------------------------------------------------------------------
-- Status bars and logging
-- Perform an arbitrary action on each internal state change or X event.
-- See the 'XMonad.Hooks.DynamicLog' extension for examples.
--
-- * NOTE: EwmhDesktops users should use the 'ewmh' function from
-- XMonad.Hooks.EwmhDesktops to modify their defaultConfig as a whole.
-- It will add EWMH logHook actions to your custom log hook by
-- combining it with ewmhDesktopsLogHook.
--
myLogHook = return ()
------------------------------------------------------------------------
-- 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.
--
-- * NOTE: EwmhDesktops users should use the 'ewmh' function from
-- XMonad.Hooks.EwmhDesktops to modify their defaultConfig as a whole.
-- It will add initialization of EWMH support to your custom startup
-- hook by combining it with ewmhDesktopsStartup.
--
myStartupHook = return ()
------------------------------------------------------------------------
-- Now run xmonad with all the defaults we set up.
-- Run xmonad with the settings you specify. No need to modify this.
--q
-- main = xmonad defaults
-- main = xmonad =<< xmobar defaults
main :: IO ()
main = xmonad =<< statusBar cmd pp kb conf
where
uhook = withUrgencyHookC NoUrgencyHook urgentConfig
cmd = "bash -c \"tee >(xmobar -x0) | tee >(xmobar -x1) | tee >(xmobar -x2)\""
pp = customPP
kb = toggleStrutsKey
conf = uhook defaults
-- A structure containing your configuration settings, overriding
-- fields in the default config. Any you don't override, will
-- use the defaults defined in xmonad/XMonad/Config.hs
--
-- No need to modify this.
--
defaults = defaultConfig {
-- simple stuff
terminal = myTerminal,
focusFollowsMouse = myFocusFollowsMouse,
borderWidth = myBorderWidth,
modMask = myModMask,
workspaces = myWorkspaces,
normalBorderColor = myNormalBorderColor,
focusedBorderColor = myFocusedBorderColor,
-- key bindings
keys = myKeys,
mouseBindings = myMouseBindings,
-- hooks, layouts
layoutHook = myLayout,
manageHook = myManageHook,
handleEventHook = myEventHook,
logHook = myLogHook,
startupHook = myStartupHook
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment