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 From c3a28e6c5882ea19b9de48e9544d0c606b2662ce Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 16 Nov 2022 06:38:01 -0500 Subject: Add transparent terminal Change-Id: Ib281d72d782df657eda23e580d54dc0d4f1b18c6 --- lib/xmonad.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/xmonad.hs') diff --git a/lib/xmonad.hs b/lib/xmonad.hs index 583ffb5..a2dd180 100644 --- a/lib/xmonad.hs +++ b/lib/xmonad.hs @@ -93,6 +93,7 @@ myManageHook = manageDocks <+> scratchHook <+> (shouldFloat --> doFullFloat) <+> -- todo: use urxvtc with daemon termName = "/home/ben/.nix-profile/bin/urxvt" +transparentTerm = "urxvt -depth 32 -bg rgba:0000/0000/0000/4444 -fg '[80]white'" insKeys :: XConfig l -> [((KeyMask, KeySym), X ())] insKeys conf@(XConfig {modMask = modMask}) = @@ -101,8 +102,8 @@ insKeys conf@(XConfig {modMask = modMask}) = ((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"), + ((modMask, xK_s), scratchpadSpawnActionTerminal transparentTerm), + ((modMask, xK_h), spawn transparentTerm), -- refresh display via autorandr ( (modMask, xK_r), spawn $ "autorandr --cycle" -- cgit v1.2.3 From 6bfb7ef9e6b590b3eeaa3bb0ea022251230f11a4 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 16 Nov 2022 06:38:11 -0500 Subject: Finally figured out how to use RationalRect Change-Id: I98e53e9984a98795fec01196bb51e41a2b9597dd --- lib/xmonad.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/xmonad.hs') diff --git a/lib/xmonad.hs b/lib/xmonad.hs index a2dd180..b3cdffd 100644 --- a/lib/xmonad.hs +++ b/lib/xmonad.hs @@ -87,7 +87,8 @@ shouldFloat = do name <- appName return (fs && not (shouldntFloat name)) -scratchHook = scratchpadManageHook (W.RationalRect 0.1 0.1 0.6 0.6) +-- RationalRect is x y w h +scratchHook = scratchpadManageHook (W.RationalRect 0.125 0.125 0.75 0.75) myManageHook = manageDocks <+> scratchHook <+> (shouldFloat --> doFullFloat) <+> manageHook def -- cgit v1.2.3