From a94317fe9762ab6f7eb0f97135825d5b8b4d4359 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Mon, 7 Nov 2022 20:17:46 -0500 Subject: random xmonad improvements --- lib/xmonad.hs | 51 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 13 deletions(-) (limited to 'lib/xmonad.hs') diff --git a/lib/xmonad.hs b/lib/xmonad.hs index 51ae0a8..583ffb5 100644 --- a/lib/xmonad.hs +++ b/lib/xmonad.hs @@ -11,16 +11,21 @@ Docs: - XMonad API: https://hackage.haskell.org/package/xmonad - Contrib API: https://hackage.haskell.org/package/xmonad-contrib +Inspirations: + +- https://reddit.simatime.com/wy695w + -} -import Data.List (intercalate) import Data.Functor ((<&>)) +import Data.List (intercalate, isPrefixOf) import Graphics.X11.ExtraTypes.XF86 import XMonad import XMonad.Actions.CopyWindow import XMonad.Config import XMonad.Hooks.EwmhDesktops (ewmh) import XMonad.Hooks.ManageDocks +import XMonad.Hooks.ManageHelpers (doFullFloat, isFullscreen) import XMonad.Layout.BinarySpacePartition import XMonad.Layout.Dwindle as Dwindle import XMonad.Layout.LayoutModifier @@ -31,8 +36,10 @@ import XMonad.Layout.Spiral import XMonad.Layout.Tabbed import XMonad.Layout.ThreeColumns import XMonad.Layout.TwoPane +import qualified XMonad.StackSet as W import XMonad.Util.CustomKeys (customKeys) import XMonad.Util.EZConfig (additionalKeys) +import XMonad.Util.Scratchpad -- Colors data Colors = Colors @@ -71,21 +78,37 @@ brighter = "brightnessctl s 5%+" dimmer = "brightnessctl s 5%-" +shouldntFloat :: String -> Bool +shouldntFloat = isPrefixOf "qutebrowser" + +shouldFloat :: Query Bool +shouldFloat = do + fs <- isFullscreen + name <- appName + return (fs && not (shouldntFloat name)) + +scratchHook = scratchpadManageHook (W.RationalRect 0.1 0.1 0.6 0.6) + +myManageHook = manageDocks <+> scratchHook <+> (shouldFloat --> doFullFloat) <+> manageHook def + +-- todo: use urxvtc with daemon +termName = "/home/ben/.nix-profile/bin/urxvt" + insKeys :: XConfig l -> [((KeyMask, KeySym), X ())] insKeys conf@(XConfig {modMask = modMask}) = [ ((modMask, xK_y), spawn "passmenu"), ((modMask, xK_m), spawn "cmdtree"), ((modMask, xK_o), spawn "rofi -sidebar-mode -show run"), ((modMask, xK_n), spawn "rofi -sidebar-mode -show window"), - + ((modMask, xK_u), spawn "rofi -show calc -modi calc -no-show-match -no-sort"), + ((modMask, xK_s), scratchpadSpawnActionTerminal termName), + ((modMask, xK_h), scratchpadSpawnActionTerminal "htop"), -- refresh display via autorandr ( (modMask, xK_r), spawn $ "autorandr --cycle" ), - -- lock it up - ( (modMask .|. shiftMask, xK_l), spawn "xautolock -locknow"), - + ((modMask .|. shiftMask, xK_l), spawn "xautolock -locknow"), -- sticky windows ((modMask, xK_a), windows copyToAll), -- @@ Make focused window always visible ((modMask .|. shiftMask, xK_a), killAllOtherCopies), -- @@ Toggle window state back @@ -134,14 +157,15 @@ myLayout theme = ||| (addSpace $ noBorders Full) ||| twopane ||| Mirror twopane --- ||| ThreeCol 1 (3 / 100) (1 / 2) --- ||| ThreeColMid 1 (3 / 100) (1 / 2) + -- ||| ThreeCol 1 (3 / 100) (1 / 2) + -- ||| ThreeColMid 1 (3 / 100) (1 / 2) ||| tiled ||| Mirror tiled ||| emptyBSP --- ||| goldenSpiral --- ||| Spiral R Dwindle.CW (3 / 2) (11 / 10) -- L/R is where to put non-main windows where + -- ||| goldenSpiral + -- ||| Spiral R Dwindle.CW (3 / 2) (11 / 10) -- L/R is where to put non-main windows + -- The last parameter is fraction to multiply the slave window heights -- with. Useless here. tiled = addSpace $ ResizableTall nmaster delta ratio [] @@ -154,17 +178,18 @@ myLayout theme = -- Percent of screen to increment by when resizing panes delta = 3 / 100 -myConf theme = additionalKeys c (insKeys c) + +myConf theme = additionalKeys cfg (insKeys cfg) where - c = + cfg = def { modMask = mod4Mask, -- super instead of alt normalBorderColor = background theme, focusedBorderColor = highlight theme, borderWidth = 3, - manageHook = manageDocks <+> manageHook def, + manageHook = myManageHook, layoutHook = myLayout theme, - terminal = "/home/ben/.nix-profile/bin/urxvt", + terminal = termName, workspaces = myWorkspaces } -- cgit v1.2.3