From 08c670ef30b8d5df3b078eb7dceb5e705cd503e6 Mon Sep 17 00:00:00 2001 From: Barak Michener Date: Tue, 11 Dec 2012 12:33:33 -0800 Subject: [PATCH] xmonad --- .vimrc | 6 +- .xmonad/xmonad.hs | 206 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 208 insertions(+), 4 deletions(-) diff --git a/.vimrc b/.vimrc index 2078ec8..8c1a651 100644 --- a/.vimrc +++ b/.vimrc @@ -260,14 +260,14 @@ function! HighlightTooLongLines() endif endfunction -let g:google = 0 +let g:google_enable = 0 let g:disable_google_optional_settings = 1 if filereadable("/usr/share/vim/google/google.vim") source /usr/share/vim/google/google.vim - let g:google = 1 + let g:google_enable = 1 endif -if g:google != 0 +if g:google_enable != 0 augroup filetypedetect au WinEnter,BufNewFile,BufRead * call HighlightTooLongLines() augroup END diff --git a/.xmonad/xmonad.hs b/.xmonad/xmonad.hs index 5535544..7b89bca 100644 --- a/.xmonad/xmonad.hs +++ b/.xmonad/xmonad.hs @@ -1,4 +1,208 @@ import XMonad import XMonad.Config.Gnome +import XMonad.Operations + +import XMonad.Actions.Commands +import XMonad.Actions.CycleWS +import XMonad.Actions.DeManage +import qualified XMonad.Actions.DynamicWorkspaces as DW + +import XMonad.Hooks.DynamicLog as DL +import XMonad.Hooks.EwmhDesktops +import XMonad.Hooks.ManageDocks +import XMonad.Hooks.ManageHelpers -main = xmonad gnomeConfig +import qualified XMonad.StackSet as W + +import XMonad.Util.Loggers as LS +import XMonad.Util.Run +import XMonad.Util.WindowProperties +import XMonad.Util.XSelection + +import qualified XMonad.Util.EZConfig as EZ +import qualified Data.Map as M + +main = xmonad gnomeConfig { + borderWidth = 4, + focusedBorderColor = "#00BFFF" + } + +{- +-- delKeys x = foldr M.delete (keys defaultConfig x) (keysToRemove x) +delKeys = keys defaultConfig +newKeys x = M.union (delKeys x) (myKeys x) + +myKeys :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ()) +myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $ + [ ((modMask .|. shiftMask, xK_r ), spawn "if type xmonad; then xmonad --recompile && xmonad --restart; else xmessage xmonad not in \\$PATH: \"$PATH\"; fi") -- %! Restart xmonad + ] + ++ + -- 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 .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f)) + | (key, sc) <- zip [xK_q, xK_w, xK_e] [0..] + , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]] + -} +{- Reference -- the originals + -- launching and killing programs + [ ((modMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf) -- %! Launch terminal + , ((modMask, xK_p ), spawn "dmenu_run") -- %! Launch dmenu + , ((modMask .|. shiftMask, xK_p ), spawn "gmrun") -- %! Launch gmrun + , ((modMask .|. shiftMask, xK_c ), kill) -- %! Close the focused window + + , ((modMask, xK_space ), sendMessage NextLayout) -- %! Rotate through the available layout algorithms + , ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf) -- %! Reset the layouts on the current workspace to default + + , ((modMask, xK_n ), refresh) -- %! Resize viewed windows to the correct size + + -- move focus up or down the window stack + , ((modMask, xK_Tab ), windows W.focusDown) -- %! Move focus to the next window + , ((modMask .|. shiftMask, xK_Tab ), windows W.focusUp ) -- %! Move focus to the previous window + , ((modMask, xK_j ), windows W.focusDown) -- %! Move focus to the next window + , ((modMask, xK_k ), windows W.focusUp ) -- %! Move focus to the previous window + , ((modMask, xK_m ), windows W.focusMaster ) -- %! Move focus to the master window + + -- modifying the window order + , ((modMask, xK_Return), windows W.swapMaster) -- %! Swap the focused window and the master window + , ((modMask .|. shiftMask, xK_j ), windows W.swapDown ) -- %! Swap the focused window with the next window + , ((modMask .|. shiftMask, xK_k ), windows W.swapUp ) -- %! Swap the focused window with the previous window + + -- resizing the master/slave ratio + , ((modMask, xK_h ), sendMessage Shrink) -- %! Shrink the master area + , ((modMask, xK_l ), sendMessage Expand) -- %! Expand the master area + + -- floating layer support + , ((modMask, xK_t ), withFocused $ windows . W.sink) -- %! Push window back into tiling + + -- increase or decrease number of windows in the master area + , ((modMask , xK_comma ), sendMessage (IncMasterN 1)) -- %! Increment the number of windows in the master area + , ((modMask , xK_period), sendMessage (IncMasterN (-1))) -- %! Deincrement the number of windows in the master area + + -- toggle the status bar gap + --, ((modMask , xK_b ), modifyGap (\i n -> let x = (XMonad.defaultGaps conf ++ 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 + , ((modMask .|. shiftMask, xK_q ), io (exitWith ExitSuccess)) -- %! Quit xmonad + , ((modMask , xK_q ), spawn "if type xmonad; then xmonad --recompile && xmonad --restart; else xmessage xmonad not in \\$PATH: \"$PATH\"; fi") -- %! Restart xmonad + ] + ++ + -- mod-[1..9] %! Switch to workspace N + -- mod-shift-[1..9] %! Move client to workspace N + [((m .|. modMask, k), windows $ f i) + | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9] + , (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 .|. modMask, 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)]] +-} + +keysToRemove :: XConfig Layout -> [(KeyMask, KeySym)] +keysToRemove XConfig{modMask = modm} = + [ (modm, xK_p ) + , (modm .|. shiftMask, xK_p ) + ] + +{- +myKeys :: XConfig Layout -> M.Map (KeyMask, KeySym) (X()) +myKeys conf = EZ.mkKeymap conf $(_emacsKeys conf) + + +_emacsKeys :: [(String, X())] +_emacsKeys = [ + ("M-q" +_emacsKeys :: XConfig Layout -> [(String, X())] +_emacsKeys conf = + [ -- Applications + {-("M-t", goto "terminals")-} + {-, ("M-S-t", runColourTerminal)-} + {-, ("M-v M-t", pasteTerminal)-} + {-, ("M-v M-d", manTerminal)-} + {-, ("M-i", goto "browsen")-} + {-, ("M-S-i", runBrowser)-} + {-, ("M-v M-i", pasteBrowser)-} + {-, ("M-p", runCmdLine)-} + {-, ("M-x", WD.changeDir P.defaultXPConfig)-} + {-, ("M-e", goto "muziek")-} + {--- , ("M-o", runMixer)-} + {-, ("M-h", runFileManager)-} + {-, ("M-s", goto "praten")-} + {-, ("M-m", goto "berichten")-} + {-, ("M-S-m", runMail)-} + {-, ("M-u", goto "agenda")-} + {-, ("M-0", goto "schutbord")-} + {-, ("M-w", goto "flim")-} + + -- mpd + {-, ("", io $ return . fromRight =<< MPD.withMPD MPD.toggle)-} + {-, ("", io $ return . fromRight =<< MPD.withMPD MPD.stop)-} + {-, ("", io $ return . fromRight =<< MPD.withMPD MPD.next)-} + {-, ("", io $ return . fromRight =<< MPD.withMPD MPD.previous)-} + {-, ("", spawn "amixer set Master 2-")-} + {-, ("", spawn "amixer set Master 2+")-} + {-, ("", spawn "amixer set Master toggle")-} + + -- couple of scripts to change brightness, very hardware specific to my laptop + -- brightness + {-, ("", spawn "lcd-brightness-inc")-} + {-, ("", spawn "lcd-brightness-dec")-} + + -- Layouts + , ("M-n", refresh) + , ("M-S-", setLayout $ XMonad.layoutHook conf) + , ("M-", sendMessage NextLayout) + , ("M-", windows W.focusDown) + , ("M-j", windows W.focusDown) + , ("M-k", windows W.focusUp) + , ("M-", windows W.focusMaster) + , ("M-S-", DwmP.dwmpromote) + , ("M-S-j", windows W.swapDown) + , ("M-S-k", windows W.swapUp) + , ("M-g", sendMessage Shrink) + , ("M-l", sendMessage Expand) + , ("M-r", withFocused $ windows . W.sink) + , ("M-,", sendMessage (IncMasterN 1)) + , ("M-.", sendMessage (IncMasterN (-1))) + + -- Toggle full screen + , ("M-", sendMessage ToggleStruts >> refresh) + + -- Windows + , ("M-[", PWork.workspacePrompt P.defaultXPConfig goto) + , ("M-]", PWin.windowPromptGoto P.defaultXPConfig) + ,("M-S-[", PWork.workspacePrompt P.defaultXPConfig shift) + + , ("M-c", kill) -- window + , ("M-S-c", WithAll.killAll) ] -- window + -- ++ + -- [ ("M-" ++ [num], goto name) + -- | (name, num) <- + -- zip _workspaces (['1' .. '9'] ++ ['0'])] + + -- -- Workspaces + -- ++ + -- [ ("M-S-" ++ [num], shift name) + -- | (name, num) <- + -- zip _workspaces (['1' .. '9'] ++ ['0'])] + ++ + [ ("M-", moveTo Next NonEmptyWS) + , ("M-", moveTo Prev NonEmptyWS) + , ("M-S-", moveTo Next EmptyWS) + , ("M-S-", moveTo Prev EmptyWS) + -- Toggle between current and previous + , ("M-`", toggleWS) + + , ("M-S-n", PI.inputPrompt P.defaultXPConfig "New Workspace:" PI.?+ newWorkspaceDir) + , ("M-S-", WithAll.killAll >> DW.removeWorkspace) --buggy, messes with focus and creates flicker, needs to be fixed + , ("M-S-r", DW.renameWorkspace P.defaultXPConfig) + + -- -- Commands + -- , ("M-y", runCommand _commands) + + -- -- Remember + , ("M1-C-r", runRemember) + -- xmonad + , ("M1-q", restartXMonad)] +-}