Skip to content

Instantly share code, notes, and snippets.

@rokoucha
Created Nov 23, 2015
Embed
What would you like to do?
Xmonad.hs
-- Modules
import XMonad
import XMonad.Layout
import XMonad.Layout.IM
import XMonad.Layout.Named
import XMonad.Layout.Tabbed
import XMonad.Layout.Spacing -- this makes smart space around windows
import XMonad.Util.EZConfig -- removeKeys, additionalKeys
import XMonad.Util.Run(spawnPipe) -- spawnPipe, hPutStrLn
import XMonad.Layout.Magnifier -- this makes window bigger
import XMonad.Layout.ResizableTile -- Resizable Horizontal border
import XMonad.Layout.ThreeColumns -- for many windows
import Control.Monad (liftM2) -- myManageHookShift
import qualified XMonad.StackSet as W -- myManageHookShift
import System.IO -- for xmobar
import XMonad.Hooks.DynamicLog -- for xmobar
import XMonad.Hooks.ManageDocks -- avoid xmobar area
import XMonad.Hooks.SetWMName
import XMonad.Layout.DragPane -- see only two window
import XMonad.Layout.ToggleLayouts -- Full window at any time
import XMonad.Layout.NoBorders -- In Full mode, border is no use
-- Main
main :: IO ()
main = do
xmproc <- spawnPipe "xmobar" -- call xmobar
xmonad $ defaultConfig
{ terminal = myTerminal
, modMask = myModMask
, borderWidth = myBorderWidth
, normalBorderColor = "#5a908e"
, focusedBorderColor = "#99cb81"
, startupHook = setWMName "LG3D"
, manageHook = myManageHookShift <+> myManageHookFloat <+> manageDocks
-- any time Full mode, avoid xmobar area
, layoutHook = toggleLayouts (noBorders Full) $ avoidStruts $ myLayout
-- xmobar setting
, logHook = dynamicLogWithPP $ xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "green" "" . shorten 50
}
}
`additionalKeysP`
-- start software
[ ("M4-t", spawn myTerminal )
, ("M4-w", spawn myBrowser )
, ("M4-g", spawn myGame )
, ("M4-f", spawn myFiler)
, ("M4-e", spawn myEditer)
, ("M4-m", spawn myMusic)
, ("M4-s", spawn myChat)
, ("M4-n", spawn myScreenShot)
, ("M4-a", spawn myPainter)
, ("M4-,", spawn "pulseaudio-ctl down")
, ("M4-.", spawn "pulseaudio-ctl up")
, ("M4-/", spawn "pulseaudio-ctl mute")
, ("M4-[", spawn "synclient TouchpadOff=0")
, ("M4-]", spawn "synclient TouchpadOff=1")
, ("M4-l", spawn "sleepmonitor")
, ("M4-o", spawn "Websearch.py")
, ("M4-p", spawn "dmenu_run -fn 'Migu 1m-10:bold'")
-- handle window size
, ("M4-j", windows W.swapDown)
, ("M4-k", windows W.swapUp)
]
myWorkspaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
myTerminal = "lilyterm"
myBrowser = "opera"
myGame = "minecraft"
myFiler = "pcmanfm"
myEditer = "leafpad"
myMusic = "audacious"
myChat = "skype"
myPainter = "azpainter"
myScreenShot = "xfce4-screenshooter"
myModMask = mod4Mask
myBorderWidth =2
myManageHookShift = composeAll
-- if you want to know className, type "$ xprop|grep CLASS" on shell
[ className =? "Audacious" --> doShift "1"
, className =? "Opera" --> doShift "2"
, className =? "Skype" --> doShift "3"
]
-- Handle Window behaveior
myLayout = (spacing 8 $ ResizableTall 1 (3/100) (3/5) [])
||| (spacing 2 $ (dragPane Horizontal (1/10) (1/2)))
||| (dragPane Vertical (1/10) (1/2))
myManageHookFloat = composeAll
[ className =? "Websearch.py" --> doFloat
, className =? "Plugin-container" --> doFloat
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment