ADD steam to dynamic workspaces

This commit is contained in:
Nathan Dwarshuis 2020-03-28 23:15:41 -04:00
parent 84ba8742c2
commit e8e898507a
2 changed files with 46 additions and 12 deletions

View File

@ -113,7 +113,8 @@ gimpDynamicWorkspace = DynWorkspace
, matchGimpRole "gimp-toolbox" -?> doF (toBottom . W.focusMaster) , matchGimpRole "gimp-toolbox" -?> doF (toBottom . W.focusMaster)
, className =? c -?> appendViewShift t , className =? c -?> appendViewShift t
] ]
, dwCmd = Just ("g", spawnCmd "gimp-2.10" []) , dwKey = 'g'
, dwCmd = Just $ spawnCmd "gimp-2.10" []
} }
where where
matchGimpRole role = isPrefixOf role <$> stringProperty "WM_WINDOW_ROLE" matchGimpRole role = isPrefixOf role <$> stringProperty "WM_WINDOW_ROLE"
@ -128,7 +129,8 @@ wmDynamicWorkspace = DynWorkspace
, dwTag = t , dwTag = t
, dwClass = c , dwClass = c
, dwHook = [ className =? c -?> appendViewShift t ] , dwHook = [ className =? c -?> appendViewShift t ]
, dwCmd = Just ("v", spawnCmd "vbox-start" ["win8raw"]) , dwKey = 'v'
, dwCmd = Just $ spawnCmd "vbox-start" ["win8raw"]
} }
where where
t = "VM" t = "VM"
@ -140,19 +142,41 @@ xsaneDynamicWorkspace = DynWorkspace
, dwTag = t , dwTag = t
, dwClass = c , dwClass = c
, dwHook = [ className =? c -?> appendViewShift t >> doFloat ] , dwHook = [ className =? c -?> appendViewShift t >> doFloat ]
, dwCmd = Just ("x", spawnCmd "xsane" []) , dwKey = 'x'
, dwCmd = Just $ spawnCmd "xsane" []
} }
where where
t = "XSANE" t = "XSANE"
c = "Xsane" c = "Xsane"
steamDynamicWorkspace :: DynWorkspace
steamDynamicWorkspace = DynWorkspace
{ dwName = "Steam Game"
, dwTag = t
, dwClass = c
-- TODO not sure why the doSink is needed, windows should tile be default
-- since dynamic workspaces are first in the managehook
, dwHook = [ className =? c -?> appendViewShift t >> doSink ]
, dwKey = 'z'
, dwCmd = Nothing
}
where
t = "STEAM"
-- TODO this actually needs to be a list to match all games we care about
c = "portal2_linux"
allDWs :: [DynWorkspace] allDWs :: [DynWorkspace]
allDWs = [xsaneDynamicWorkspace, wmDynamicWorkspace, gimpDynamicWorkspace] allDWs = [ xsaneDynamicWorkspace
, wmDynamicWorkspace
, gimpDynamicWorkspace
, steamDynamicWorkspace
]
-- | Layout configuration -- | Layout configuration
myLayouts = onWorkspace (dwTag wmDynamicWorkspace) vmLayout myLayouts = onWorkspace (dwTag wmDynamicWorkspace) vmLayout
$ onWorkspace (dwTag gimpDynamicWorkspace) gimpLayout $ onWorkspace (dwTag gimpDynamicWorkspace) gimpLayout
$ onWorkspace (dwTag steamDynamicWorkspace) steamLayout
$ mkToggle (single HIDE) $ mkToggle (single HIDE)
$ tall ||| fulltab ||| full $ tall ||| fulltab ||| full
where where
@ -169,6 +193,7 @@ myLayouts = onWorkspace (dwTag wmDynamicWorkspace) vmLayout
full = renamed [Replace "Full"] full = renamed [Replace "Full"]
$ noBorders Full $ noBorders Full
vmLayout = noBorders Full vmLayout = noBorders Full
steamLayout = vmLayout
-- TODO use a tabbed layout for multiple master windows -- TODO use a tabbed layout for multiple master windows
gimpLayout = renamed [Replace "Gimp Layout"] gimpLayout = renamed [Replace "Gimp Layout"]
$ avoidStruts $ avoidStruts
@ -313,8 +338,11 @@ mkKeys ts c =
]) ++ ]) ++
mkNamedSubmap "Dynamic Workspaces" mkNamedSubmap "Dynamic Workspaces"
[ ("M-C-" ++ k, "launch/switch to " ++ n, spawnOrSwitch t a) [ ("M-C-" ++ [k], "launch/switch to " ++ n, cmd)
| DynWorkspace { dwTag = t, dwCmd = Just (k, a), dwName = n } <- allDWs | DynWorkspace { dwTag = t, dwKey = k, dwCmd = a, dwName = n } <- allDWs,
let cmd = case a of
Just a' -> spawnOrSwitch t a'
Nothing -> windows $ W.view t
] ++ ] ++
mkNamedSubmap "Screens" mkNamedSubmap "Screens"

View File

@ -31,6 +31,7 @@ module WorkspaceMon
, removeDynamicWorkspace , removeDynamicWorkspace
, runWorkspaceMon , runWorkspaceMon
, spawnOrSwitch , spawnOrSwitch
, doSink
) )
where where
@ -39,7 +40,6 @@ import SendXMsg
import qualified Data.Map as M import qualified Data.Map as M
import Data.Maybe import Data.Maybe
import Data.Semigroup
import Control.Concurrent import Control.Concurrent
import Control.Monad import Control.Monad
@ -58,8 +58,7 @@ import System.Process (Pid)
import XMonad.Actions.DynamicWorkspaces import XMonad.Actions.DynamicWorkspaces
import XMonad.Core import XMonad.Core
( Query ( ManageHook
, ScreenId
, WorkspaceId , WorkspaceId
, X , X
, withWindowSet , withWindowSet
@ -78,7 +77,8 @@ data DynWorkspace = DynWorkspace
, dwTag :: WorkspaceId , dwTag :: WorkspaceId
, dwClass :: String , dwClass :: String
, dwHook :: [MaybeManageHook] , dwHook :: [MaybeManageHook]
, dwCmd :: Maybe (String, X ()) , dwKey :: Char
, dwCmd :: Maybe (X ())
-- TODO this should also have the layout for this workspace -- TODO this should also have the layout for this workspace
} }
@ -179,13 +179,19 @@ spawnOrSwitch tag cmd = do
-- Move windows to new workspace if they are part of a dynamic workspace -- Move windows to new workspace if they are part of a dynamic workspace
viewShift viewShift
:: WorkspaceId -> Query (Endo (W.StackSet WorkspaceId l Window ScreenId sd)) :: WorkspaceId -> ManageHook
viewShift = doF . liftM2 (.) W.view W.shift viewShift = doF . liftM2 (.) W.view W.shift
appendViewShift appendViewShift
:: String -> Query (Endo (W.StackSet WorkspaceId l Window ScreenId sd)) :: String -> ManageHook
appendViewShift tag = liftX (appendWorkspace tag) >> viewShift tag appendViewShift tag = liftX (appendWorkspace tag) >> viewShift tag
-- surprisingly this doesn't exist?
doSink :: ManageHook
doSink = doF $ \s -> case W.stack $ W.workspace $ W.current s of
Just s' -> W.sink (W.focus s') s
Nothing -> s
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | Eventhook -- | Eventhook
-- When an app is closed, this will respond the event that is sent in the main -- When an app is closed, this will respond the event that is sent in the main