From 09655273538354a462fbf8213cd5b9889e6d2a99 Mon Sep 17 00:00:00 2001 From: Leon Kowarschick Date: Tue, 9 Jun 2020 22:52:14 +0200 Subject: [PATCH] add window swallowing --- files/.config/alacritty/alacritty.yml | 8 ++- .../configstore/update-notifier-npm.json | 2 +- files/.xmonad/.stack-work/stack.sqlite3 | Bin 323584 -> 327680 bytes files/.xmonad/lib/Config.hs | 63 ++++++++++++++++-- files/.xmonad/my-xmonad.cabal | 3 +- 5 files changed, 67 insertions(+), 9 deletions(-) diff --git a/files/.config/alacritty/alacritty.yml b/files/.config/alacritty/alacritty.yml index 98a3722..1d67ea3 100644 --- a/files/.config/alacritty/alacritty.yml +++ b/files/.config/alacritty/alacritty.yml @@ -12,8 +12,8 @@ window: # y: 0 padding: - x: 10 - y: 10 + x: 20 + y: 20 #Spread additional padding evenly around the terminal content. dynamic_padding: true @@ -338,6 +338,7 @@ colors: *gruvbox background_opacity: 1.0 font: + #size: 10 size: 12 normal: #family: JetBrainsMono Nerd Font @@ -347,3 +348,6 @@ font: #family: cherry #family: lucy tewi2a #family: Scientifica + offset: + x: 0 + y: 0 diff --git a/files/.config/configstore/update-notifier-npm.json b/files/.config/configstore/update-notifier-npm.json index a4bf579..6ec379c 100644 --- a/files/.config/configstore/update-notifier-npm.json +++ b/files/.config/configstore/update-notifier-npm.json @@ -1,4 +1,4 @@ { "optOut": false, - "lastUpdateCheck": 1591520965287 + "lastUpdateCheck": 1591697300975 } \ No newline at end of file diff --git a/files/.xmonad/.stack-work/stack.sqlite3 b/files/.xmonad/.stack-work/stack.sqlite3 index 233f2efabf60efd605071bf022628e976624eb7d..3f3c0af77387b8ec386a12efabb1a022e6412ef0 100644 GIT binary patch delta 983 zcmZ8fT}TvB6u#%q-JQL&&0K5MMGMPXEZp1_vL&<)E34JiWkNuH7kmuRoZ z*~h$_36rx#5wM1Lt%86@pkxYR%I~d*1i{d63JreVkpt^3);2dszPCRfNsGo@PU#OD1PX$<0I zLIHd6pdA(b#JqV-BHna_>;%P+?dZXe>?q>_JG${hJGyW`AFq=FaL9DkOQRTjTg-Q- zq&yECZcmLnxY|Piub_n(o>{xf7HaeYAf z$mDV>Ijte{{}angqUlD|g(#G}c-aIFP%(gF1W=@N_=HmxK?8z@b!Q^hq+C2JMs%zH zw|GO0Ne-fOqD7Hzi{uf9+Xb-$V`e3DgVv9Z-R`*zoxI!^D*|JZU`JD}99W}}xZfL#)yIlkl1&=R zF~)jREy0Sl9cp=UX{vX-K}&X*h3Oytp)&oTFI1ovTFTU3ct)A!fpU_=gY+)%L49lx zOm?wRblt@R8UOF);7)t)JeyY0(!_ zniHiU$Wo9u^jSCgI-?ExK#wRv=R|#ymtj%z6n_ipfOnf*pWw}frhc4d&f_-d8x`pz zy`wjjrx)~8wp>;2bC{9&A!W5P;+3=46?C_1Xacz04osH=!*rk<4m90?s)^!=;)5$v zjVUXf1IX1erOSX}JFsg<30HP5AU-@n`eyUP+M5@7JG~T0$_7q0&SiD;m zqbcmfGx3v}$fhuid*dfmX-(i?zY@hsp=U8I?`843VrS4OC-ZpOt<-vkguaM-GWIf$ U-gf&eG8hn3d2E%_1?;c;4;^r!LI3~& diff --git a/files/.xmonad/lib/Config.hs b/files/.xmonad/lib/Config.hs index 0f8fdb3..d6f38a4 100644 --- a/files/.xmonad/lib/Config.hs +++ b/files/.xmonad/lib/Config.hs @@ -6,14 +6,22 @@ module Config (main) where import qualified Data.Map.Strict as M import Control.Concurrent import Control.Exception ( catch , SomeException) -import Control.Monad ( filterM ) +import Control.Monad ( filterM + , when + , guard + ) import Control.Arrow ( (>>>) ) -import Data.List ( isPrefixOf , isSuffixOf) +import Data.List ( isPrefixOf + , isSuffixOf + , isInfixOf + ) +import qualified Foreign.C.Types import System.Exit (exitSuccess) - +import qualified XMonad.Util.ExtensibleState as XS import qualified Rofi import qualified DescribedSubmap import qualified TiledDragging +import qualified GHC.Word import Data.Foldable ( for_ ) @@ -64,7 +72,9 @@ import XMonad.Util.SpawnOnce (spawnOnce) import XMonad.Util.WorkspaceCompare ( getSortByXineramaPhysicalRule , getSortByIndex) import qualified Data.Monoid +import Data.Monoid ( Endo ) import Data.Traversable ( for ) +import Data.Semigroup ( All(..) ) import qualified System.IO as SysIO import qualified XMonad.Actions.Navigation2D as Nav2d import qualified XMonad.Config.Desktop as Desktop @@ -80,6 +90,7 @@ import qualified XMonad.Layout.MultiToggle.Instances as MTog import qualified XMonad.Layout.ToggleLayouts as ToggleLayouts import qualified XMonad.StackSet as W import qualified XMonad.Util.XSelection as XSel +import XMonad.Util.WindowProperties import qualified XMonad.Layout.PerScreen as PerScreen {-# ANN module "HLint: ignore Redundant $" #-} {-# ANN module "HLint: ignore Redundant bracket" #-} @@ -180,7 +191,7 @@ myLayout = avoidStruts ||| (rename "Horizon" $ spacingAndGaps $ mouseResizableTileMirrored {draggerType = BordersDragger}) ||| (rename "BSP" $ spacingAndGaps $ borderResize $ emptyBSP) ||| (rename "ThreeCol" $ makeTabbed $ spacingAndGaps $ reflectHoriz $ ResizableThreeColMid 1 (3/100) (1/2) []) - ||| (rename "TabbedRow" $ makeTabbed $ spacingAndGaps $ zoomRow)) + ||| (rename "TabbedRow" $ makeTabbed $ spacingAndGaps $ zoomRow)) vertScreenLayouts = ((rename "ThreeCol" $ makeTabbed $ spacingAndGaps $ Mirror $ reflectHoriz $ ThreeColMid 1 (3/100) (1/2)) @@ -488,7 +499,7 @@ main = do , manageHook = manageSpawn <+> myManageHook <+> manageHook def , focusedBorderColor = aqua , normalBorderColor = "#282828" - , handleEventHook = handleEventHook Desktop.desktopConfig + , handleEventHook = mySwallowEventHook <+> handleEventHook Desktop.desktopConfig --, handleEventHook = minimizeEventHook <+> handleEventHook def <+> hintsEventHook -- <+> Ewmh.fullscreenEventHook , mouseBindings = myMouseBindings <+> mouseBindings def } @@ -501,6 +512,48 @@ main = do -- }}} + +mySwallowEventHook = swallowEventHook ([className =? "Alacritty", className =? "Termite"]) ([return True]) + +swallowEventHook :: [Query Bool] -> [Query Bool] -> Event -> X All +swallowEventHook parentQueries childQueries event = do + case event of + (DestroyWindowEvent _ _ _ _ eventId window) -> + when (eventId == window) $ do + (SwallowedStorage swallowed) <- XS.get + case M.lookup window swallowed of + Just win -> windows (\ws -> W.shiftWin (W.tag . W.workspace . W.current $ ws) (fromIntegral win) ws) + Nothing -> return () + return () + + (MapRequestEvent _ _ _ _ _ newWindow) -> withFocused $ \focused -> do + parentMatches <- mapM (`runQuery` focused) parentQueries + childMatches <- mapM (`runQuery` newWindow) childQueries + when (or parentMatches && or childMatches) $ do + newWindowPid <- getProp32s "_NET_WM_PID" newWindow + oldWindowPid <- getProp32s "_NET_WM_PID" focused + case (oldWindowPid, newWindowPid) of + (Just (oldPid:_), Just (newPid:_)) -> do + isChild <- liftIO $ (fromIntegral newPid) `isChildOf` (fromIntegral oldPid) + when isChild $ do + windows (W.shiftWin "NSP" focused) -- TODO use https://hackage.haskell.org/package/xmonad-contrib-0.16/docs/XMonad-Layout-Hidden.html + XS.modify (\(SwallowedStorage m) -> SwallowedStorage $ M.insert newWindow focused m) + _ -> return () + return () + _ -> return () + return $ All True + +isChildOf :: Int -> Int -> IO Bool +isChildOf child parent = do + output <- runProcessWithInput "pstree" ["-T", "-p", show parent] "" + return $ any ((show child) `isInfixOf`) $ lines output + +newtype SwallowedStorage = SwallowedStorage (M.Map GHC.Word.Word64 GHC.Word.Word64) deriving Typeable +instance ExtensionClass SwallowedStorage where + initialValue = SwallowedStorage mempty + + + -- POLYBAR Kram -------------------------------------- {{{ -- | Loghook for polybar on a given monitor. diff --git a/files/.xmonad/my-xmonad.cabal b/files/.xmonad/my-xmonad.cabal index 7386812..e876499 100644 --- a/files/.xmonad/my-xmonad.cabal +++ b/files/.xmonad/my-xmonad.cabal @@ -23,4 +23,5 @@ executable my-xmonad netlink >=1.1.1.0, containers >=0.6.2.1, utf8-string >=1.0.1.1, - text >=1.2.4.0 + text >=1.2.4.0, + process >= 0.0.10