summaryrefslogtreecommitdiff
path: root/xmonad.hs
diff options
context:
space:
mode:
Diffstat (limited to 'xmonad.hs')
-rw-r--r--xmonad.hs257
1 files changed, 257 insertions, 0 deletions
diff --git a/xmonad.hs b/xmonad.hs
new file mode 100644
index 0000000..3960fac
--- /dev/null
+++ b/xmonad.hs
@@ -0,0 +1,257 @@
+import XMonad
+import XMonad.Hooks.SetWMName
+import XMonad.Layout.Grid
+import XMonad.Layout.ResizableTile
+import XMonad.Layout.IM
+import XMonad.Layout.ThreeColumns
+import XMonad.Layout.NoBorders
+import XMonad.Layout.Circle
+import XMonad.Layout.PerWorkspace (onWorkspace)
+import XMonad.Layout.Fullscreen
+import XMonad.Util.EZConfig
+import XMonad.Util.Run
+import XMonad.Util.Dzen
+import XMonad.Util.NamedWindows
+import XMonad.Hooks.DynamicLog
+import XMonad.Actions.Plane
+import XMonad.Hooks.ManageDocks
+import XMonad.Hooks.UrgencyHook
+import XMonad.Hooks.ICCCMFocus
+import qualified XMonad.StackSet as W
+import qualified Data.Map as M
+import Data.Ratio ((%))
+
+import XMonad.Hooks.EwmhDesktops
+
+
+-- import XMonad.Actions.Volume
+import XMonad.Hooks.DynamicLog
+import XMonad.Hooks.ManageDocks
+-- import XMonad.Util.Run(spawnPipe)
+import XMonad.Util.EZConfig ( additionalKeys )
+import XMonad.Config.Desktop
+
+import System.IO
+import System.Process
+
+import qualified XMonad.StackSet as W
+
+
+-- VARS
+
+myModMask = mod4Mask -- changes the mod key to "super"
+myFocusedBorderColor = "#ff0000" -- color of focused border
+myNormalBorderColor = "#cccccc" -- color of inactive border
+myBorderWidth = 1 -- width of border around windows
+-- myTerminal = "terminator" -- which terminal software to use
+myIMRosterTitle = "Buddy List" -- title of roster on IM workspace
+ -- use "Buddy List" for Pidgin, but
+ -- "Contact List" for Empathy
+{-
+ Xmobar configuration variables. These settings control the appearance
+ of text which xmonad is sending to xmobar via the DynamicLog hook.
+-}
+
+myTitleColor = "#eeeeee" -- color of window title
+myTitleLength = 80 -- truncate window title to this length
+myCurrentWSColor = "#e6744c" -- color of active workspace
+myVisibleWSColor = "#c185a7" -- color of inactive workspace
+myUrgentWSColor = "#cc0000" -- color of workspace with 'urgent' window
+myCurrentWSLeft = "[" -- wrap active workspace with these
+myCurrentWSRight = "]"
+myVisibleWSLeft = "(" -- wrap inactive workspace with these
+myVisibleWSRight = ")"
+myUrgentWSLeft = "{" -- wrap urgent workspace with these
+myUrgentWSRight = "}"
+
+myWorkspaces =
+ [
+ "7:Comm", "8:Web", "9:Vim",
+ "4:Docs", "5:Root", "6:Andr",
+ "1:Tex", "2:Vid", "3:Pix"
+ ]
+
+startupWorkspace = "5:Root" -- which workspace do you want to be on after launch?
+
+defaultLayouts = smartBorders(avoidStruts(
+-- ResizableTall layout has a large master window on the left,
+-- and remaining windows tile on the right. By default each area
+-- takes up half the screen, but you can resize using "super-h" and
+-- "super-l".
+ ResizableTall 1 (3/100) (1/2) []
+
+-- Mirrored variation of ResizableTall. In this layout, the large
+-- master window is at the top, and remaining windows tile at the
+-- bottom of the screen. Can be resized as described above.
+ ||| Mirror (ResizableTall 1 (3/100) (1/2) [])
+
+-- Full layout makes every window full screen. When you toggle the
+-- active window, it will bring the active window to the front.
+ ||| noBorders Full
+
+-- ThreeColMid layout puts the large master window in the center
+-- of the screen. As configured below, by default it takes of 3/4 of
+-- the available space. Remaining windows tile to both the left and
+-- right of the master window. You can resize using "super-h" and
+-- "super-l".
+ ||| ThreeColMid 1 (3/100) (3/4)
+
+-- Circle layout places the master window in the center of the screen.
+-- Remaining windows appear in a circle around it
+ ||| Circle
+
+-- Grid layout tries to equally distribute windows in the available
+-- space, increasing the number of columns and rows as necessary.
+-- Master window is at top left.
+ ||| Grid))
+
+chatLayout = avoidStruts(withIM (1%7) (Title myIMRosterTitle) Grid)
+gimpLayout = smartBorders(avoidStruts(ThreeColMid 1 (3/100) (3/4)))
+
+myLayouts =
+ onWorkspace "7:Comm" chatLayout
+ $ onWorkspace "3:Pix" gimpLayout
+ $ defaultLayouts
+
+myKeyBindings =
+ [
+ ((myModMask, xK_b), sendMessage ToggleStruts)
+ , ((myModMask, xK_a), sendMessage MirrorShrink)
+ , ((myModMask, xK_z), sendMessage MirrorExpand)
+-- , ((myModMask, xK_x), spawn "screenshot")
+ , ((0, xK_Print), spawn "/home/nick/scripts/screenshot")
+ , ((myModMask .|. controlMask, xK_Print), spawn "/home/nick/scripts/windowshot")
+ , ((myModMask, xK_Print), spawn "/home/nick/scripts/fullestscreen")
+-- , ((myModMask, xK_p), spawn "synapse")
+-- , ((myModMask .|. mod1Mask, xK_space), spawn "synapse")
+ , ((myModMask, xK_u), focusUrgent)
+-- , ((0, 0x1008FF12), spawn "amixer -q set Master toggle")
+-- , ((0, 0x1008FF11), spawn "amixer -q set Master 4%-")
+-- , ((0, 0x1008FF13), spawn "amixer -q set Master 4%+")
+-- , ((0, xK_F8), spawn "set-volume M")
+-- , ((myModMask, xK_F9), spawn "set-volume -")
+-- , ((0, XF86AudioRaiseVolume), spawn -volume +")
+ , ((0, 0x1008FF12), spawn "/home/nick/scripts/set-volume M")
+ , ((0, 0x1008FF11), spawn "/home/nick/scripts/set-volume -")
+ , ((0, 0x1008FF13), spawn "/home/nick/scripts/set-volume +")
+ ]
+
+myManagementHooks :: [ManageHook]
+myManagementHooks = [
+ resource =? "stalonetray" --> doIgnore
+ , (className =? "Thunderbird") --> doF (W.shift "7:Comm")
+ , (className =? "Pidgin") --> doF (W.shift "7:Comm")
+ , (className =? "Gimp") --> doF (W.shift "3:Pix")
+ , (className =? "Gimp-2.8") --> doF (W.shift "3:Pix")
+ , (className =? "Nautilus") --> doF (W.shift "4:Docs")
+ ]
+
+
+numPadKeys =
+ [
+ xK_KP_Home, xK_KP_Up, xK_KP_Page_Up,
+ xK_KP_Left, xK_KP_Begin, xK_KP_Right,
+ xK_KP_End, xK_KP_Down, xK_KP_Page_Down
+ ]
+
+numKeys =
+ [
+ xK_7, xK_8, xK_9,
+ xK_4, xK_5, xK_6,
+ xK_1, xK_2, xK_3
+ ]
+
+myKeys = myKeyBindings ++
+ [
+ ((m .|. myModMask, k), windows $ f i)
+ | (i, k) <- zip myWorkspaces numPadKeys
+ , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]
+ ] ++
+ [
+ ((m .|. myModMask, k), windows $ f i)
+ | (i, k) <- zip myWorkspaces numKeys
+ , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]
+ ] ++
+ M.toList (planeKeys myModMask (Lines 3) Finite) ++
+ [
+ ((m .|. myModMask, key), screenWorkspace sc
+ >>= flip whenJust (windows . f))
+ | (key, sc) <- zip [xK_w, xK_e, xK_r] [1,0,2]
+ , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]
+ ]
+
+--main = do
+-- xmproc <- spawnPipe "xmobar"
+-- xmonad $ defaultConfig
+-- { manageHook = manageDocks <+> manageHook defaultConfig
+-- , layoutHook = avoidStruts $ layoutHook defaultConfig
+-- , logHook = dynamicLogWithPP xmobarPP
+-- { ppOutput = hPutStrLn xmproc
+-- , ppTitle = xmobarColor "green" "" . shorten 50
+-- }
+-- , modMask = mod4Mask -- Rebind Mod to the Windows key
+-- } `additionalKeys`
+-- [ ((mod4Mask .|. shiftMask, xK_z), spawn "xscreensaver-command -lock; xset dpms force off")
+-- , ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s")
+-- , ((0, xK_Print), spawn "scrot")
+-- ]
+
+-- Alertwindow
+
+data LibNotifyUrgencyHook = LibNotifyUrgencyHook deriving (Read, Show)
+
+instance UrgencyHook LibNotifyUrgencyHook where
+ urgencyHook LibNotifyUrgencyHook w = do
+ name <- getName w
+ Just idx <- fmap (W.findTag w) $ gets windowset
+
+ safeSpawn "notify-send" [show name, "workspace " ++ idx]
+-- spawn "notify-send" [show name, "workspace " ++ idx]
+
+
+-- Functs
+
+alert = dzenConfig centered . show . round
+centered =
+ onCurr (center 150 66)
+ >=> font "-*-helvetica-*-r-*-*-64-*-*-*-*-*-*-*"
+ >=> addArgs ["-fg", "#80c0ff"]
+ >=> addArgs ["-bg", "#000040"]
+
+
+
+-- Main
+main :: IO ()
+main = do
+ xmproc <- spawnPipe "xmobar ~/.xmonad/xmobarrc"
+ xmonad $ withUrgencyHook LibNotifyUrgencyHook $ ewmh $ defaultConfig {
+-- xmonad $ withUrgencyHook LibNotifyUrgencyHook $ ewmh $ desktopConfig {
+ focusedBorderColor = myFocusedBorderColor
+ , normalBorderColor = myNormalBorderColor
+-- , terminal = myTerminal
+ , borderWidth = myBorderWidth
+ , layoutHook = myLayouts
+ , workspaces = myWorkspaces
+ , modMask = myModMask
+ , handleEventHook = XMonad.Layout.Fullscreen.fullscreenEventHook
+-- , handleEventHook = handleEventHook defaultConfig <+> fullscreenEventHook
+ , startupHook = do
+ setWMName "LG3D"
+ windows $ W.greedyView startupWorkspace
+ spawn "~/.xmonad/startup-hook"
+ , manageHook = manageHook defaultConfig
+ <+> composeAll myManagementHooks
+ <+> manageDocks
+ , logHook = takeTopFocus <+> dynamicLogWithPP xmobarPP {
+ ppOutput = hPutStrLn xmproc
+ , ppTitle = xmobarColor myTitleColor ""
+ . shorten myTitleLength
+ , ppCurrent = xmobarColor myCurrentWSColor ""
+ . wrap myCurrentWSLeft myCurrentWSRight
+ , ppVisible = xmobarColor myVisibleWSColor ""
+ . wrap myVisibleWSLeft myVisibleWSRight
+ , ppUrgent = xmobarColor myUrgentWSColor ""
+ . wrap myUrgentWSLeft myUrgentWSRight
+ }
+ } `additionalKeys` myKeys
+