diff options
author | konstantin.sobolev <konstantin.sobolev@gmail.com> | 2009-04-28 21:27:31 +0200 |
---|---|---|
committer | konstantin.sobolev <konstantin.sobolev@gmail.com> | 2009-04-28 21:27:31 +0200 |
commit | 53f08e31fc88e5024012902d74fcc323dbdba7b3 (patch) | |
tree | 9840c13e6f61410bc459a214b8e3b3d8676ad99d /XMonad/Util | |
parent | 45f2d6896b5928bc16ae37384a403679f349299b (diff) | |
download | XMonadContrib-53f08e31fc88e5024012902d74fcc323dbdba7b3.tar.gz XMonadContrib-53f08e31fc88e5024012902d74fcc323dbdba7b3.tar.xz XMonadContrib-53f08e31fc88e5024012902d74fcc323dbdba7b3.zip |
NS_Placement
Ignore-this: 7cf2d8d956c8e906b41731632db67e2a
Added ability to specify scratchpad manage hooks, mostly for defining window placement in a more flexible manner
darcs-hash:20090428192731-fb31b-cae7243900cb3091916fbb8d8d1bb96e2826fcf6.gz
Diffstat (limited to 'XMonad/Util')
-rw-r--r-- | XMonad/Util/NamedScratchpad.hs | 42 |
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. |