Skip to content

Instantly share code, notes, and snippets.

@zenlinux
Created February 28, 2016 11:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zenlinux/68704ba5c2c92ab97b48 to your computer and use it in GitHub Desktop.
Save zenlinux/68704ba5c2c92ab97b48 to your computer and use it in GitHub Desktop.
Xmonad.hs works with lemonbar( xft+slant ) version from https://github.com/neeasade/bar/tree/slant-xft. The setup below works great but if I try to use "powerline symbols" like this "" # Powerline separators it wont work.
import XMonad hiding ( (|||) )
import Data.List -- clickable workspaces
import Graphics.X11.ExtraTypes.XF86
import System.IO (hPutStrLn)
--import XMonad.Actions.CycleWS -- nextWS, prevWS
import XMonad.Actions.FloatKeys
import XMonad.Actions.TagWindows
import XMonad.Actions.WindowGo
import XMonad.Actions.WithAll
import XMonad.Hooks.DynamicLog hiding (xmobar, xmobarPP, xmobarColor, sjanssenPP, byorgeyPP)
import XMonad.Hooks.EwmhDesktops hiding (fullscreenEventHook)
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.Minimize -- for minimizeEventHook
import XMonad.Hooks.SetWMName
import XMonad.Hooks.UrgencyHook
import XMonad.Hooks.XPropManage
import XMonad.Layout.BoringWindows
import XMonad.Layout.Fullscreen
import XMonad.Layout.Gaps
import XMonad.Layout.Grid
import XMonad.Layout.LayoutCombinators
import XMonad.Layout.Maximize (maximize, maximizeRestore)
import XMonad.Layout.Minimize (minimize, minimizeWindow, MinimizeMsg(RestoreNextMinimizedWin))
import XMonad.Layout.Named
import XMonad.Layout.NoBorders
-- import XMonad.Layout.PerWorkspace
import XMonad.Layout.ResizableTile
import XMonad.Layout.SimplestFloat
import XMonad.Layout.Spacing
import XMonad.Layout.Tabbed
import XMonad.Layout.WindowNavigation
import XMonad.ManageHook
import XMonad.Prompt
import XMonad.Prompt.Input
import XMonad.Prompt.RunOrRaise
import XMonad.Prompt.Window
import XMonad.Util.Dmenu
import XMonad.Util.EZConfig
import XMonad.Util.Font(Align(AlignCenter))
import XMonad.Util.Loggers
import XMonad.Util.NamedScratchpad
import XMonad.Util.Run(spawnPipe,safeSpawn)
import qualified XMonad.Actions.FlexibleResize as FlexibleResize
import qualified XMonad.StackSet as W
-- namedscratchpad
-- Most important feature of Xmonad for me.
scratchpads = [
NS "mHtop" "xterm -e htop" (title =? "htop") defaultFloating,
NS "notes" "gvim --role notes ~/notes.txt" (role =? "notes") (customFloating $ W.RationalRect (1/6) (1/6) (2/3) (2/3)),
NS "mEmacs" "emacs" (className =? "Emacs" ) nonFloating,
NS "mTerminator" "terminator" (className =? ".terminator-wrapped" ) nonFloating
] where role = stringProperty "WM_WINDOW_ROLE"
-- Theme for tabs
myTabTheme = defaultTheme {
activeColor = "#2199ee"
, inactiveColor = "grey"
, urgentColor = "red"
, activeBorderColor = "#2199ee"
, inactiveBorderColor = "white"
, activeTextColor = "black"
, inactiveTextColor = "black"
, fontName = "xft:Century Gothic-10"
}
-- Theme for Prompt
myPromptTheme :: XPConfig
myPromptTheme = defaultXPConfig {
font = "xft:Inconsolata-11"
, height = 30
, position = Bottom
, promptBorderWidth = 0
, promptKeymap = emacsLikeXPKeymap
-- more fuzzy searching, match anywhere
, searchPredicate = isInfixOf
-- always highlight a result, so I can hit enter any time
, alwaysHighlight = True
}
-- shell prompt theme
mySP = defaultXPConfig {
font = "xft:Inconsolata-11:pixelsize=14"
--font = "xft:DejaVu Sans Mono:pixelsize=14"
, bgColor = "#0c1021"
, fgColor = "#f8f8f8"
, fgHLight = "#f8f8f8"
, bgHLight = "steelblue3"
, borderColor = "DarkOrange"
, promptBorderWidth = 1
, position = Top
, height = 22
, defaultText = []
}
myAutoSP = mySP { autoComplete = Just 1000 }
myWaitSP = mySP { autoComplete = Just 1000000 }
myLayoutPrompt = inputPromptWithCompl myAutoSP "Layout"
(mkComplFunFromList' ["1.mtabbed", "2.mtiled", "3.mfullscreen", "4.mgrid"]) ?+ \l ->
sendMessage $ JumpToLayout $ drop 2 l
--
-- DECLARE WORKSPACES RULES
--
myLayout = maximize . minimize $
windowNavigation $
boringWindows $
smartBorders (
aTiled |||
aFullScreen |||
aGrid |||
aFullScreen |||
aTabbed |||
aFullScreen )
where
aTabbed = named "mtabbed" ( avoidStruts $ gaps [(U, 12), (R, 8), (L, 8), (D, 8)] $ tabbed shrinkText myTabTheme )
aGrid = named "mgrid" ( gaps [(U, 12), (R, 8), (L, 8), (D, 8)] $ avoidStruts $ spacing 8 $ Grid)
aTiled = named "mtiled" ( gaps [(U, 12), (R, 8), (L, 8), (D, 8)] $ avoidStruts $ spacing 8 $ ResizableTall nmaster delta ratio [] )
aFullScreen = named "mfullscreen" (noBorders(fullscreenFull Full))
-- Default number of windows in master pane
nmaster = 1
-- Percent of the screen to increment when resizing
delta = 5/100
-- Default proportion of the screen taken up by main pane
ratio = toRational (2/(1 + sqrt 5 :: Double))
-- WORKSPACE DEFINITIONS
--myWorkspaces = clickable $ [
-- " 1:Term "
-- ," 2:Vim "
-- ," 3:Files "
-- ," 4:Pdf "
-- ," 5 "
-- ," 6:Gimp "
-- ," 7:Inkscape "
-- ," 8 "
-- ," 9 "]
-- where clickable l = [ "^ca(1,xdotool key alt+" ++ show (n) ++ ")" ++ ws ++ "^ca()" |
-- (i,ws) <- zip [1..] l,
-- let n = i ]
myWorkspaces = [
" 1:Term "
," 2:Vim "
," 3:Files "
," 4:Pdf "
," 5 "
," 6:Gimp "
," 7:Inkscape "
," 8 "
," 9 "]
-- APPLICATION SPECIFIC RULES
myManageHook = composeAll [
resource =? "dmenu" --> doFloat
, resource =? "skype" --> doFloat
, resource =? "feh" --> doIgnore
, resource =? "dzen2" --> doIgnore
, className =? "dzen2" --> doIgnore
, resource =? "dzen" --> doIgnore
, resource =? "lemonbar" --> doIgnore
, resource =? "bar" --> doIgnore
, className =? "lemonbar" --> doIgnore
, className =? "bar" --> doIgnore
, className =? "Pcmanfm" --> doShift (myWorkspaces !! 2)
, resource =? ".zathura-wrapped"--> doShift (myWorkspaces !! 3)
, className =? "Gimp" --> doShift (myWorkspaces !! 5)
, className =? ".inkscape-wrapped" --> doShift (myWorkspaces !! 6)
, className =? "Filezilla" --> doShift (myWorkspaces !! 7)
, resource =? "transmission" --> doShift (myWorkspaces !! 7)
, resource =? "mplayer" --> doShift (myWorkspaces !! 8)
, className =? "mplayer2" --> doShift (myWorkspaces !! 8)
, manageDocks
]
xPropMatches :: [XPropMatch]
xPropMatches = [
( [ (wM_CLASS, any ("Firefox" `isInfixOf`))], pmX(setTags (words("be bt"))))
,( [ (wM_CLASS, any (".terminator-wrapped" ==))], pmX(addTag "bt"))
,( [ (wM_CLASS, any ("emacs" ==))], pmX(addTag "be"))
,( [ (wM_CLASS, any ("Emacs" ==))], pmX(addTag "be"))
]
newManageHook = xPropManageHook xPropMatches <+> myManageHook <+> manageHook defaultConfig
--
-- DZEN LOG RULES for workspace names, layout image, current program title
--
myLogHook h = dynamicLogWithPP ( defaultPP {
ppCurrent = wrap "%{R}" "%{R}" . pad
, ppVisible = wrap " " " " . pad
, ppHidden = wrap "%{+u}" "%{-u}" . pad
, ppHiddenNoWindows = wrap "%{F#ecff22}" "%{F#2199ee}" . pad
, ppWsSep = "%{-u} "
, ppSep = " "
-- , ppTitle = wrap "%{F#00ff00}" "%{r}" . shorten 70 . pad
, ppTitle = wrap "%{F#00ff00}" "%{r}" .
(\x -> case x of
"" -> "ZenRatio"
_ -> x
)
, ppLayout = wrap " " " " .
(\x -> case x of
"Maximize Minimize mfullscreen" -> " %{B#00ff00}%{F#000000} full %{B#000000}%{F#2199ee} "
"Maximize Minimize mgrid" -> " %{B#00ff00}%{F#000000} grid %{B#000000}%{F#2199ee} "
"Maximize Minimize mtabbed" -> " %{B#00ff00}%{F#000000} tabb %{B#000000}%{F#2199ee} "
"Maximize Minimize mtiled" -> " %{B#00ff00}%{F#000000} tile %{B#000000}%{F#2199ee} "
_ -> "%{B#00ff00}%{F#000000}" ++ x ++ "%{B#000000}%{F#2199ee}"
)
-- , ppOrder = \(ws:l:t:x) -> [" "] ++ x ++ [l, ws, t]
-- , ppOrder = \(ws:l:t:x) -> x ++ [l, ws, t]
, ppOrder = \(ws:l:t:x) -> [l, ws, " " , t] ++ x
, ppOutput = hPutStrLn h
, ppExtras = [ date "%a %b %d %H:%M "]
})
--
-- Spawn pipes and menus on boot, set default settings
--
-- select font with xfontsel
--myXmonadlemonbar = "bar -p -f \"-gbdfed-creep-*-*-*-*-16-*-*-*-*-*-*-*\" -B \"#FF2B2B2B\" | bash "
myXmonadlemonbar = "/home/ronin/bin/lemonbar -g 1332x30+14+14 -d -p -f \"Century Gothic:size=11\" -F \"#2199ee\" -f \"Monofur for Powerline:size=11\" -B \"#000000\" -u 4 -U \"#00ff00\" | bash "
main = do
lemonbar <- spawnPipe myXmonadlemonbar
xmonad $ ewmh defaultConfig {
terminal = myTerminal
, borderWidth = 8
, normalBorderColor = "#000000"
, focusedBorderColor = "#2199ee"
, modMask = mod1Mask
, layoutHook = avoidStruts $ myLayout
, workspaces = myWorkspaces
, manageHook = newManageHook
, handleEventHook = docksEventHook <+> fullscreenEventHook <+> minimizeEventHook
, startupHook = return () >> checkKeymap defaultConfig myKeyConfig >> setWMName "LG3D"
, logHook = myLogHook lemonbar
}
--
-- Keyboard options
--
`additionalKeysP` myKeyConfig
myKeyConfig :: [([Char], X ())]
myKeyConfig = [
("M1-S-a", withFocused (keysResizeWindow (-20,0)(0,0)))
,("M1-S-c", return())
,("M1-S-d", withFocused (keysResizeWindow (0,-20)(0,0)))
,("M1-S-f", withFocused (keysResizeWindow (20,0)(0,0)))
,("M1-S-h", sendMessage MirrorExpand)
,("M1-S-l", sendMessage MirrorShrink)
,("M1-S-m", namedScratchpadAction scratchpads "mEmacs")
,("M1-S-n", namedScratchpadAction scratchpads "mTerminator")
,("M1-S-s", withFocused (keysResizeWindow (0,20)(0,0)))
,("M1-S-t", spawn "urxvt -e tmux")
,("M1-S-x", kill)
,("M1-a", withFocused (keysMoveWindow (-20,0)))
,("M1-b", raiseMaybe (safeSpawn "firefox" []) (className =? "Firefox"))
,("M1-d", withFocused (keysMoveWindow (0,-20)))
,("M1-f", withFocused (keysMoveWindow (20,0)))
,("M1-g", raiseMaybe (safeSpawn "gimp" []) (className =? "Gimp"))
,("M1-i", raiseMaybe (safeSpawn "inkscape" []) (className =? ".inkscape-wrapped"))
,("M1-m", raiseMaybe (safeSpawn "emacs" []) (className =? "Emacs"))
,("M1-n", raiseMaybe (safeSpawn "terminator" []) (className =? ".terminator-wrapped"))
,("M1-q", spawn "killall lemonbar; killall bar; killall dzen2; cd ~/.xmonad; ghc -threaded xmonad.hs; mv xmonad xmonad-x86_64-linux; xmonad --restart" )
,("M1-s", withFocused (keysMoveWindow (0,20)))
,("M1-t", withFocused $ windows . W.sink)
,("M1-w", raiseMaybe (safeSpawn "pcmanfm" []) (className =? "Pcmanfm"))
,("M1-z", raiseMaybe (safeSpawn "filezilla" []) (className =? "Filezilla"))
,("M4-C-s", tagPrompt myPromptTheme (\s -> withTaggedGlobalP s shiftHere))
,("M4-S-b", windowPromptBring myPromptTheme )
,("M4-S-g", windowPromptGoto myPromptTheme)
,("M4-S-n", sendMessage RestoreNextMinimizedWin)
,("M4-S-s", tagPrompt myPromptTheme (\s -> withFocused (addTag s)))
,("M4-S-t", tagPrompt myPromptTheme (\s -> focusUpTaggedGlobal s ))
,("M4-n", withFocused minimizeWindow)
,("M4-o f", sendMessage $ JumpToLayout "mfullscreen")
,("M4-o l", sendMessage $ JumpToLayout "mtiled")
,("M4-o t", sendMessage $ JumpToLayout "mtabbed")
,("M4-p", myLayoutPrompt)
,("M4-t", sinkAll)
-- ,("M4-j", windows focusDown)
-- ,("M4-k", windows focusUp)
]
-- Define constants
myTerminal = "urxvt"
-- myBitmapsDir = "~/.xmonad/dzen2/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment