mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
X.A.WindowBringer: Add a filter function to config
This commit is contained in:
parent
b4a13e6b1b
commit
09b1dc1a6e
@ -419,9 +419,13 @@
|
|||||||
|
|
||||||
* `XMonad.Prompt.WindowBringer`
|
* `XMonad.Prompt.WindowBringer`
|
||||||
|
|
||||||
- Added `windowApMap` function which maps application executable
|
- Added `windowAppMap` function which maps application executable
|
||||||
names to its underlying window.
|
names to its underlying window.
|
||||||
|
|
||||||
|
- A new field `windowFilter` was added to the config, which allows the user
|
||||||
|
to provide a function which will decide whether each window should be
|
||||||
|
included in the window bringer menu.
|
||||||
|
|
||||||
* `XMonad.Actions.Search`
|
* `XMonad.Actions.Search`
|
||||||
|
|
||||||
- The `hoogle` function now uses the new URL `hoogle.haskell.org`.
|
- The `hoogle` function now uses the new URL `hoogle.haskell.org`.
|
||||||
|
@ -24,6 +24,7 @@ module XMonad.Actions.WindowBringer (
|
|||||||
windowMap, windowAppMap, windowMap', bringWindow, actionMenu
|
windowMap, windowAppMap, windowMap', bringWindow, actionMenu
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import Control.Monad
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
|
||||||
import qualified XMonad.StackSet as W
|
import qualified XMonad.StackSet as W
|
||||||
@ -50,12 +51,14 @@ data WindowBringerConfig = WindowBringerConfig
|
|||||||
{ menuCommand :: String -- ^ The shell command that will handle window selection
|
{ menuCommand :: String -- ^ The shell command that will handle window selection
|
||||||
, menuArgs :: [String] -- ^ Arguments to be passed to menuCommand
|
, menuArgs :: [String] -- ^ Arguments to be passed to menuCommand
|
||||||
, windowTitler :: X.WindowSpace -> Window -> X String -- ^ A function that produces window titles given a workspace and a window
|
, windowTitler :: X.WindowSpace -> Window -> X String -- ^ A function that produces window titles given a workspace and a window
|
||||||
|
, windowFilter :: Window -> X Bool -- ^ Filter function to decide which windows to consider
|
||||||
}
|
}
|
||||||
|
|
||||||
instance Default WindowBringerConfig where
|
instance Default WindowBringerConfig where
|
||||||
def = WindowBringerConfig{ menuCommand = "dmenu"
|
def = WindowBringerConfig{ menuCommand = "dmenu"
|
||||||
, menuArgs = ["-i"]
|
, menuArgs = ["-i"]
|
||||||
, windowTitler = decorateName
|
, windowTitler = decorateName
|
||||||
|
, windowFilter = \_ -> return True
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | Pops open a dmenu with window titles. Choose one, and you will be
|
-- | Pops open a dmenu with window titles. Choose one, and you will be
|
||||||
@ -122,11 +125,8 @@ bringWindow w ws = W.shiftWin (W.currentTag ws) w ws
|
|||||||
-- | Calls dmenuMap to grab the appropriate Window, and hands it off to action
|
-- | Calls dmenuMap to grab the appropriate Window, and hands it off to action
|
||||||
-- if found.
|
-- if found.
|
||||||
actionMenu :: WindowBringerConfig -> (Window -> X.WindowSet -> X.WindowSet) -> X ()
|
actionMenu :: WindowBringerConfig -> (Window -> X.WindowSet -> X.WindowSet) -> X ()
|
||||||
actionMenu WindowBringerConfig{ menuCommand = cmd
|
actionMenu c@WindowBringerConfig{ menuCommand = cmd, menuArgs = args } action =
|
||||||
, menuArgs = args
|
windowMap' c >>= menuMapFunction >>= flip X.whenJust (windows . action)
|
||||||
, windowTitler = titler
|
|
||||||
} action
|
|
||||||
= windowMap' titler >>= menuMapFunction >>= flip X.whenJust (windows . action)
|
|
||||||
where
|
where
|
||||||
menuMapFunction :: M.Map String a -> X (Maybe a)
|
menuMapFunction :: M.Map String a -> X (Maybe a)
|
||||||
menuMapFunction = menuMapArgs cmd args
|
menuMapFunction = menuMapArgs cmd args
|
||||||
@ -134,18 +134,19 @@ actionMenu WindowBringerConfig{ menuCommand = cmd
|
|||||||
|
|
||||||
-- | A map from window names to Windows.
|
-- | A map from window names to Windows.
|
||||||
windowMap :: X (M.Map String Window)
|
windowMap :: X (M.Map String Window)
|
||||||
windowMap = windowMap' decorateName
|
windowMap = windowMap' def
|
||||||
|
|
||||||
-- | A map from application executable names to Windows.
|
-- | A map from application executable names to Windows.
|
||||||
windowAppMap :: X (M.Map String Window)
|
windowAppMap :: X (M.Map String Window)
|
||||||
windowAppMap = windowMap' decorateAppName
|
windowAppMap = windowMap' def { windowTitler = decorateAppName }
|
||||||
|
|
||||||
-- | A map from window names to Windows, given a windowTitler function.
|
-- | A map from window names to Windows, given a windowTitler function.
|
||||||
windowMap' :: (X.WindowSpace -> Window -> X String) -> X (M.Map String Window)
|
windowMap' :: WindowBringerConfig -> X (M.Map String Window)
|
||||||
windowMap' titler = do
|
windowMap' WindowBringerConfig{ windowTitler = titler, windowFilter = include } = do
|
||||||
ws <- gets X.windowset
|
windowSet <- gets X.windowset
|
||||||
M.fromList . concat <$> mapM keyValuePairs (W.workspaces ws)
|
M.fromList . concat <$> mapM keyValuePairs (W.workspaces windowSet)
|
||||||
where keyValuePairs ws = mapM (keyValuePair ws) $ W.integrate' (W.stack ws)
|
where keyValuePairs ws = let wins = W.integrate' (W.stack ws)
|
||||||
|
in mapM (keyValuePair ws) =<< filterM include wins
|
||||||
keyValuePair ws w = (, w) <$> titler ws w
|
keyValuePair ws w = (, w) <$> titler ws w
|
||||||
|
|
||||||
-- | Returns the window name as will be listed in dmenu.
|
-- | Returns the window name as will be listed in dmenu.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user