Skip to content

Instantly share code, notes, and snippets.

@eira-fransham
Created September 2, 2017 09:12
Show Gist options
  • Save eira-fransham/087034ba171c82e7169f1984823e50bb to your computer and use it in GitHub Desktop.
Save eira-fransham/087034ba171c82e7169f1984823e50bb to your computer and use it in GitHub Desktop.
import XMonad
import XMonad.Actions.CycleWS
import XMonad.Actions.UpdatePointer
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Layout.Fullscreen
import XMonad.Layout.NoBorders
import XMonad.Layout.BorderResize
import XMonad.Layout.Minimize
import XMonad.Layout.BinarySpacePartition
import XMonad.Util.Run
import XMonad.Util.EZConfig (additionalKeys)
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.UrgencyHook
import XMonad.Hooks.FadeInactive
import XMonad.Config.Xfce
import Graphics.X11.ExtraTypes.XF86
import Data.Char
import Data.Monoid
import Data.List
import Control.Monad (void)
import Control.Applicative ((<$>))
import Control.Concurrent (forkIO, threadDelay)
import Control.Arrow ((&&&))
import qualified XMonad.Hooks.EwmhDesktops as E
import qualified XMonad.StackSet as W
import qualified Data.Map as M
myWorkspaces = ["Main","Editor","Terminals","Other"]
myLayout = smartBorders $
Full
||| (avoidStruts . minimize) (Tall 1 (3 / 100) (2 / 3))
||| (avoidStruts . minimize) emptyBSP
defaultConf = xfceConfig
main = do
void $ spawn "setxkbmap -option 'caps:escape'"
compton
fixPanel
xmonad . E.ewmh $ defaultConf
{ terminal = "urxvt"
, modMask = mod4Mask -- Windows key
, borderWidth = 1
, normalBorderColor = "#000000"
, focusedBorderColor = "#000000"
, manageHook = myManageHook <+> manageDocks <+> manageHook defaultConf
, handleEventHook =
E.fullscreenEventHook
<+> handleEventHook defaultConf
<+> docksEventHook
, layoutHook = myLayout
, logHook = fadeInactiveLogHook 0.8
, keys = confKeys
, workspaces = myWorkspaces
}
fixPanel = void . forkIO $ threadDelay (5 * 10 ^ 5) >> spawn "xfce4-panel -r"
compton = void $ spawn "compton --daemon"
myManageHook = composeAll $
[ (v . map toLower <$> command) --> a | (v, a) <- myActions ]
++
[ isDialog --> doCenterFloat ]
where
myActions = floating [ isPrefixOf "xfce4-popup-" ]
floating = map (flip (,) doFloat)
command = stringProperty "WM_COMMAND"
confKeys conf@(XConfig {XMonad.modMask = modm}) =
(<> keys defaultConf conf) . M.fromList $
[ ((modm, xK_p ), spawn "xfce4-popup-whiskermenu")
, ((modm .|. shiftMask, xK_c ), spawn "xkill")
, ((modm, xK_c ), kill)
-- minimize
, ((modm , xK_minus ), withFocused minimizeWindow)
, ((modm .|. shiftMask , xK_equal ), sendMessage RestoreNextMinimizedWin)
-- layouts
, ((modm, xK_space ), sendMessage NextLayout)
-- floating layer stuff
, ((modm, xK_t ), withFocused $ windows . W.sink)
-- refresh
, ((modm, xK_r ), refresh)
-- focus
, ((modm, xK_Tab ), windows W.focusDown)
, ((modm, xK_j ), windows W.focusDown)
, ((modm, xK_k ), windows W.focusUp)
, ((modm .|. shiftMask, xK_Tab ), windows W.focusUp)
, ((modm, xK_m ), windows W.focusMaster)
, ((modm, xK_Right ), nextWS)
, ((modm, xK_Left ), prevWS)
, ((modm .|. shiftMask, xK_Right ), shiftToNext >> nextWS)
, ((modm .|. shiftMask, xK_Left ), shiftToPrev >> prevWS)
-- swapping
, ((modm, xK_Return ), windows W.swapMaster)
, ((modm .|. shiftMask, xK_j ), windows W.swapDown)
, ((modm .|. shiftMask, xK_k ), windows W.swapUp)
-- resizing
, ((modm, xK_h ), sendMessage Shrink)
, ((modm, xK_l ), sendMessage Expand)
-- quit, or restart
, ((modm .|. shiftMask, xK_q ), spawn "xfce4-session-logout")
, ((mod1Mask .|. shiftMask, xK_q ), spawn "light-locker-command --lock")
-- screenshot
, ((0, xK_Print ), spawn "xfce4-screenshooter")
-- ungrab mouse cursor from applications which can grab it (games)
, ((modm, xK_i ), spawn "xdotool key XF86Ungrab")
]
++
-- 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), (uncurry (.) . (W.greedyView &&& W.shift), shiftMask)]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment