shared / .xmonad / xmonad.hs

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")
  ]
  
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.