----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---INFORMATIONS ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- informations = { Author = Graawr -- , Version = XMonad 0.10 <+> ghc 7.4 <+> dzen-0.8.5 -- , Updated = August 17 2013 -- } ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---IMPORTS ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- Base import XMonad import Data.Maybe (isJust) import XMonad.Config.Azerty import System.IO (hPutStrLn) import System.Exit (exitSuccess) import qualified XMonad.StackSet as W -- Utilities import XMonad.Util.EZConfig (additionalKeysP, additionalMouseBindings) import XMonad.Util.NamedScratchpad (NamedScratchpad(NS), namedScratchpadManageHook, namedScratchpadAction, customFloating) import XMonad.Util.Run (safeSpawn, unsafeSpawn, runInTerm, spawnPipe) import XMonad.Util.SpawnOnce -- Hooks import XMonad.Hooks.DynamicLog (dynamicLogWithPP, defaultPP, dzenColor, pad, shorten, PP(..)) import XMonad.Hooks.ManageDocks (avoidStruts, ToggleStruts(..)) import XMonad.Hooks.Place (placeHook, withGaps, smart) import XMonad.Hooks.InsertPosition import XMonad.Hooks.FloatNext (floatNextHook, toggleFloatNext, toggleFloatAllNew) -- Actions import XMonad.Actions.Promote import XMonad.Actions.RotSlaves (rotSlavesDown, rotAllDown) import XMonad.Actions.CopyWindow (kill1, copyToAll, killAllOtherCopies, runOrCopy) import XMonad.Actions.WindowGo (runOrRaise, raiseMaybe) import XMonad.Actions.WithAll (sinkAll, killAll) import XMonad.Actions.CycleWS (moveTo, shiftTo, WSType(..)) import XMonad.Actions.GridSelect (GSConfig(..), goToSelected, bringSelected, colorRangeFromClassName, buildDefaultGSConfig) import XMonad.Actions.DynamicWorkspaces (addWorkspacePrompt, removeEmptyWorkspace) import XMonad.Actions.Warp (warpToWindow, banishScreen, Corner(LowerRight)) import XMonad.Actions.MouseResize import qualified XMonad.Actions.ConstrainedResize as Sqr -- Layouts modifiers import XMonad.Layout.PerWorkspace (onWorkspace) import XMonad.Layout.Renamed (renamed, Rename(CutWordsLeft, Replace)) import XMonad.Layout.WorkspaceDir import XMonad.Layout.Spacing (spacing) import XMonad.Layout.Minimize import XMonad.Layout.Maximize import XMonad.Layout.BoringWindows (boringWindows) import XMonad.Layout.LimitWindows (limitWindows, increaseLimit, decreaseLimit) import XMonad.Layout.WindowArranger (windowArrange, WindowArrangerMsg(..)) import XMonad.Layout.Reflect (reflectVert, reflectHoriz, REFLECTX(..), REFLECTY(..)) import XMonad.Layout.MultiToggle (mkToggle, single, EOT(EOT), Toggle(..), (??)) import XMonad.Layout.MultiToggle.Instances (StdTransformers(NBFULL, MIRROR, NOBORDERS)) import qualified XMonad.Layout.ToggleLayouts as T (toggleLayouts, ToggleLayout(Toggle)) -- Layouts import XMonad.Layout.GridVariants (Grid(Grid)) import XMonad.Layout.SimplestFloat import XMonad.Layout.OneBig import XMonad.Layout.ResizableTile import XMonad.Layout.ZoomRow (zoomRow, zoomIn, zoomOut, zoomReset, ZoomMessage(ZoomFullToggle)) import XMonad.Layout.IM (withIM, Property(Role)) -- Prompts import XMonad.Prompt (defaultXPConfig, XPConfig(..), XPPosition(Top), Direction1D(..)) ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---SETTINGS ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- Styles myFont = "-artwiz-snap-normal-*-normal-*-10-*-*-*-*-*-*-*" myBorderWidth = 1 myColorBG = "#151515" myColorWhite = "#ebebeb" myColorRed = "#C3143B" myColorGray = "#545454" myColorDarkgray = "#353535" -- Settings myModMask = mod4Mask myTerminal = "urxvtc_mod -name urxvt" -- Prompts colors myPromptConfig = defaultXPConfig { font = myFont , bgColor = myColorBG , fgColor = myColorRed , bgHLight = myColorBG , fgHLight = myColorWhite , borderColor = myColorBG , promptBorderWidth = myBorderWidth , height = 20 , position = Top , historySize = 0 } -- Grid selector colors myGridConfig = colorRangeFromClassName (0x15,0x15,0x15) -- lowest inactive bg (0x15,0x15,0x15) -- highest inactive bg (0xC3,0x14,0x3B) -- active bg (0x54,0x54,0x54) -- inactive fg (0xEB,0xEB,0xEB) -- active fg myGSConfig colorizer = (buildDefaultGSConfig myGridConfig) { gs_cellheight = 65 , gs_cellwidth = 120 , gs_cellpadding = 10 , gs_font = myFont } ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---SCRATCHPADS ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- myScratchpads = [ NS "terminal" "urxvtc_mod -name terminal -e tmux attach" (resource =? "terminal") myPosition , NS "music" "urxvtc_mod -name music -e ncmpcpp" (resource =? "music") myPosition , NS "rtorrent" "urxvtc_mod -name rtorrent -e rtorrent" (resource =? "rtorrent") myPosition , NS "wcalc" "urxvtc_mod -name wcalc -e wcalc" (resource =? "wcalc") myPosition ] where myPosition = customFloating $ W.RationalRect (1/3) (1/3) (1/3) (1/3) ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---KEYBINDINGS ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- myKeys = -- Xmonad [ ("M-C-r", spawn "xmonad --recompile") , ("M-M1-r", spawn "xmonad --restart") , ("M-S-r", spawn "pkill dzen && xmonad --restart") , ("M-M1-q", io exitSuccess) -- Windows , ("M-r", refresh) , ("M-q", kill1) , ("M-C-q", killAll) , ("M-S-q", killAll >> moveTo Next nonNSP >> killAll >> moveTo Next nonNSP >> killAll >> moveTo Next nonNSP >> killAll >> moveTo Next nonNSP) , ("M-", withFocused $ windows . W.sink) , ("M-S-", sinkAll) , ("M-z", windows W.focusMaster) , ("M1-", windows W.focusDown) -- Mouse special button , ("M1-", windows W.focusDown) , ("M-a", windows W.swapDown) , ("M-e", windows W.swapUp) , ("M1-S-", rotSlavesDown) , ("M1-C-", rotAllDown) , ("M-", promote) , ("M-*", withFocused minimizeWindow) , ("M-S-*", sendMessage RestoreNextMinimizedWin) , ("M-!", withFocused (sendMessage . maximizeRestore)) , ("M-$", toggleFloatNext) , ("M-S-$", toggleFloatAllNew) , ("M-;", warpToWindow (1/2) (1/2)) , ("M1-;", banishScreen LowerRight) , ("M-S-s", windows copyToAll) , ("M-C-s", killAllOtherCopies) , ("M-C-M1-", sendMessage Arrange) , ("M-C-M1-", sendMessage DeArrange) , ("M-", sendMessage (MoveUp 10)) , ("M-", sendMessage (MoveDown 10)) , ("M-", sendMessage (MoveRight 10)) , ("M-", sendMessage (MoveLeft 10)) , ("M-S-", sendMessage (IncreaseUp 10)) , ("M-S-", sendMessage (IncreaseDown 10)) , ("M-S-", sendMessage (IncreaseRight 10)) , ("M-S-", sendMessage (IncreaseLeft 10)) , ("M-C-", sendMessage (DecreaseUp 10)) , ("M-C-", sendMessage (DecreaseDown 10)) , ("M-C-", sendMessage (DecreaseRight 10)) , ("M-C-", sendMessage (DecreaseLeft 10)) -- Layouts , ("M-S-", sendMessage ToggleStruts) , ("M-d", asks (XMonad.layoutHook . config) >>= setLayout) , ("M-", sendMessage NextLayout) , ("M-S-f", sendMessage (T.Toggle "float")) , ("M-S-g", sendMessage (T.Toggle "gimp")) , ("M-S-x", sendMessage $ Toggle REFLECTX) , ("M-S-y", sendMessage $ Toggle REFLECTY) , ("M-S-m", sendMessage $ Toggle MIRROR) , ("M-S-b", sendMessage $ Toggle NOBORDERS) , ("M-S-d", sendMessage (Toggle NBFULL) >> sendMessage ToggleStruts) , ("M-", sendMessage (IncMasterN 1)) , ("M-", sendMessage (IncMasterN (-1))) , ("M-S-", decreaseLimit) , ("M-S-", increaseLimit) , ("M-h", sendMessage Shrink) , ("M-l", sendMessage Expand) , ("M-j", sendMessage MirrorShrink) , ("M-k", sendMessage MirrorExpand) , ("M-S-l", sendMessage zoomIn) , ("M-S-h", sendMessage zoomOut) , ("M-y", sendMessage zoomReset) , ("M-s", sendMessage ZoomFullToggle) -- Workspaces , ("", moveTo Next nonNSP) , ("", moveTo Prev nonNSP) , ("M-", moveTo Next nonEmptyNonNSP) , ("M-", moveTo Prev nonEmptyNonNSP) , ("M-S-", shiftTo Next nonNSP >> moveTo Next nonNSP) , ("M-S-", shiftTo Prev nonNSP >> moveTo Prev nonNSP) , ("M-M1-", addWorkspacePrompt myPromptConfig) , ("M-M1-",removeEmptyWorkspace) -- Apps , ("M-", spawn "urxvtc_mod -name urxvt") , ("M-S-", spawn "urxvtc_mod -name anyWorkspace") , ("M-", spawn "exe=`dmenu_run -nb '#151515' -nf '#545454' -sb '#C3143B' -sf '#ebebeb' -p 'run:' -i` && eval \"exec $exe\"") , ("C-", spawn "pkill dunst") , ("M-g", spawn "magnet") , ("M-x", safeSpawn "i3lock" ["-ubi", "/home/logan/images/accueil.png"]) , ("M-f", raiseMaybe (runInTerm "-name ranger" "ranger") (resource =? "ranger")) , ("M-t", raiseMaybe (runInTerm "-name newsbeuter" "newsbeuter") (resource =? "newsbeuter")) , ("M-m", raiseMaybe (runInTerm "-name mutt" "mutt") (resource =? "mutt")) , ("M-v", raiseMaybe (runInTerm "-name weechat" "weechat-curses") (resource =? "weechat")) , ("M-o", raiseMaybe (runInTerm "-name htop" "htop") (resource =? "htop") >> warpToWindow (1/2) (1/2)) , ("M-w", runOrRaise "iceweasel" (resource =? "Navigator")) , ("M-C-f", runOrRaise "thunar" (resource =? "thunar")) , ("M-C-", runOrRaise "trayerd" (resource =? "trayer")) , ("M-M1-f", runOrCopy "urxvtc_mod -name ranger -e ranger" (resource =? "ranger")) , ("M-M1-t", runOrCopy "urxvtc_mod -name newsbeuter -e newsbeuter" (resource =? "newsbeuter")) , ("M-M1-m", runOrCopy "urxvtc_mod -name mutt -e mutt" (resource =? "mutt")) , ("M-M1-v", runOrCopy "urxvtc_mod -name weechat -e weechat-curses" (resource =? "weechat")) , ("M-M1-o", runOrCopy "urxvtc_mod -name htop -e htop" (resource =? "htop") >> warpToWindow (1/2) (1/2)) , ("M-M1-w", runOrCopy "iceweasel" (resource =? "Navigator")) , ("M-C-A-f", runOrCopy "thunar" (resource =? "thunar")) , ("M-M1-C-", runOrCopy "trayerd" (resource =? "trayer")) -- Prompts , ("M-,", goToSelected $ myGSConfig myGridConfig) , ("M-S-,", bringSelected $ myGSConfig myGridConfig) , ("M-:", changeDir myPromptConfig) -- Scratchpads , ("M-", namedScratchpadAction myScratchpads "terminal" >> warpToWindow (1/2) (1/2)) , ("M-c", namedScratchpadAction myScratchpads "wcalc" >> warpToWindow (1/2) (1/2)) , ("M-b", namedScratchpadAction myScratchpads "rtorrent" >> warpToWindow (1/2) (1/2)) , ("M-n", namedScratchpadAction myScratchpads "music" >> warpToWindow (1/2) (1/2)) , ("", namedScratchpadAction myScratchpads "music" >> warpToWindow (1/2) (1/2)) -- Multimedia Keys , ("", spawn "ncmpcpp toggle") , ("", spawn "ncmpcpp prev") , ("", spawn "ncmpcpp next") , ("", spawn "amixer set Master toggle") , ("", spawn "amixer set Master 5%- unmute") , ("", spawn "amixer set Master 5%+ unmute") , ("", safeSpawn "iceweasel" ["/home/logan/.config/infoconf.html"]) , ("", safeSpawn "iceweasel" ["https://www.duckduckgo.com/"]) , ("", runOrRaise "icedove" (resource =? "icedove")) , ("", runOrRaise "speedcrunch" (resource =? "speedcrunch")) , ("", spawn "toggleeject") , ("", spawn "scrotd 0") ] where nonNSP = WSIs (return (\ws -> W.tag ws /= "NSP")) nonEmptyNonNSP = WSIs (return (\ws -> isJust (W.stack ws) && W.tag ws /= "NSP")) myMouseKeys = [ ((mod4Mask .|. shiftMask, button3), \w -> focus w >> Sqr.mouseResizeWindow w True) ] ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---WORKSPACES ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- myWorkspaces = ["term", "web", "media", "syst"] myManageHook = placeHook (withGaps (20,12,12,12) (smart (0.5,0.5))) <+> insertPosition End Newer <+> floatNextHook <+> namedScratchpadManageHook myScratchpads <+> (composeAll . concat $ [ [ resource =? r --> doF (W.view "term" . W.shift "term") | r <- myTermApps ] , [ resource =? r --> doF (W.view "web" . W.shift "web") | r <- myWebApps ] , [ resource =? r --> doF (W.view "media" . W.shift "media") | r <- myMediaApps ] , [ resource =? r --> doF (W.view "syst" . W.shift "syst") | r <- mySystApps ] , [ resource =? r --> doFloat | r <- myFloatApps ] , [ className =? c --> ask >>= doF . W.sink | c <- myUnfloatApps ] ]) <+> manageHook defaultConfig where myTermApps = ["urxvt", "xterm", "xfce4-terminal", "xfontsel"] myWebApps = ["Navigator", "newsbeuter", "mutt", "luakit", "midori", "Mail", "dwb"] myMediaApps = ["easytag", "sonata", "comix", "inkscape", "vlc", "zathura", "gnome-mplayer", "Audacity", "hotot", "ncmpcpp", "weechat", "mplayer", "gimp", "gimp-2.8"] mySystApps = ["ranger", "thunar", "Thunar", "lxappearance", "geany", "nitrogen", "Qt-subapplication", "gparted", "bleachbit"] myFloatApps = ["Dialog", "htop", "file-roller", "nitrogen", "display", "feh", "xmessage", "trayer"] myUnfloatApps = ["Gimp"] ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---LAYOUTS ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- myLayoutHook = avoidStruts $ mouseResize $ windowArrange $ T.toggleLayouts float $ mkToggle (NBFULL ?? NOBORDERS ?? EOT) $ renamed [CutWordsLeft 4] $ maximize $ minimize $ boringWindows $ spacing 12 $ onWorkspace "term" myTermLayout $ onWorkspace "web" myWebLayout $ onWorkspace "media" myMediaLayout $ onWorkspace "syst" mySystLayout myDefaultLayout where myTermLayout = workspaceDir "~" $ oneBig ||| tiled ||| lined ||| grid myWebLayout = workspaceDir "~/téléchargements" $ monocle ||| oneBig ||| lined myMediaLayout = workspaceDir "~/vidéos" $ T.toggleLayouts gimp $ monocle ||| oneBig ||| tiled ||| lined mySystLayout = workspaceDir "~" $ tiled ||| oneBig ||| monocle ||| lined ||| grid myDefaultLayout = workspaceDir "/" $ float ||| oneBig ||| tiled ||| lined ||| monocle ||| grid oneBig = renamed [Replace "oneBig"] $ limitWindows 6 $ Mirror $ mkToggle (single MIRROR) $ mkToggle (single REFLECTX) $ mkToggle (single REFLECTY) $ OneBig (2/3) (2/3) tiled = renamed [Replace "tiled"] $ limitWindows 5 $ reflectVert $ mkToggle (single MIRROR) $ mkToggle (single REFLECTX) $ ResizableTall 1 (3/100) (2/3) [2/3] lined = renamed [Replace "lined"] $ limitWindows 3 $ Mirror $ mkToggle (single MIRROR) zoomRow monocle = renamed [Replace "monocle"] $ limitWindows 20 Full grid = renamed [Replace "grid"] $ limitWindows 12 $ mkToggle (single MIRROR) $ Grid (16/10) float = renamed [Replace "float"] $ limitWindows 20 simplestFloat gimp = renamed [Replace "gimp"] $ limitWindows 3 $ withIM 0.11 (Role "gimp-toolbox") $ reflectHoriz $ withIM 0.15 (Role "gimp-dock") Full ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---STATUSBAR ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- myBitmapsDir = "/home/logan/.xmonad/statusbar/icons" myXmonadBarL = "dzen2 -x '0' -y '0' -h '16' -w '1000' -ta 'l' -fg '"++myColorWhite++"' -bg '"++myColorBG++"' -fn '"++myFont++"' " myXmonadBarR = "conky -c /home/logan/.xmonad/statusbar/conky_dzen | dzen2 -x '1000' -y '0' -w '680' -h '16' -ta 'r' -bg '"++myColorBG++"' -fg '"++myColorWhite++"' -fn '"++myFont++"'" myLogHook h = dynamicLogWithPP $ defaultPP { ppOutput = hPutStrLn h , ppCurrent = dzenColor myColorWhite myColorRed . pad , ppHidden = dzenColor myColorWhite myColorBG . noScratchPad , ppHiddenNoWindows = dzenColor myColorGray myColorBG . noScratchPad , ppSep = dzenColor myColorRed myColorBG " | " , ppWsSep = dzenColor myColorRed myColorBG "" , ppTitle = dzenColor myColorWhite myColorBG . shorten 75 , ppOrder = \(ws:l:t:_) -> [ws,l,t] , ppLayout = dzenColor myColorWhite myColorBG . (\x -> case x of "oneBig" -> "^i("++myBitmapsDir++"/mini/nbstack.xbm)" "tiled" -> "^i("++myBitmapsDir++"/mini/tile.xbm)" "lined" -> "^i("++myBitmapsDir++"/mini/bstack2.xbm)" "monocle" -> "^i("++myBitmapsDir++"/mini/monocle.xbm)" "grid" -> "^i("++myBitmapsDir++"/mini/grid.xbm)" "float" -> "^i("++myBitmapsDir++"/mini/float.xbm)" "gimp" -> "^i("++myBitmapsDir++"/fox.xbm)" "Full" -> "^i("++myBitmapsDir++"/mini/monocle2.xbm)" _ -> x ) } where noScratchPad ws = if ws == "NSP" then "" else pad ws ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---AUTOSTART ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- myStartupHook = do spawnOnce "xsetroot -cursor_name left_ptr &" spawnOnce "sh ~/.fehbg &" spawnOnce "mpd &" spawnOnce "unclutter &" spawnOnce "compton -bc -t -8 -l -9 -r 6 -o 0.7 -m 1.0 &" spawnOnce "xautolock -time 15 -locker 'i3lock -ubi /home/logan/images/accueil.png' &" spawnOnce "gnome-keyring-daemon --start --components=pkcs11 &" spawnOnce "urxvtc_mod -name terminal -e tmux &" ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---CONFIG ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- main = do dzenLeftBar <- spawnPipe myXmonadBarL dzenRightBar <- spawnPipe myXmonadBarR xmonad $ azertyConfig { modMask = myModMask , terminal = myTerminal , manageHook = myManageHook , layoutHook = myLayoutHook , logHook = myLogHook dzenLeftBar , startupHook = myStartupHook , workspaces = myWorkspaces , borderWidth = myBorderWidth , normalBorderColor = myColorDarkgray , focusedBorderColor = myColorWhite } `additionalKeysP` myKeys `additionalMouseBindings` myMouseKeys