aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Util
diff options
context:
space:
mode:
authorBraden Shepherdson <Braden.Shepherdson@gmail.com>2008-02-25 19:36:33 +0100
committerBraden Shepherdson <Braden.Shepherdson@gmail.com>2008-02-25 19:36:33 +0100
commitc823d73e9af1096727bccbd4abd6d237a78ea271 (patch)
treea431ee74f6325d7fd0d7edcc17ef31e981167518 /XMonad/Util
parentc72acaf81a7b7353151a4beb98d4c0c8840baa51 (diff)
downloadXMonadContrib-c823d73e9af1096727bccbd4abd6d237a78ea271.tar.gz
XMonadContrib-c823d73e9af1096727bccbd4abd6d237a78ea271.tar.xz
XMonadContrib-c823d73e9af1096727bccbd4abd6d237a78ea271.zip
Scratchpad terminal
Key binding and ManageHook to pop up a small, floating terminal window for a few quick commands. Combined with a utility like detach[1], makes a great X application launcher. Requires my two new ManageHooks (doRectFloat, specifically). [1] http://detach.sourceforge.net darcs-hash:20080225183633-d53a8-d3d517320cd98c1b6ea2abe82262a0a6877f1406.gz
Diffstat (limited to 'XMonad/Util')
-rw-r--r--XMonad/Util/Scratchpad.hs81
1 files changed, 81 insertions, 0 deletions
diff --git a/XMonad/Util/Scratchpad.hs b/XMonad/Util/Scratchpad.hs
new file mode 100644
index 0000000..3eab56c
--- /dev/null
+++ b/XMonad/Util/Scratchpad.hs
@@ -0,0 +1,81 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module : XMonad.Util.Scratchpad
+-- Copyright : (c) Braden Shepherdson 2008
+-- License : BSD-style (as xmonad)
+--
+-- Maintainer : Braden.Shepherdson@gmail.com
+-- Stability : unstable
+-- Portability : unportable
+--
+-- Very handy hotkey-launched floating terminal window.
+--
+-- A tool like detach (<http://detach.sourceforge.net>) turns it
+-- into a launchpad for X apps.
+--
+-- By default, your xmonad terminal is used, and mod+s is the hotkey.
+-- The default ManageHook uses a centered, half-screen-wide,
+-- quarter-screen-tall window.
+-- The key, position and size are configurable.
+--
+-- The terminal application must support the @-title@ argument.
+-- Known supported terminals: rxvt, rxvt-unicode, xterm.
+-- Most others are likely to follow the lead set by xterm.
+--
+-- Add the following to your xmonad.hs keybindings to use the default mod+s:
+--
+-- > scratchpadSpawnDefault conf
+--
+-- Or specify your own key binding, with the action:
+--
+-- > scratchpadSpawnAction conf
+--
+-- And add one of the @scratchpadManageHook*@s to your ManageHook list.
+-- The default rectangle is half the screen wide and a quarter of the
+-- screen tall, centered.
+--
+-----------------------------------------------------------------------------
+
+module XMonad.Util.Scratchpad (
+ scratchpadSpawnDefault
+ ,scratchpadSpawnAction
+ ,scratchpadManageHookDefault
+ ,scratchpadManageHook
+ ) where
+
+import XMonad
+import XMonad.Core
+import XMonad.Hooks.ManageHelpers (doRectFloat)
+import qualified XMonad.StackSet
+
+
+
+-- | Complete key binding. Pops up the terminal on mod+s.
+scratchpadSpawnDefault :: XConfig Layout -- ^ The configuration, to retrieve terminal and modMask
+ -> ((KeyMask, KeySym), X ())
+scratchpadSpawnDefault conf = ((modMask conf, xK_s), scratchpadSpawnAction conf)
+
+
+-- | Action to pop up the terminal, for the user to bind to a custom key.
+scratchpadSpawnAction :: XConfig Layout -- ^ The configuration, to retrieve the terminal
+ -> X ()
+scratchpadSpawnAction conf = spawn $ terminal conf ++ " -title scratchpad"
+
+
+
+-- | The ManageHook, with the default rectangle:
+-- Half the screen wide, a quarter of the screen tall, centered.
+scratchpadManageHookDefault :: ManageHook
+scratchpadManageHookDefault = scratchpadManageHook scratchpadDefaultRect
+
+
+-- | The ManageHook, with a user-specified StackSet.RationalRect.
+scratchpadManageHook :: XMonad.StackSet.RationalRect -- ^ User-specified screen rectangle.
+ -> ManageHook
+scratchpadManageHook rect = title =? "scratchpad" --> doRectFloat rect
+
+
+scratchpadDefaultRect :: XMonad.StackSet.RationalRect
+scratchpadDefaultRect = XMonad.StackSet.RationalRect 0.25 0.375 0.5 0.25
+
+