Commits

Robert Massaioli [Atlassian] committed 6b6b26b

Initial import of the config files.

  • Participants

Comments (0)

Files changed (3)

+Robert Massaioli's xmonad.hs
+============================
+
+This is my xmonad.hs file that I want to share with everyone, for a full set of its features then I reccomend
+opening the file itself and having a read. Meant for programmers that use Dvorak keyboards.
+
+Instalation
+-----------
+
+Check out this repository in a convinient location. Then do the following:
+
+    mv ~/.xmonad/xmonad.hs ~/.xmonad/xmonad.hs.old
+    ln -s xmonad.hs ~/.xmonad/
+
+And then restart xmonad using whatever key you have restart mapped to. Please note that this xmonad.hs was supposed to be used on a dvorak keyboard.
+
+Command Guide
+-------------
+
+XMonad configuration file by Thomas ten Cate <ttencate@gmail.com>  
+Edited and extended by Robert Massaioli <robertmassaioli@gmail.com>
+
+Works on xmonad-0.8, NOT on 0.7 or below; and of course
+xmonad-contrib needs to be installed as well.
+
+This is designed to play nice with a standard Ubuntu Hardy (or greater) installation.
+It gives you 12 workspaces per screen, available through Alt+F1..F12. You can move
+windows to a workspace with Win+F1..F12. You can do both at the same time
+by pressing Win+Alt+F1..F12. It should work well with other *nix operating systems
+too.
+
+All workspaces except F11 respect panels and docks.  
+F11 is the fullscreen workspace (for mplayer, etc.).  
+F12 is the instant messaging workspace.  
+When you switch screens the mouse will go with you.  
+
+Pidgin and Skype windows are automatically placed onto the IM workspace.
+Their contact lists each get a column on the right side of the screen,
+and all their other windows (chat windows, etc.) go into a grid layout
+in the remaining space.
+(This uses a copied and modified version of XMonad.Layout.IM.)
+
+Keybindings mostly use the Windows key, but some use Alt to mimic other
+window managers. In general: Alt is used for navigation, Win for modification.
+Some of the bindings resemble the XMonad defaults, but most don't.
+The bindings are set up to be comfortable to use on a dvorak keyboard layout.
+
+Before we have the commands lets make some word definitions:
+window = The window that a program runs in.
+Workspace = One screen with many windows.
+Screen = A physical computer screen that you will look at.
+
+__Screen management:__
+>  Ctrl+Alt+Left/Right        move focus to previous/next screen  
+>  Ctrl+Alt+Down/Up           switch current window to current workspace on previous/next screen  
+>  Ctrl+Alt+Shift+Left/Right  swap all windows in current screen with previous/next screen  
+
+__Navigation:__  
+>  Alt+Space            switch to free workspace  
+>  Alt+F1..F12          switch to workspace on the same screen  
+>  Alt+Tab              focus next window on same screen  
+>  Alt+BackSpace        focus previous window on the same screen (Meant to be in the CapsLock position but my layout is different)  
+>  Win+Z                The mouse it moved one sixth of the way in from the top left of the window.  
+
+__Window management:__  
+>  These commands all keep windows in the same screen.
+>  Alt+Shift+Space      move current window to free workspace 
+>  Win+F1..F12          move window to workspace
+>  Win+Alt+F1..F12      move window to workspace and switch to that workspace  
+>  Win+Up/Down          move window up/down on  
+>  Win+C                close window  
+>  Alt+ScrollUp/Down    move focused window up/down  
+>  Win+M                move window to master area  
+>  Win+N                refresh the current window  
+>  Alt+LMB              move floating window  
+>  Alt+MMB              resize floating window  
+>  Alt+RMB              unfloat floating window  
+>  Win+T                unfloat floating window  
+ 
+__Layout management:__  
+>  Win+Left/Right       shrink/expand master area  
+>  Win+W/V              move more/less windows into master area  
+>  Win+Space            cycle layouts  
+>  Alt+Space            Go back to the first layout  
+
+__Other:__  
+>  Win+Enter            start a terminal  
+>  Win+R                open the dmenu dialogue (you can make it gnomeRun if you wish)  
+>  Win+Q                restart XMonad  
+>  Win+B                opens your browser  
+>  Win+Shift+Q          display Gnome shutdown dialog  
+Config { font = "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*"
+       , bgColor = "black"
+       , fgColor = "grey"
+       , position = Top
+       , lowerOnStart = True
+       , commands = [ Run Network "eth0" ["-L","0","-H","32","--normal","green","--high","red"] 5
+                    , Run MultiCpu [
+                                        "-L","3",
+                                        "-H","60",
+                                        "--normal","green",
+                                        "--high","red",
+                                        "--template", "Cpu0: <total0> Cpu1: <total1> Cpu2: <total2> Cpu3: <total3>"
+                                   ] 10
+                    , Run Memory    [
+                                        "-t","Mem: <used>/<total> (<usedratio>%)"
+                                        , "-L", "1500"
+                                        , "-H", "6500"
+                                        , "--normal", "yellow"
+                                        , "--high", "red"
+                                        , "--low", "green"
+                                    ] 10
+                    , Run Swap [] 10
+                    , Run Date "%a %b %_d %Y %p %I:%M:%S" "date" 10
+                    , Run StdinReader
+                    ]
+       , sepChar = "%"
+       , alignSep = "}{"
+       , template = "%multicpu% | %memory% * %swap% | %StdinReader% }{ <fc=#d843e1>%eth0%</fc> | <fc=#ee9a00>%date%</fc>"
+       }
+{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, TypeSynonymInstances, FlexibleContexts, NoMonomorphismRestriction #-}
+ 
+
+-- XMonad configuration file by Thomas ten Cate <ttencate@gmail.com>
+-- Edited and extended by Robert Massaioli <robertmassaioli@gmail.com>
+-- 
+-- Works on whatever XMonad that I happen to be running, usually the latest one.
+-- You will need xmonad-contrib and maybe more.
+--
+-- This is designed to play nice with a standard Ubuntu installation.
+--
+-- WARNING: On my computers I swap CapsLock and BackSpace around so if you don't then you will need
+-- to swap those around in this config.
+ 
+import XMonad
+import XMonad.Util.EZConfig
+import qualified XMonad.StackSet as S
+import XMonad.Actions.CycleWS
+import XMonad.Config.Gnome
+import XMonad.Hooks.EwmhDesktops
+import XMonad.Hooks.ManageDocks
+import XMonad.Layout.Combo
+import XMonad.Layout.Grid
+import XMonad.Layout.LayoutModifier
+import XMonad.Layout.Named
+import XMonad.Layout.NoBorders
+import XMonad.Layout.PerWorkspace
+import XMonad.Layout.Reflect
+import XMonad.Layout.TwoPane
+import XMonad.Layout.WindowNavigation
+import XMonad.Util.WindowProperties
+import Control.Monad
+import Data.Ratio
+import qualified Data.Map as M
+import XMonad.Util.Run
+import XMonad.Util.Dmenu
+import XMonad.Util.Dzen 
+import XMonad.Hooks.DynamicLog (dynamicLogXinerama, xmobar)
+import XMonad.Actions.FindEmptyWorkspace
+import XMonad.Layout.IndependentScreens
+import XMonad.Actions.Warp
+import XMonad.Hooks.UrgencyHook
+import System.Exit
+
+import XMonad.Prompt
+import XMonad.Actions.TagWindows
+
+import XMonad.Actions.OnScreen (greedyViewOnScreen, viewOnScreen)
+import Data.Maybe (fromMaybe)
+
+import XMonad.Hooks.ManageHelpers (isFullscreen, doFullFloat)
+
+-- defaults on which we build
+-- use e.g. defaultConfig or gnomeConfig
+myBaseConfig = gnomeConfig
+ 
+-- display
+-- replace the bright red border with a more stylish colour
+myBorderWidth = 1
+myNormalBorderColor = "white"
+myFocusedBorderColor = "purple"
+ 
+-- workspaces
+myWorkspaces = map show [1..12]
+ 
+-- layouts
+basicLayout = Tall nmaster delta ratio 
+  where
+    nmaster = 1
+    delta   = 3 / 100
+    ratio   = 1 / 2
+tallLayout = named "tall" . avoidStruts $ basicLayout
+wideLayout = named "wide" . avoidStruts $ Mirror basicLayout
+singleLayout = named "single" . avoidStruts $ noBorders Full
+fullscreenLayout = named "fullscreen" $ noBorders Full
+imLayout = avoidStruts . reflectHoriz $ withIMs ratio rosters chatLayout 
+  where
+    chatLayout      = Grid
+    ratio           = 1 % 6
+    rosters         = [skypeRoster, pidginRoster]
+    pidginRoster    = And (ClassName "Pidgin") (Role "buddy_list")
+    skypeRoster     = ClassName "Skype" `And` 
+                      Not (Title "Options") `And` 
+                      Not (Role "Chats") `And` 
+                      Not (Role "CallWindowForm")
+ 
+myLayoutHook screens = fullscreen $ im normal 
+  where
+    normal     = tallLayout ||| wideLayout ||| singleLayout
+    fullscreen = onWorkspaces (withScreens screens ["11"]) fullscreenLayout
+    im         = onWorkspace "im" imLayout
+ 
+-- special treatment for specific windows:
+myManageHook = composeAll userDefinedHooks <+> manageHook myBaseConfig
+   where
+      userDefinedHooks =
+         [ webBrowserHook
+         , fileBrowserHook
+         , terminalHook
+         , imClientHook
+         , allowFullscreenHook
+         ]
+
+      isTerminal = isApplicationGroup ["Gnome-terminal"]
+      isIM     = isApplicationGroup ["Pidgin", "Skype"]
+      isWebBrowser = isApplicationGroup ["X-www-browser", "Google-chrome", "Firefox"]
+      isFileBrowser = isApplicationGroup ["Nautilus"]
+      isEclipse = isApplicationGroup ["Eclipse"]
+
+      isApplicationGroup :: [String] -> Query Bool
+      isApplicationGroup = foldr1 (<||>) . map (className =?)
+
+      imClientHook = isIM --> addTagsHook ["im_client"]
+      terminalHook = isTerminal --> addTagsHook ["terminal"]
+      webBrowserHook = isWebBrowser --> addTagsHook ["browser"]
+      fileBrowserHook = isFileBrowser --> addTagsHook ["file_browser"]
+      eclipseHook = isEclipse --> addTagsHook ["eclipse"]
+
+      -- this will allow anything that says it is fullscreen to go fullscreen: like youtube videos
+      allowFullscreenHook = isFullscreen --> doFullFloat
+
+      addTagsHook :: [String] -> ManageHook
+      addTagsHook ts = do
+         window <- ask
+         liftX . sequence . fmap (flip addTag window) $ ts
+         idHook
+ 
+-- Mod4 is the Super / Windows key
+-- alt, is well...alt
+myModMask = mod4Mask
+altMask   = mod1Mask
+ 
+{-
+ - Default Spawn Commands
+ - Update these using update alternatives as in:
+ -    $ update-alternatives --config x-www-browser
+ -}
+myBrowser = "x-www-browser"   
+myTerminal = "x-terminal-emulator"
+
+-- choose which menu runs
+runMenu = spawn "dmenu_run"
+-- runMenu = gnomeRun
+
+-- better keybindings for dvorak
+myKeys conf = M.fromList $
+    [ ((myModMask              , xK_Return    ), spawn myTerminal)
+    , ((myModMask              , xK_x         ), spawn myBrowser)
+    , ((myModMask              , xK_r         ), runMenu)
+    , ((myModMask              , xK_c         ), kill)
+    -- Empty Workspace Movement
+    , ((altMask                , xK_space     ), viewEmptyWorkspace)
+    , ((altMask .|. shiftMask  , xK_space     ), tagToEmptyWorkspace)
+    -- Layout Commands
+    , ((myModMask              , xK_space     ), sendMessage NextLayout)
+    , ((altMask                , xK_Return    ), sendMessage FirstLayout)
+    , ((myModMask              , xK_n         ), refresh)
+    , ((myModMask              , xK_m         ), windows S.swapMaster)
+    -- controlling window movement, position and location
+    , ((altMask                , xK_Tab       ), windows S.focusDown >> windowCenter)
+    , ((altMask                , xK_BackSpace ), windows S.focusUp >> windowCenter)
+    , ((myModMask              , xK_Down      ), windows S.swapDown)
+    , ((myModMask              , xK_Up        ), windows S.swapUp)
+    , ((myModMask              , xK_Left      ), sendMessage Shrink)
+    , ((myModMask              , xK_Right     ), sendMessage Expand)
+    , ((myModMask              , xK_t         ), withFocused $ windows . S.sink)
+    , ((myModMask              , xK_w         ), sendMessage (IncMasterN 1))
+    , ((myModMask              , xK_v         ), sendMessage (IncMasterN (-1)))
+    -- Shutdown commands
+    , ((myModMask              , xK_q         ), restart "xmonad" True)
+    , ((myModMask              , xK_h         ), spawn "gksudo pm-hibernate")
+    , ((myModMask .|. shiftMask, xK_q         ), spawn "gksudo shutdown -P now")
+    , ((myModMask .|. shiftMask, xK_w         ), spawn "gnome-screensaver-command -l")
+    -- Print Screen
+    , ((myModMask              , xK_Print     ), spawn "gnome-screenshot")
+    , ((altMask                , xK_Print     ), spawn "gnome-screenshot -a")
+    -- MPC and Volume commands
+    , ((myModMask               , xK_Page_Up), spawn "mpc next")
+    , ((myModMask               , xK_Page_Down), spawn "mpc prev")
+    , ((myModMask               , xK_Pause), spawn "mpc toggle")
+    , ((myModMask               , xK_Home), spawn "amixer -c0 -- sset Master Playback 2dB+")
+    , ((myModMask               , xK_End), spawn "amixer -c0 -- sset Master Playback 2dB-")
+    -- Screen Movement
+    , ((altMask .|. controlMask, xK_Left       ), prevScreen >> windowCenter)
+    , ((altMask .|. controlMask, xK_Right      ), nextScreen >> windowCenter)
+    , ((altMask .|. controlMask, xK_Down       ), shiftPrevScreen)
+    , ((altMask .|. controlMask, xK_Up         ), shiftNextScreen)
+    , ((altMask .|. controlMask .|. shiftMask, xK_Down       ), shiftPrevScreen >> prevScreen >> windowCenter)
+    , ((altMask .|. controlMask .|. shiftMask, xK_Up         ), shiftNextScreen >> nextScreen >> windowCenter)
+    , ((altMask .|. controlMask .|. shiftMask, xK_Left     ), swapPrevScreen) -- this does not work properly
+    , ((altMask .|. controlMask .|. shiftMask, xK_Right     ), swapNextScreen)
+    , ((myModMask              , xK_z         ), windowCenter)
+    -- Tagging Windows
+    , ((myModMask              ,   xK_g  ), tagPrompt defaultXPConfig (withFocused . addTag))
+    , ((myModMask .|. shiftMask,   xK_g  ), tagDelPrompt defaultXPConfig)
+    , ((altMask                ,   xK_g  ), tagPrompt defaultXPConfig (`withTaggedGlobalP` gotoWindow))
+    ] ++
+    -- Alt+F1..F10 switches to workspace
+    -- mod+F1..F10 moves window to workspace
+    -- (Alt is in a nicer location for the thumb than the Windows key,
+    -- and 1..9 keys are already in use by Firefox, irssi, ...)
+    [ ((m, k), f i)
+        | (i, k) <- zip (workspaces' conf) workspaceKeys
+        , (f, m) <- [(windowsGreedyView, altMask), (windowsShift, myModMask)]
+    ] ++
+    -- mod+alt+F1..F10 moves window to workspace and switches to that workspace
+    [ ((myModMask .|. altMask, k), windowsShift i >> windowsGreedyView i >> windowCenter) 
+        | (i, k) <- zip (workspaces' conf) workspaceKeys
+    ]
+    where 
+        workspaceKeys = [xK_F1 .. xK_F12]
+        windowsShift      = windows . onCurrentScreen S.shift
+        windowsGreedyView = windows . onCurrentScreen S.greedyView
+        windowCenter = warpToWindow (1 % 6) (1 % 6)
+
+        gotoWindow :: Window -> WindowSet -> WindowSet
+        gotoWindow window ws = case S.findTag window ws of
+                                 Just i -> viewOnScreen (screenIdFromTag i) i ws
+                                 Nothing -> ws
+            where
+               screenIdFromTag :: WorkspaceId -> ScreenId
+               screenIdFromTag = S . read . takeWhile (/= '_')
+ 
+-- mouse bindings that mimic Gnome's
+myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList
+    [ ((altMask, button1), \w -> focus w >> mouseMoveWindow w)
+    , ((altMask, button2), \w -> focus w >> mouseResizeWindow w)
+    , ((altMask, button3), \w -> focus w >> withFocused (windows . S.sink))
+    , ((altMask, button4), const $ windows S.swapUp)
+    , ((altMask, button5), const $ windows S.swapDown)
+    ]
+ 
+-- put it all together
+main = do
+    nScreens <- countScreens    -- just in case you are on a laptop like me count the screens so that you can go
+    xmonad =<< xmobar myBaseConfig
+      { modMask = myModMask
+      , workspaces = withScreens nScreens myWorkspaces
+      , layoutHook = myLayoutHook nScreens
+      , manageHook = myManageHook
+      , borderWidth = myBorderWidth
+      , normalBorderColor = myNormalBorderColor
+      , focusedBorderColor = myFocusedBorderColor
+      , keys = myKeys
+      , mouseBindings = myMouseBindings
+      , logHook = myLogHook
+      }
+    where
+        myLogHook = dynamicLogXinerama
+ 
+-- modified version of XMonad.Layout.IM --
+ 
+-- | Data type for LayoutModifier which converts given layout to IM-layout
+-- (with dedicated space for the roster and original layout for chat windows)
+data AddRosters a = AddRosters Rational [Property] 
+                    deriving (Read, Show)
+ 
+instance LayoutModifier AddRosters Window where
+  modifyLayout (AddRosters ratio props) = applyIMs ratio props
+  modifierDescription _                = "IMs"
+ 
+-- | Modifier which converts given layout to IMs-layout (with dedicated
+-- space for rosters and original layout for chat windows)
+withIMs :: LayoutClass l a => Rational -> [Property] -> l a -> ModifiedLayout AddRosters l a
+withIMs ratio props = ModifiedLayout $ AddRosters ratio props
+ 
+-- | IM layout modifier applied to the Grid layout
+gridIMs :: Rational -> [Property] -> ModifiedLayout AddRosters Grid a
+gridIMs ratio props = withIMs ratio props Grid
+ 
+hasAnyProperty :: [Property] -> Window -> X Bool
+hasAnyProperty [] _ = return False
+hasAnyProperty (p:ps) w = do
+    b <- hasProperty p w
+    if b then return True else hasAnyProperty ps w
+ 
+-- | Internal function for placing the rosters specified by
+-- the properties and running original layout for all chat windows
+applyIMs :: (LayoutClass l Window) =>
+               Rational
+            -> [Property]
+            -> S.Workspace WorkspaceId (l Window) Window
+            -> Rectangle
+            -> X ([(Window, Rectangle)], Maybe (l Window))
+applyIMs ratio props wksp rect = do
+    let stack = S.stack wksp
+    let ws = S.integrate' stack
+    rosters <- filterM (hasAnyProperty props) ws
+    let n = fromIntegral $ length rosters
+    let (rostersRect, chatsRect) = splitHorizontallyBy (n * ratio) rect
+    let rosterRects = splitHorizontally n rostersRect
+    let filteredStack = stack >>= S.filter (`notElem` rosters)
+    (a,b) <- runLayout (wksp {S.stack = filteredStack}) chatsRect
+    return (zip rosters rosterRects ++ a, b)