Skip to content

Instantly share code, notes, and snippets.

@TrevorBramble
Created September 22, 2015 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TrevorBramble/cc4c112a70a0e221dbe1 to your computer and use it in GitHub Desktop.
Save TrevorBramble/cc4c112a70a0e221dbe1 to your computer and use it in GitHub Desktop.
import XMonad
import Data.Monoid
import Data.Ratio ((%))
import System.Exit
import System.IO
--import XMonad.Actions.Navigation2D
import XMonad.Hooks.DynamicLog (dynamicLogWithPP, xmobarPP, ppOutput, ppCurrent, ppUrgent,
ppVisible, ppTitle, ppLayout, xmobarColor, wrap, shorten, statusBar)
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.SetWMName
import XMonad.Hooks.UrgencyHook
import XMonad.Layout.IM
import XMonad.Layout.NoBorders
import XMonad.Layout.Spacing
import XMonad.Layout.PerWorkspace
import XMonad.Layout.Named
import XMonad.Layout.ThreeColumns
import XMonad.Util.Run(spawnPipe)
import Graphics.X11.ExtraTypes.XF86
import qualified XMonad.StackSet as W
import qualified Data.Map as M
-------------------------------------
myTerminal = "urxvtc"
myFileManager = "thunar"
myBrowser = "chromium %u"
myDmenu = "$(echo -e \"pico8\" | dmenu_path | yeganesh -- -nb '#0a0f14' -nf '#98d1ce' -sb '#093748' -sf '#26a98b' -f -i -fn '-*-terminus-medium-r-normal-*-18-180-72-72-c-*-iso8859-*')"
myExit = "exitx"
myPrintscreen = "gnome-screenshot"
myScreenshot = "gnome-screenshot -i"
myTrayer = "killall trayer; sleep 2s; trayer --edge top --align right --SetDockType true --SetPartialStrut true --margin 170 --widthtype request --expand false --heighttype pixel --height 20 --transparent true --alpha 255 --padding 0 --distance 1"
myDropbox = "sleep 2s; dropbox start"
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = True
myBorderWidth = 1
myNormalBorderColor = "#093748"
myFocusedBorderColor = "#599caa"
xmobarCurrentWorkspaceColor = "#26a98b"
xmobarLayoutColor = "#98d1ce"
xmobarTitleColor = "#26a98b"
xmobarUrgentHighColor = "#c33027"
xmobarUrgentLowColor = "#d26939"
-- mod1Mask = "left alt", mod3Mask = "right alt", mod4mask = "super"
myModMask = mod4Mask
myWorkspaces = ["1","2","3","4","5","6","7","8","9"]
myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
-- launch a terminal
[ ((modm, xK_apostrophe ), spawn $ XMonad.terminal conf)
-- launch a web browser
, ((modm .|. shiftMask, xK_backslash ), spawn myBrowser)
-- launch dmenu
, ((modm, xK_semicolon ), spawn myDmenu)
-- launch file manager
, ((modm, xK_o ), spawn myFileManager)
-- take a screenshot, fullscreen
, ((noModMask, xK_Print ), spawn myPrintscreen)
-- take a screenshot, interactive
, ((shiftMask, xK_Print ), spawn myScreenshot)
-- lock session
, ((modm .|. shiftMask, xK_l ), spawn "xscreensaver-command --lock")
-- invoke exit menu
, ((modm .|. shiftMask, xK_Delete ), spawn myExit)
-- close focused window
, ((modm .|. shiftMask, xK_c ), kill)
-- Rotate through the available layout algorithms
, ((modm, xK_space ), sendMessage NextLayout)
-- Reset the layouts on the current workspace to default
, ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
-- Resize viewed windows to the correct size
, ((modm, xK_n ), refresh)
-- Move focus to the next window
, ((modm, xK_Tab ), windows W.focusDown)
-- Move focus to the next window
, ((modm, xK_j ), windows W.focusDown)
-- Move focus to the previous window
, ((modm .|. shiftMask, xK_Tab ), windows W.focusUp )
-- Move focus to the previous window
, ((modm, xK_k ), windows W.focusUp )
-- Move focus to the master window
, ((modm, xK_m ), windows W.focusMaster )
-- Swap the focused window and the master window
, ((modm, xK_Return ), windows W.swapMaster)
-- Swap the focused window with the next window
, ((modm .|. shiftMask, xK_j ), windows W.swapDown )
-- Swap the focused window with the previous window
, ((modm .|. shiftMask, xK_k ), windows W.swapUp )
-- Shrink the master area
, ((modm, xK_h ), sendMessage Shrink)
-- Expand the master area
, ((modm, xK_l ), sendMessage Expand)
-- Push window back into tiling
, ((modm, xK_t ), withFocused $ windows . W.sink)
-- Increment the number of windows in the master area
, ((modm , xK_comma ), sendMessage (IncMasterN 1))
-- Deincrement the number of windows in the master area
, ((modm , xK_period ), sendMessage (IncMasterN (-1)))
-- Toggle the status bar gap
-- Use this binding with avoidStruts from Hooks.ManageDocks.
-- See also the statusBar function from Hooks.DynamicLog.
--
, ((modm , xK_b ), sendMessage ToggleStruts)
-- Quit xmonad
, ((modm .|. shiftMask, xK_q ), io (exitWith ExitSuccess))
-- Restart xmonad
, ((modm , xK_q ), spawn "xmonad --recompile; xmonad --restart")
]
++
[ ((0, xF86XK_MonBrightnessDown ), spawn "xbacklight - 1")
, ((0, xF86XK_MonBrightnessUp ), spawn "xbacklight + 1")
]
++
--
-- mod-[1..9], Switch to workspace N
-- mod-shift-[1..9], Move client to workspace N
--
[((m .|. modm, 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 .|. modm, 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)]]
myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
-- mod-button1, Set the window to floating mode and move by dragging
[ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
>> windows W.shiftMaster))
-- mod-button2, Raise the window to the top of the stack
, ((modm, button2), (\w -> focus w >> windows W.shiftMaster))
-- mod-button3, Set the window to floating mode and resize by dragging
, ((modm, button3), (\w -> focus w >> mouseResizeWindow w
>> windows W.shiftMaster))
-- you may also bind events to the mouse scroll wheel (button4 and button5)
]
myLayoutHook =
(
verticalLayout
||| horizontalLayout
-- ||| ThreeCol 1 (3/100) (1/2)
-- ||| ThreeColMid 1 (3/100) (1/2)
||| fullLayout)
where
-- default tiling algorithm partitions the screen into two panes
tiled = Tall nmaster delta ratio
-- The default number of windows in the master pane
nmaster = 1
-- Default proportion of screen occupied by master pane
ratio = 1/2
-- Percent of screen to increment by when resizing panes
delta = 2/100
verticalLayout = named "vertical" (
withIM (1%7) (ClassName "Pidgin") $ avoidStruts $ smartBorders $ smartSpacing 4 $ tiled
)
horizontalLayout = named "horizontal" (
avoidStruts $ smartBorders $ smartSpacing 4 $ Mirror tiled
)
fullLayout = named "full" (
avoidStruts $ smartBorders $ noBorders Full
)
-- gimpLayout = named "Gimp" (
-- withIM (0.15) (Role "gimp-toolbox") $
-- reflectHoriz $
-- withIM (0.2) (Role "gimp-dock") Full
-- )
myManageHook = composeAll
[ className =? "Audacious" --> doShift "9"
, className =? "Calibre-gui" --> doShift "8"
, appName =? "recordMyDesktop" --> doFloat
, appName =? "Panel" --> doIgnore
, resource =? "desktop_window" --> doIgnore
, title =? "File Operation Progress" --> doFloat
, appName =? "screenshot" --> doFloat
, className =? "xcalc" --> doFloat
, className =? "Galculator" --> doFloat
, title =? "Change Foreground Color" --> doFloat
, className =? "zoom" --> doFloat
, className =? "SimpleScreenRecorder" --> doFloat
, manageDocks ]
myEventHook = do ewmhDesktopsEventHook
myLogHook :: X ()
myLogHook = ewmhDesktopsLogHook
myStartupHook :: X ()
myStartupHook = do
setWMName "LG3D"
spawn myTrayer
spawn myDropbox
myPP = xmobarPP {
ppCurrent = xmobarColor xmobarCurrentWorkspaceColor "" . wrap "(" ")"
, ppLayout = xmobarColor xmobarLayoutColor "" . (\layout -> case layout of
"vertical" -> "│├─"
"horizontal" -> "─┬─"
"full" -> "│ │"
)
, ppTitle = xmobarColor xmobarTitleColor "" . shorten 80
, ppUrgent = xmobarColor xmobarUrgentHighColor xmobarUrgentLowColor
}
toggleStrutsKey XConfig {XMonad.modMask = modMask} = (modMask, xK_b)
myConfig = defaultConfig {
terminal = myTerminal
, focusFollowsMouse = myFocusFollowsMouse
, borderWidth = myBorderWidth
, modMask = myModMask
, workspaces = myWorkspaces
, normalBorderColor = myNormalBorderColor
, focusedBorderColor = myFocusedBorderColor
, keys = myKeys
, mouseBindings = myMouseBindings
, layoutHook = myLayoutHook
, manageHook = myManageHook
, handleEventHook = myEventHook
, logHook = myLogHook
, startupHook = myStartupHook
}
main = xmonad =<< statusBar "xmobar" myPP toggleStrutsKey myConfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment