aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Hooks/Script.hs
diff options
context:
space:
mode:
authorTrevor Elliott <trevor@galois.com>2008-04-16 23:30:24 +0200
committerTrevor Elliott <trevor@galois.com>2008-04-16 23:30:24 +0200
commitadf4bc5e5cbe409ff343207be08d9304208301b1 (patch)
tree46205260bedd54fd94259448c91a57e27fcdeb82 /XMonad/Hooks/Script.hs
parentf68320da1881af928265ba83f1d275dd30cb9be5 (diff)
downloadXMonadContrib-adf4bc5e5cbe409ff343207be08d9304208301b1.tar.gz
XMonadContrib-adf4bc5e5cbe409ff343207be08d9304208301b1.tar.xz
XMonadContrib-adf4bc5e5cbe409ff343207be08d9304208301b1.zip
Script-based hooks
darcs-hash:20080416213024-5b2f6-adc47e1fc23870c99aca6eccf962a23932bd1eb8.gz
Diffstat (limited to '')
-rw-r--r--XMonad/Hooks/Script.hs54
1 files changed, 54 insertions, 0 deletions
diff --git a/XMonad/Hooks/Script.hs b/XMonad/Hooks/Script.hs
new file mode 100644
index 0000000..d9a4ee1
--- /dev/null
+++ b/XMonad/Hooks/Script.hs
@@ -0,0 +1,54 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module : XMonad.Hooks.Script
+-- Copyright : (c) Trevor Elliott <trevor@galois.com>
+-- License : BSD3-style (see LICENSE)
+--
+-- Maintainer : Trevor Elliott <trevor@galois.com>
+-- Stability : unstable
+-- Portability : unportable
+--
+-- Provides a simple interface for running a ~/.xmonad/hooks script with the
+-- name of a hook.
+--
+-----------------------------------------------------------------------------
+
+module XMonad.Hooks.Script (
+ -- * Usage
+ -- $usage
+
+ -- * Script Hook Interface
+ execScriptHook
+ ) where
+
+--
+-- Useful Imports
+--
+import XMonad
+
+import Control.Monad.Trans
+import System.Directory
+
+-- $usage
+--
+-- This module allows you to run a centrally located script with the text
+-- name of a hook. The script is assumed to be located at @~\/.xmonad\/hooks@.
+--
+-- For example, if you wanted to run the hook "startup" in your script every
+-- time your startup hook ran, you could modify your xmonad config as such:
+--
+-- > main = xmonad $ defaultConfig {
+-- > ...
+-- > startupHook = execScriptHook "startup"
+-- > ...
+-- > }
+--
+-- Now, everytime the startup hook runs, the command "~\/.xmonad/hooks startup"
+-- will also.
+
+-- | Execute a named script hook
+execScriptHook :: MonadIO m => String -> m ()
+execScriptHook hook = io $ do
+ home <- getHomeDirectory
+ let script = home ++ "/.xmonad/hooks "
+ spawn (script ++ hook)