From ca0cd87b7818cc55fdb057285aa138dbf2fb8b14 Mon Sep 17 00:00:00 2001 From: Leon Kowarschick Date: Wed, 10 Jun 2020 12:58:56 +0200 Subject: [PATCH] asdf --- files/.xmonad/.stack-work/stack.sqlite3 | Bin 327680 -> 327680 bytes files/.xmonad/lib/Config.hs | 49 ++++++++++++++++++------ 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/files/.xmonad/.stack-work/stack.sqlite3 b/files/.xmonad/.stack-work/stack.sqlite3 index 3f3c0af77387b8ec386a12efabb1a022e6412ef0..d2a012cc20be9c0c52f94dfb3cc7e6311cdef4c3 100644 GIT binary patch delta 68 zcmZo@5NT)-nIO%WH&Mo!F>hl+@&``FWekauxg4#G(+#;8wb`3;899Lh(;d55^qX}* Uw(EXm1Y#y2X5Oy*k>xTU0NjNZhyVZp delta 69 zcmZo@5NT)-nIO%`GEv5vk!52-@&_&k#-$92lDQl$_0tWx7`51&av3>+0@EG4SoE89 VKep?BWCUU+AZFgK`;p}`9{|T)7BBz+ diff --git a/files/.xmonad/lib/Config.hs b/files/.xmonad/lib/Config.hs index d6f38a4..b2cb1a4 100644 --- a/files/.xmonad/lib/Config.hs +++ b/files/.xmonad/lib/Config.hs @@ -14,6 +14,7 @@ import Control.Arrow ( (>>>) ) import Data.List ( isPrefixOf , isSuffixOf , isInfixOf + , intercalate ) import qualified Foreign.C.Types import System.Exit (exitSuccess) @@ -313,7 +314,8 @@ myKeys = concat [ zoomRowBindings, tabbedBindings, multiMonitorBindings, program --, ("M-b", launchWithBackgroundInstance (className =? "qutebrowser") "bwrap --bind / / --dev-bind /dev /dev --tmpfs /tmp --tmpfs /run qutebrowser") --, ("M-b", safeSpawnProg "qutebrowser") , ("M-b", safeSpawnProg "firefox") - , ("M-S-", launchWithBackgroundInstance (className =? "Alacritty") "alacritty") + , ("M-S-", spawn "alacritty") + --, ("M-S-", launchWithBackgroundInstance (className =? "Alacritty") "alacritty") ] miscBindings :: [(String, X ())] @@ -518,13 +520,20 @@ mySwallowEventHook = swallowEventHook ([className =? "Alacritty", className =? " 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 () + ConfigureEvent {} -> withWindowSet (XS.put . BeforeClosingStackStorage . W.stack . W.workspace . W.current) + (DestroyWindowEvent _ _ _ _ eventId window) -> when (eventId == window) $ do + (SwallowedStorage swallowed) <- XS.get + liftIO $ logOut [ show swallowed ] + case M.lookup window swallowed of + Just win -> do + BeforeClosingStackStorage maybeOldStack <- XS.get + case maybeOldStack of + Just oldStack -> do + windows (\ws -> onWorkspace "NSP" (W.delete' win) ws |> updateStack (const $ Just $ oldStack { W.focus = win })) + XS.modify (\(SwallowedStorage m) -> SwallowedStorage $ M.delete window m) + Nothing -> return () + Nothing -> return () + return () (MapRequestEvent _ _ _ _ _ newWindow) -> withFocused $ \focused -> do parentMatches <- mapM (`runQuery` focused) parentQueries @@ -536,23 +545,42 @@ swallowEventHook parentQueries childQueries event = do (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 + -- TODO use https://hackage.haskell.org/package/xmonad-contrib-0.16/docs/XMonad-Layout-Hidden.html + windows (\ws -> (onWorkspace "NSP" (W.insertUp focused) ws) + { W.current = (W.current ws) + { W.workspace = (W.workspace $ W.current ws) + { W.stack = (fmap (\x -> x { W.focus = newWindow}) $ W.stack . W.workspace . W.current $ ws) + } + } + }) XS.modify (\(SwallowedStorage m) -> SwallowedStorage $ M.insert newWindow focused m) _ -> return () return () _ -> return () return $ All True + where + updateStack f ws = + ws { W.current = (W.current ws) { W.workspace = (W.workspace $ W.current $ ws) { W.stack = (f $ W.stack . W.workspace . W.current $ ws) } } } + isChildOf :: Int -> Int -> IO Bool isChildOf child parent = do output <- runProcessWithInput "pstree" ["-T", "-p", show parent] "" return $ any ((show child) `isInfixOf`) $ lines output +logOut :: [String] -> IO () +logOut x = catchAndNotifyAny (appendFile "/tmp/xmonad-event-out" ((intercalate " - " x) ++ "\n")) + +onWorkspace :: (Eq i, Eq s) => i -> (W.StackSet i l a s sd -> W.StackSet i l a s sd) -> (W.StackSet i l a s sd -> W.StackSet i l a s sd) +onWorkspace n f s = W.view (W.currentTag s) . f . W.view n $ s + newtype SwallowedStorage = SwallowedStorage (M.Map GHC.Word.Word64 GHC.Word.Word64) deriving Typeable instance ExtensionClass SwallowedStorage where initialValue = SwallowedStorage mempty - +newtype BeforeClosingStackStorage = BeforeClosingStackStorage (Maybe (W.Stack Window)) deriving (Typeable, Show) +instance ExtensionClass BeforeClosingStackStorage where + initialValue = BeforeClosingStackStorage Nothing -- POLYBAR Kram -------------------------------------- {{{ @@ -615,7 +643,6 @@ dropEndWhile test xs = if test $ last xs then dropEndWhile test (init xs) else catchAndNotifyAny :: IO () -> IO () catchAndNotifyAny ioAction = catch ioAction (\(e :: SomeException) -> notify "Xmonad exception" (show e)) - getVisibleWorkspacesTagsOnMonitor :: ScreenId -> X [VirtualWorkspace] getVisibleWorkspacesTagsOnMonitor monitor = do ws <- gets windowset