ENH use dual swicher/launcher for transient workspaces

This commit is contained in:
Nathan Dwarshuis 2020-03-26 21:02:58 -04:00
parent ccc3aca822
commit 2d9d5dcefe
1 changed files with 13 additions and 5 deletions

View File

@ -503,9 +503,6 @@ runMinBacklight = io $ void callMinBrightness
runMaxBacklight :: X () runMaxBacklight :: X ()
runMaxBacklight = io $ void callMaxBrightness runMaxBacklight = io $ void callMaxBrightness
showWorkspace :: WorkspaceId -> X ()
showWorkspace tag = windows $ W.view tag
toggleDPMS :: X () toggleDPMS :: X ()
toggleDPMS = io $ void callToggle toggleDPMS = io $ void callToggle
@ -531,6 +528,17 @@ showKeybindings x = addName "Show Keybindings" $ do
, "'#element.selected.normal { background-color: #a200ff; }'" , "'#element.selected.normal { background-color: #a200ff; }'"
] ]
appendOrSwitch :: WorkspaceId -> X () -> X ()
appendOrSwitch tag cmd = do
occupied <- withWindowSet $ \ws ->
return $ elem tag
$ map W.tag
-- list of all workspaces with windows on them
$ W.workspace (W.current ws)
: W.hidden ws
++ map W.workspace (W.visible ws)
if occupied then windows $ W.view tag else appendWorkspace tag >> cmd
myModMask :: KeyMask myModMask :: KeyMask
myModMask = mod4Mask myModMask = mod4Mask
@ -607,8 +615,8 @@ mkKeys hs client c =
, ("M-C-q", "launch calc", runCalc) , ("M-C-q", "launch calc", runCalc)
, ("M-C-f", "launch file manager", runFileManager) , ("M-C-f", "launch file manager", runFileManager)
-- TODO shoudn't these be flipped? -- TODO shoudn't these be flipped?
, ("M-C-v", "launch windows VM", runVBox >> appendWorkspace myVMWorkspace) , ("M-C-v", "launch windows VM", appendOrSwitch myVMWorkspace runVBox)
, ("M-C-g", "launch GIMP", runGimp >> appendWorkspace myGimpWorkspace) , ("M-C-g", "launch GIMP", appendOrSwitch myGimpWorkspace runGimp)
] ++ ] ++
mkNamedSubmap c "Multimedia" mkNamedSubmap c "Multimedia"