Source

shared / .xmonad / xmonad.hs

Full commit
module Main (main) where

import XMonad
import System.Exit
import qualified Data.Map as M
import Graphics.X11.Xlib
import XMonad.Prompt
import XMonad.Prompt.Input
import XMonad.Prompt.Shell
import XMonad.Prompt.Ssh
import XMonad.Prompt.XMonad
import XMonad.Prompt.RunOrRaise
import XMonad.Hooks.Script
import XMonad.Util.EZConfig
import XMonad.Util.Run
import XMonad.Layout.NoBorders
import XMonad.Layout.Tabbed
import XMonad.Layout.Grid
import XMonad.Layout.OneBig
import XMonad.Layout.ShowWName
import XMonad.Hooks.UrgencyHook
import XMonad.Hooks.EwmhDesktops

myModMask = mod4Mask               -- "windows key"
myNormalBorderColor  = "#4f4fff"
myFocusedBorderColor = "#ff2080"
myBorderWidth = 2
myTerminal = "urxvt"

main :: IO ()
main = xmonad $ withUrgencyHookC myUrgentHook myUrgentConfig $ ewmh config
       where config = defaultConfig {
               normalBorderColor  = myNormalBorderColor,
               focusedBorderColor = myFocusedBorderColor,
               keys               = newKeys,
               modMask            = myModMask,
               borderWidth        = myBorderWidth,
               terminal           = myTerminal,
               startupHook        = execScriptHook "startup" >> (checkKeymap config myKeys),
               manageHook         = composeAll manageHooks,
               layoutHook         = myLayoutHook,
               workspaces         = myWorkspaces
               }
             myUrgentHook = SpawnUrgencyHook "~/.xmonad/urgentHook "
             myUrgentConfig = urgencyConfig {
               remindWhen = Every (minutes 1)
               }


newKeys x = M.union (keys defaultConfig x) (mkKeymap x myKeys)
myKeys = [
  ("M1-<F4>", kill),
  ("M-x", spawn "visit"),
  ("M-z", safeSpawn "zsh" ["-c", "sensible-browser"]),
  ("M-S-z", spawn "zsh -c sensible-browser \"$(xsel)\""),
  ("M-0", spawn "popup-notify"),
  --  ("M-S-0", spawn "notify-send \"`date '+%A %Y-%m-%d %T'`\" \"`cal`\""),
  ("M-S-0", spawn "zenity --calendar --text=\"Now: `date`\""),
  ("M-s", inputPrompt defaultXPConfig "Google" ?+ \t -> safeSpawn "search" [t]),
  ("M-S-s", spawn "bash -c 'search \"$(xclip -o)\"'"),
  ("M-g", spawn "sensible-browser --app=http://www.gmail.com"),
  ("M-o", spawn "nautilus --no-desktop"),
  ("M-;", focusUrgent),
  ("M-S-`", spawn "user-shutdown"),
  ("<XF86AudioLowerVolume>", spawn "amixer sset -- Master playback 10-"),
  ("<XF86AudioRaiseVolume>", spawn "amixer sset -- Master playback 10+"),
  ("S-<XF86AudioRaiseVolume>", spawn "amixer sset -- Master playback 100%"),
  ("<XF86AudioMute>", spawn "amixer sset -- Master playback 0%"),
  ("M-<F3>", spawn "xbacklight -inc 20"),
  ("M-<F2>", spawn "xbacklight -dec 20"),
  ("M-S-q", saveAndShutdown)
  ]

saveAndShutdown = do execScriptHook "shutdown" ; io (exitWith ExitSuccess)
  

manageHooks = [
  className =? "XClock"    -->doFloat,
  className =? "Xmessage"  -->doFloat,
  className =? "Zenity"    -->doFloat,
  className =? "Rhythmbox" -->doShift "music",
  className =? "trayer"    -->doShift "misc",
  className =? "skype"     -->doShift "skype"
  ]
              
myLayoutHook = showWName $ smartBorders $ (Mirror spiral) ||| myTabbed ||| Full
  where tiled      = Tall nmaster inc splitFrac
        nmaster    = 1
        spiral     = OneBig splitFrac splitFrac
        myTabbed   = simpleTabbed
        inc::(Fractional t)=>t
        inc        = 1/15
        splitFrac::(Fractional t)=>t
        splitFrac  = 10*inc

myWorkspaces = [
  "web",
  "code",
  "chat",
  "docs",
  "terminals",
  "skype",
  "7",
  "music",
  "misc"
  ]

defaultApps = M.fromList [
  ("web","sensible-browser"),
  ("code","sensible-editor"),
  ("chat","pidgin"),
  ("terminals","urxvt"),
  ("skype","skype"),
  ("music","rhythmbox")
  ]