aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Util
diff options
context:
space:
mode:
Diffstat (limited to 'XMonad/Util')
-rw-r--r--XMonad/Util/NamedScratchpad.hs42
1 files changed, 31 insertions, 11 deletions
diff --git a/XMonad/Util/NamedScratchpad.hs b/XMonad/Util/NamedScratchpad.hs
index 8d08e47..a7153e0 100644
--- a/XMonad/Util/NamedScratchpad.hs
+++ b/XMonad/Util/NamedScratchpad.hs
@@ -17,6 +17,9 @@ module XMonad.Util.NamedScratchpad (
-- * Usage
-- $usage
NamedScratchpad(..),
+ nonFloating,
+ defaultFloating,
+ customFloating,
NamedScratchpads,
namedScratchpadAction,
namedScratchpadManageHook,
@@ -54,19 +57,24 @@ import qualified XMonad.StackSet as W
-- > import XMonad.Util.NamedScratchpad
-- >
-- > scratchpads = [
--- > -- run htop in xterm, find it by title, use default geometry
--- > NS "htop" "xterm -e htop" (title =? "htop") Nothing ,
--- > -- run stardict, find it by class name, place the window
+-- > -- run htop in xterm, find it by title, use default floating window placement
+-- > NS "htop" "xterm -e htop" (title =? "htop") defaultFloating ,
+-- >
+-- > -- run stardict, find it by class name, place it in the floating window
-- > -- 1/6 of screen width from the left, 1/6 of screen height
-- > -- from the top, 2/3 of screen width by 2/3 of screen height
-- > NS "stardict" "stardict" (className =? "Stardict")
--- > (Just $ W.RationalRect (1/6) (1/6) (2/3) (2/3))
--- > ]
+-- > (customFloating $ W.RationalRect (1/6) (1/6) (2/3) (2/3)) ,
+-- >
+-- > -- run gvim, find by role, don't float
+-- > NS "notes" "gvim --role notes ~/notes.txt" (role =? "notes") nonFloating
+-- > ] where role = stringProperty "WM_WINDOW_ROLE"
--
-- Add keybindings:
--
-- > , ((modMask x .|. controlMask .|. shiftMask, xK_t), namedScratchpadAction scratchpads "htop")
-- > , ((modMask x .|. controlMask .|. shiftMask, xK_s), namedScratchpadAction scratchpads "stardict")
+-- > , ((modMask x .|. controlMask .|. shiftMask, xK_n), namedScratchpadAction scratchpads "notes")
--
-- ... and a manage hook:
--
@@ -77,18 +85,30 @@ import qualified XMonad.StackSet as W
--
-- | Single named scratchpad configuration
-data NamedScratchpad = NS { name :: String -- ^ Scratchpad name
- , cmd :: String -- ^ Command used to run application
- , query :: Query Bool -- ^ Query to find already running application
- , rect :: Maybe W.RationalRect -- ^ Floating window geometry
+data NamedScratchpad = NS { name :: String -- ^ Scratchpad name
+ , cmd :: String -- ^ Command used to run application
+ , query :: Query Bool -- ^ Query to find already running application
+ , hook :: ManageHook -- ^ Manage hook called for application window, use it to define the placement. See @nonFloating@, @defaultFloating@ and @customFloating@
}
+-- | Manage hook that makes the window non-floating
+nonFloating :: ManageHook
+nonFloating = idHook
+
+-- | Manage hook that makes the window floating with the default placement
+defaultFloating :: ManageHook
+defaultFloating = doFloat
+
+-- | Manage hook that makes the window floating with custom placement
+customFloating :: W.RationalRect -> ManageHook
+customFloating = doRectFloat
+
-- | Named scratchpads configuration
type NamedScratchpads = [NamedScratchpad]
-- | Finds named scratchpad configuration by name
findByName :: NamedScratchpads -> String -> Maybe NamedScratchpad
-findByName c s = listToMaybe $ filter ((s==).name) c
+findByName c s = listToMaybe $ filter ((s==) . name) c
-- | Runs application which should appear in specified scratchpad
runApplication :: NamedScratchpad -> X ()
@@ -128,7 +148,7 @@ scratchpadWorkspaceTag = "NSP"
-- | Manage hook to use with named scratchpads
namedScratchpadManageHook :: NamedScratchpads -- ^ Named scratchpads configuration
-> ManageHook
-namedScratchpadManageHook = composeAll . fmap (\c -> query c --> maybe doFloat doRectFloat (rect c))
+namedScratchpadManageHook = composeAll . fmap (\c -> query c --> hook c)
-- | Transforms a workspace list containing the NSP workspace into one that
-- doesn't contain it. Intended for use with logHooks.