mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 06:39:14 +00:00
vanadium/xmonad: shift windows based on dynamic title property
This commit is contained in:
parent
0d468192be
commit
5f1cea7f25
1 changed files with 28 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ import XMonad.Hooks.EwmhDesktops
|
||||||
import XMonad.Hooks.InsertPosition
|
import XMonad.Hooks.InsertPosition
|
||||||
import XMonad.Hooks.ManageDocks
|
import XMonad.Hooks.ManageDocks
|
||||||
import XMonad.Hooks.ManageHelpers
|
import XMonad.Hooks.ManageHelpers
|
||||||
|
import XMonad.Hooks.OnPropertyChange
|
||||||
import XMonad.Hooks.RefocusLast
|
import XMonad.Hooks.RefocusLast
|
||||||
import XMonad.Hooks.StatusBar
|
import XMonad.Hooks.StatusBar
|
||||||
import XMonad.Layout.NoBorders
|
import XMonad.Layout.NoBorders
|
||||||
|
|
@ -25,6 +26,7 @@ import XMonad.Util.SpawnOnce
|
||||||
import XMonad.Layout.Magnifier
|
import XMonad.Layout.Magnifier
|
||||||
|
|
||||||
import Data.Char.Greek
|
import Data.Char.Greek
|
||||||
|
import Data.Semigroup
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
import System.Posix
|
import System.Posix
|
||||||
import Graphics.X11.ExtraTypes.XF86
|
import Graphics.X11.ExtraTypes.XF86
|
||||||
|
|
@ -50,6 +52,7 @@ main =
|
||||||
, startupHook = myStartupHook
|
, startupHook = myStartupHook
|
||||||
, layoutHook = myLayout
|
, layoutHook = myLayout
|
||||||
, manageHook = myManageHook
|
, manageHook = myManageHook
|
||||||
|
, handleEventHook = myEventHandleHook
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Only remove mappings that needs pass through
|
-- Only remove mappings that needs pass through
|
||||||
|
|
@ -81,6 +84,9 @@ isEvolution = className ~? "gnome.Evolution"
|
||||||
isFirefox :: Query Bool
|
isFirefox :: Query Bool
|
||||||
isFirefox = className =? "firefox"
|
isFirefox = className =? "firefox"
|
||||||
|
|
||||||
|
isSpotify :: Query Bool
|
||||||
|
isSpotify = isFirefox <&&> title ~? "Spotify"
|
||||||
|
|
||||||
isFirefoxPip :: Query Bool
|
isFirefoxPip :: Query Bool
|
||||||
isFirefoxPip = isFirefox <&&> title =? "Picture-in-Picture"
|
isFirefoxPip = isFirefox <&&> title =? "Picture-in-Picture"
|
||||||
|
|
||||||
|
|
@ -127,6 +133,25 @@ myManageHook =
|
||||||
]
|
]
|
||||||
<> namedScratchpadManageHook myScratchpads
|
<> namedScratchpadManageHook myScratchpads
|
||||||
|
|
||||||
|
myEventHandleHook :: Event -> X All
|
||||||
|
myEventHandleHook =
|
||||||
|
-- TODO: is there a way to always open certain sites in new windows in firefox?
|
||||||
|
onTitleChange $ composeAll
|
||||||
|
[ isSpotify --> doShiftAndViewIfMoved multimediaWS
|
||||||
|
, isDiscord --> doShiftAndViewIfMoved chatWS
|
||||||
|
]
|
||||||
|
|
||||||
|
-- If the title changes in the background, we don't want to greedy view that workspace.
|
||||||
|
-- Imagine Spotify playing in the background, a track change would focus that workspace.
|
||||||
|
-- We prevent this by checking if the window is already there.
|
||||||
|
doShiftAndViewIfMoved :: WorkspaceId -> Query (Endo WindowSet)
|
||||||
|
doShiftAndViewIfMoved n = doF . shiftAndViewIfMoved n =<< ask
|
||||||
|
|
||||||
|
shiftAndViewIfMoved :: WorkspaceId -> Window -> WindowSet -> WindowSet
|
||||||
|
shiftAndViewIfMoved n w s = case W.findTag w s of
|
||||||
|
Just from | n `W.tagMember` s && n /= from -> W.greedyView n $ W.shiftWin n w s
|
||||||
|
_ -> s
|
||||||
|
|
||||||
myStartupHook :: X ()
|
myStartupHook :: X ()
|
||||||
myStartupHook = do
|
myStartupHook = do
|
||||||
spawnOnce "fcitx5 &" -- Input method
|
spawnOnce "fcitx5 &" -- Input method
|
||||||
|
|
@ -261,6 +286,9 @@ altMask = mod1Mask
|
||||||
myWorkspaces :: [WorkspaceId]
|
myWorkspaces :: [WorkspaceId]
|
||||||
myWorkspaces = map (:[]) $ take 8 greekLower
|
myWorkspaces = map (:[]) $ take 8 greekLower
|
||||||
|
|
||||||
|
multimediaWS :: WorkspaceId
|
||||||
|
multimediaWS = myWorkspaces !! 6
|
||||||
|
|
||||||
chatWS :: WorkspaceId
|
chatWS :: WorkspaceId
|
||||||
chatWS = myWorkspaces !! 3
|
chatWS = myWorkspaces !! 3
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue