mirror of
https://github.com/elkowar/dots-of-war.git
synced 2024-11-06 03:12:24 +00:00
add window swallowing
This commit is contained in:
parent
411be1ae5a
commit
0965527353
5 changed files with 67 additions and 9 deletions
|
@ -12,8 +12,8 @@ window:
|
||||||
# y: 0
|
# y: 0
|
||||||
|
|
||||||
padding:
|
padding:
|
||||||
x: 10
|
x: 20
|
||||||
y: 10
|
y: 20
|
||||||
|
|
||||||
#Spread additional padding evenly around the terminal content.
|
#Spread additional padding evenly around the terminal content.
|
||||||
dynamic_padding: true
|
dynamic_padding: true
|
||||||
|
@ -338,6 +338,7 @@ colors: *gruvbox
|
||||||
background_opacity: 1.0
|
background_opacity: 1.0
|
||||||
|
|
||||||
font:
|
font:
|
||||||
|
#size: 10
|
||||||
size: 12
|
size: 12
|
||||||
normal:
|
normal:
|
||||||
#family: JetBrainsMono Nerd Font
|
#family: JetBrainsMono Nerd Font
|
||||||
|
@ -347,3 +348,6 @@ font:
|
||||||
#family: cherry
|
#family: cherry
|
||||||
#family: lucy tewi2a
|
#family: lucy tewi2a
|
||||||
#family: Scientifica
|
#family: Scientifica
|
||||||
|
offset:
|
||||||
|
x: 0
|
||||||
|
y: 0
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{
|
{
|
||||||
"optOut": false,
|
"optOut": false,
|
||||||
"lastUpdateCheck": 1591520965287
|
"lastUpdateCheck": 1591697300975
|
||||||
}
|
}
|
Binary file not shown.
|
@ -6,14 +6,22 @@ module Config (main) where
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
import Control.Exception ( catch , SomeException)
|
import Control.Exception ( catch , SomeException)
|
||||||
import Control.Monad ( filterM )
|
import Control.Monad ( filterM
|
||||||
|
, when
|
||||||
|
, guard
|
||||||
|
)
|
||||||
import Control.Arrow ( (>>>) )
|
import Control.Arrow ( (>>>) )
|
||||||
import Data.List ( isPrefixOf , isSuffixOf)
|
import Data.List ( isPrefixOf
|
||||||
|
, isSuffixOf
|
||||||
|
, isInfixOf
|
||||||
|
)
|
||||||
|
import qualified Foreign.C.Types
|
||||||
import System.Exit (exitSuccess)
|
import System.Exit (exitSuccess)
|
||||||
|
import qualified XMonad.Util.ExtensibleState as XS
|
||||||
import qualified Rofi
|
import qualified Rofi
|
||||||
import qualified DescribedSubmap
|
import qualified DescribedSubmap
|
||||||
import qualified TiledDragging
|
import qualified TiledDragging
|
||||||
|
import qualified GHC.Word
|
||||||
|
|
||||||
|
|
||||||
import Data.Foldable ( for_ )
|
import Data.Foldable ( for_ )
|
||||||
|
@ -64,7 +72,9 @@ import XMonad.Util.SpawnOnce (spawnOnce)
|
||||||
import XMonad.Util.WorkspaceCompare ( getSortByXineramaPhysicalRule , getSortByIndex)
|
import XMonad.Util.WorkspaceCompare ( getSortByXineramaPhysicalRule , getSortByIndex)
|
||||||
|
|
||||||
import qualified Data.Monoid
|
import qualified Data.Monoid
|
||||||
|
import Data.Monoid ( Endo )
|
||||||
import Data.Traversable ( for )
|
import Data.Traversable ( for )
|
||||||
|
import Data.Semigroup ( All(..) )
|
||||||
import qualified System.IO as SysIO
|
import qualified System.IO as SysIO
|
||||||
import qualified XMonad.Actions.Navigation2D as Nav2d
|
import qualified XMonad.Actions.Navigation2D as Nav2d
|
||||||
import qualified XMonad.Config.Desktop as Desktop
|
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.Layout.ToggleLayouts as ToggleLayouts
|
||||||
import qualified XMonad.StackSet as W
|
import qualified XMonad.StackSet as W
|
||||||
import qualified XMonad.Util.XSelection as XSel
|
import qualified XMonad.Util.XSelection as XSel
|
||||||
|
import XMonad.Util.WindowProperties
|
||||||
import qualified XMonad.Layout.PerScreen as PerScreen
|
import qualified XMonad.Layout.PerScreen as PerScreen
|
||||||
{-# ANN module "HLint: ignore Redundant $" #-}
|
{-# ANN module "HLint: ignore Redundant $" #-}
|
||||||
{-# ANN module "HLint: ignore Redundant bracket" #-}
|
{-# ANN module "HLint: ignore Redundant bracket" #-}
|
||||||
|
@ -180,7 +191,7 @@ myLayout = avoidStruts
|
||||||
||| (rename "Horizon" $ spacingAndGaps $ mouseResizableTileMirrored {draggerType = BordersDragger})
|
||| (rename "Horizon" $ spacingAndGaps $ mouseResizableTileMirrored {draggerType = BordersDragger})
|
||||||
||| (rename "BSP" $ spacingAndGaps $ borderResize $ emptyBSP)
|
||| (rename "BSP" $ spacingAndGaps $ borderResize $ emptyBSP)
|
||||||
||| (rename "ThreeCol" $ makeTabbed $ spacingAndGaps $ reflectHoriz $ ResizableThreeColMid 1 (3/100) (1/2) [])
|
||| (rename "ThreeCol" $ makeTabbed $ spacingAndGaps $ reflectHoriz $ ResizableThreeColMid 1 (3/100) (1/2) [])
|
||||||
||| (rename "TabbedRow" $ makeTabbed $ spacingAndGaps $ zoomRow))
|
||| (rename "TabbedRow" $ makeTabbed $ spacingAndGaps $ zoomRow))
|
||||||
|
|
||||||
vertScreenLayouts =
|
vertScreenLayouts =
|
||||||
((rename "ThreeCol" $ makeTabbed $ spacingAndGaps $ Mirror $ reflectHoriz $ ThreeColMid 1 (3/100) (1/2))
|
((rename "ThreeCol" $ makeTabbed $ spacingAndGaps $ Mirror $ reflectHoriz $ ThreeColMid 1 (3/100) (1/2))
|
||||||
|
@ -488,7 +499,7 @@ main = do
|
||||||
, manageHook = manageSpawn <+> myManageHook <+> manageHook def
|
, manageHook = manageSpawn <+> myManageHook <+> manageHook def
|
||||||
, focusedBorderColor = aqua
|
, focusedBorderColor = aqua
|
||||||
, normalBorderColor = "#282828"
|
, normalBorderColor = "#282828"
|
||||||
, handleEventHook = handleEventHook Desktop.desktopConfig
|
, handleEventHook = mySwallowEventHook <+> handleEventHook Desktop.desktopConfig
|
||||||
--, handleEventHook = minimizeEventHook <+> handleEventHook def <+> hintsEventHook -- <+> Ewmh.fullscreenEventHook
|
--, handleEventHook = minimizeEventHook <+> handleEventHook def <+> hintsEventHook -- <+> Ewmh.fullscreenEventHook
|
||||||
, mouseBindings = myMouseBindings <+> mouseBindings def
|
, 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 -------------------------------------- {{{
|
-- POLYBAR Kram -------------------------------------- {{{
|
||||||
|
|
||||||
-- | Loghook for polybar on a given monitor.
|
-- | Loghook for polybar on a given monitor.
|
||||||
|
|
|
@ -23,4 +23,5 @@ executable my-xmonad
|
||||||
netlink >=1.1.1.0,
|
netlink >=1.1.1.0,
|
||||||
containers >=0.6.2.1,
|
containers >=0.6.2.1,
|
||||||
utf8-string >=1.0.1.1,
|
utf8-string >=1.0.1.1,
|
||||||
text >=1.2.4.0
|
text >=1.2.4.0,
|
||||||
|
process >= 0.0.10
|
||||||
|
|
Loading…
Reference in a new issue