rendered paste body
import XMonad.Config
import XMonad.Core
import qualified XMonad.Actions.FlexibleResize as Flex
import XMonad.Hooks.DynamicLog -- hiding (dynamicLogWithPP)
import XMonad.Hooks.ManageDocks
import XMonad.ManageHook
import XMonad.Layout hiding ((|||))
import XMonad.Layout.NoBorders
import XMonad.Layout.Tabbed
import XMonad.Layout.Grid
import Data.Maybe ( isJust )
import Data.List
import Data.Ord ( comparing )
import XMonad.Actions.Submap
import XMonad.Layout.LayoutCombinators -- ( JumpToLayout(JumpToLayout) )
import XMonad.Prompt
import XMonad.Actions.FlexibleResize as Flex
import XMonad.Main
import XMonad.Operations
import XMonad.Prompt ( XPConfig(..), XPPosition(..) )
import XMonad.Prompt.Shell --( shellPrompt )
import XMonad.Util.Run
import qualified XMonad.StackSet as W
import XMonad.Util.WorkspaceCompare
import Data.Ratio
import Data.Bits ((.|.))
import qualified Data.Map as M
import System.Exit
import Graphics.X11.Xlib
import System.IO
import Control.Monad.State
import XMonad.Util.NamedWindows
import XMonad.Util.Run
import XMonad.Hooks.UrgencyHook
------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- H I C S V N T C O N F I G S --
--------------------------------------------------------------------------------
------------------------------------------------------------------------------
----------------------------------------
-- DYNAMICLOG
----------------------------------------
-- Dynamic prottyprintor
customPP = PP { ppCurrent = wrap "[" "]"
, ppVisible = wrap "<" ">"
, ppHidden = id
, ppHiddenNoWindows = const ""
, ppUrgent = id
, ppSep = " | "
, ppWsSep = " "
, ppTitle = shorten 80
, ppLayout = \x -> ""
, ppOrder = id
, ppSort = getSortByIndex
, ppExtras = []
, ppOutput = putStrLn
}
sepBy sep = concat . intersperse sep . filter (not . null)
----------------------------------------
-- RANDOM CRACKPOTTERY
----------------------------------------
-- Misc definitions of externally launchable things
dmenu, volUp, volDown, monitoring :: String
dmenu = "exe=`dmenu -nb '#334477' -nf '#ffffff' -sb '#000000' -sf '#ffffff' -fn '-*-terminus-*-r-*-*-12-*-*-*-*-*-iso10646-*' < ~/.dmenu_cache` && eval \"exec $exe\""
volUp = "amixer sset PCM 1+ 1>/dev/null "
volDown = "amixer sset PCM 1- 1>/dev/null "
monitoring = "killall mkstatus ; mkstatus | dzen2 -e '' -w 820 -ta r -fg '#ffffff' -bg '#000000' -fn '-*-terminus-*-r-*-*-12-*-*-*-*-*-iso10646-*' -x 200"
statusBarLeft =
"dzen2 -e '' -w 200 -ta l -fg #ffffff -bg #000000 -fn '-*-terminus-*-r-*-*-12-*-*-*-*-*-iso10646-*'"
statusBarRight =
"mkstatus | dzen2 -e '' -w 820 -ta r -fg #ffffff -bg #000000 -fn '-*-terminus-*-r-*-*-12-*-*-*-*-*-iso10646-*' -x 200"
----------------------------------------
-- KEYS AND MOUSES!!! KEYS AND MOUSES!!!
----------------------------------------
noKeyMask :: KeyMask
noKeyMask = 0
customKeys (XConfig {modMask = modm}) = M.fromList $
-- launching and killing programs
[ ((modm, xK_u ), spawn "urxvtc") -- @@ ! Launch a terminal
, ((modm, xK_i ), spawn "dillo") -- @@ ! spawn Dildo
, ((modm, xK_p ), spawn dmenu) -- @@ colored dmenu
, ((modm .|. shiftMask, xK_p ), spawn "dmenu_regen.sh") -- @@ ! regenerate menu & launch
, ((noKeyMask , xK_F11 ), spawn volDown) -- @@ ! vol down
, ((noKeyMask , xK_F12 ), spawn volUp) -- @@ ! vol up
, ((modm, xK_j ), shellPrompt customXPConfig)
, ((modm, xK_k ), prompt ("urxvtc -e") customXPConfig)
, ((modm .|. shiftMask, xK_c ), kill) -- @@ Close the focused window
, ((modm, xK_n ), refresh) -- %! Resize viewed windows to the correct size
-- move focus up or down the window stack
, ((modm, xK_Tab ), windows W.focusDown) -- @@ Move focus to the next window
, ((modm .|. shiftMask, xK_Tab ), windows W.focusUp) -- @@ ! Move focus to the prev window
, ((modm, xK_h ), windows W.focusDown) -- @@ ! Move focus to the next window
, ((modm, xK_t ), windows W.focusUp ) -- @@ ! Move focus to the previous window
-- modifying the window order and layouts
, ((modm, xK_Return), windows W.swapMaster) -- @@ Swap the focused window and the master window
, ((modm .|. shiftMask, xK_h ), windows W.swapDown ) -- @@ Swap the focused window with the next window
, ((modm .|. shiftMask, xK_t ), windows W.swapUp ) -- @@ Swap the focused window with the previous window
, ((modm, xK_space ), sendMessage NextLayout) -- %! Rotate through the available layout algorithms
, ((modm, xK_m ), submap . M.fromList $
[ ((0, xK_t), sendMessage $ JumpToLayout "Tall")
, ((0, xK_f), sendMessage $ JumpToLayout "Full")
, ((0, xK_b), sendMessage $ JumpToLayout "Tabbed")
, ((0, xK_g), sendMessage $ JumpToLayout "Grid")
])
-- resizing the master/slave ratio
, ((modm .|. shiftMask, xK_d ), sendMessage Shrink) -- %! Shrink the master area
, ((modm .|. shiftMask, xK_n ), sendMessage Expand) -- %! Expand the master area
, ((modm, xK_l ), withFocused $ windows . W.sink) -- %! Push window back into tiling
-- increase or decrease number of windows in the master area
, ((modm , xK_comma ), sendMessage (IncMasterN 1)) -- %! Increment the number of windows in the master area
, ((modm , xK_period), sendMessage (IncMasterN (-1))) -- %! Deincrement the number of windows in the master area
-- toggle the status bar gap
--, ((modm , xK_b ), modifyGap (\i n -> let x = (defaultGaps ++ repeat (0,0,0,0)) !! i in if n == x then (0,0,0,0) else x)) -- %! Toggle the status bar gap
-- quit, or restart
, ((modm .|. shiftMask, xK_Pause ), io (exitWith ExitSuccess)) -- @@ Quit xmonad
, ((modm .|. shiftMask, xK_q ), restart "Restarted from keyboard" True) -- @@ Restart xmonad
, ((modm .|. shiftMask, xK_m ), spawn monitoring) -- @@ Restart dzen monitoring (mkstatus)
-- Extension-provided key bindings
]
++
-- 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 (workspaces defaultConfig) [xK_exclam, xK_at, xK_numbersign, xK_dollar, xK_percent, xK_asciicircum, xK_ampersand, xK_asterisk, xK_parenleft, xK_parenright]
, (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)]]
-- Extension-provided key bindings lists
-}
-- |
-- default actions bound to mouse events
--
--mouseBindings :: M.Map (KeyMask, Button) (Window -> X ())
myMouse x =
-- mod-button1 %! Set the window to floating mode and move by dragging
[ ((modMask x, button1), (\w -> focus w >> mouseMoveWindow w))
-- mod-button2 %! Raise the window to the top of the stak
, ((modMask x, button2), (\w -> focus w >> windows W.swapMaster))
-- mod-button3 %! Set the window to floating mode and resize by dragging
, ((modMask x, button3), (\w -> focus w >> Flex.mouseResizeWindow w))
-- Extension-provided mouse bindings
]
customMouse x = M.union (mouseBindings defaultConfig x) (M.fromList (myMouse x))
----------------------------------------
-- SHELL STUFFS
----------------------------------------
-- Shell prompt configs
customXPConfig = XPC { font = "-*-terminus-*-r-*-*-12-*-*-*-*-*-iso10646-*"
, bgColor = "#334477"
, fgColor = "#ffffff"
, bgHLight = "#000000"
, fgHLight = "#ffffff"
, borderColor = "#000000"
, promptBorderWidth = 0
, position = Top
, height = 14
, historySize = 666
, defaultText = "XNomad: "
}
----------------------------------------
-- LAYOUTS AND WINDOWS STUFF
----------------------------------------
-- Toggle between layouts with ease
--myLayouts = toggleLayouts tiled ||| noBorders Full ||| tabbed shrinkText customTConf
-- Config for Tabbed mode
{-
customTConf =
defaultTConf { activeColor = "#334477"
, inactiveColor = "#000000"
, activeBorderColor = "#000000"
, inactiveBorderColor = "#000000"
, activeTextColor = "#ffffff"
, inactiveTextColor = "#ffffff"
, fontName = "-*-terminus-*-r-*-*-12-*-*-*-*-*-iso10646-*"
, tabSize = 15
}
-}
myTabConfig = defaultTheme { activeColor = "#334477"
, inactiveColor = "#000000"
, activeBorderColor = "#000000"
, inactiveBorderColor = "#000000"
, activeTextColor = "#ffffff"
, inactiveTextColor = "#ffffff"
, fontName = "-*-terminus-*-r-*-*-12-*-*-*-*-*-iso10646-*"
, decoHeight = 40
}
-- Hooks
-- Send stuff to appropriate places
-- Stolen from Arossato.hs
myManageHook = composeAll [ resource =? "mplayer" --> doFloat
, resource =? "gimp" --> doFloat
--, resource =? "gecko" --> (W.shift "4")
--, resource =? "psi" --> (W.shift "3")
]
----------------------------------------
-- Putting it all together
----------------------------------------
main = do --din <- spawnPipe statusBarLeft
--spawn statusBarRight
xmonad $ defaultConfig
{ borderWidth = 1
, normalBorderColor = "#070A22"
, focusedBorderColor = "#334477"
, terminal = "urxvtc"
, modMask = mod4Mask
, defaultGaps = [(15, 0, 0, 0)]
, manageHook = myManageHook <+> manageHook defaultConfig --manageDocks
, logHook = dynamicLogWithPP customPP
, layoutHook = avoidStruts (Tall 1 (3%100) (1%2) ||| noBorders Full ||| tabbed shrinkText myTabConfig ||| Grid)
, keys = \c -> customKeys c `M.union` keys defaultConfig c
, mouseBindings = customMouse
}