aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhen.sydow <zhen.sydow@gmail.com>2008-05-13 15:47:54 +0200
committerzhen.sydow <zhen.sydow@gmail.com>2008-05-13 15:47:54 +0200
commita9dd237b2693c518d71aa896bd64c1f65ae925d9 (patch)
treeb71ccbc2e22e6e0a5daa87bb07a337812ba74452
parent80b3682dfcfd51f43a3223e53dd0795684449085 (diff)
downloadXMonadContrib-a9dd237b2693c518d71aa896bd64c1f65ae925d9.tar.gz
XMonadContrib-a9dd237b2693c518d71aa896bd64c1f65ae925d9.tar.xz
XMonadContrib-a9dd237b2693c518d71aa896bd64c1f65ae925d9.zip
new contrib module to launch apps with command line parameters
darcs-hash:20080513134754-3cf16-32d43fbbad243d902b1de3c3ddf508fc6efebb9a.gz
-rw-r--r--XMonad/Actions/AppLauncher.hs70
-rw-r--r--xmonad-contrib.cabal1
2 files changed, 71 insertions, 0 deletions
diff --git a/XMonad/Actions/AppLauncher.hs b/XMonad/Actions/AppLauncher.hs
new file mode 100644
index 0000000..a2026ad
--- /dev/null
+++ b/XMonad/Actions/AppLauncher.hs
@@ -0,0 +1,70 @@
+{- |
+ Module : XMonad.Actions.AppLauncher
+ Copyright : (C) 2008 Luis Cabellos
+ License : None; public domain
+
+ Maintainer : <zhen.sydow@gmail.com>
+ Stability : unstable
+ Portability : unportable
+
+ A module for launch applicationes that receive parameters in the command line.
+ The launcher call a prompt to get the parameters.
+-}
+module XMonad.Actions.AppLauncher ( -- * Usage
+ -- $usage
+ launchApp
+
+ -- * Use case: launching gimp with file
+ -- $tip
+ ) where
+
+import XMonad (X(),MonadIO)
+import XMonad.Core (spawn)
+import XMonad.Prompt (XPrompt(showXPrompt), mkXPrompt, XPConfig())
+import XMonad.Prompt.Shell (getShellCompl)
+
+{- $usage
+ This module is intended to allow the launch of the same application
+ but changing the parameters using the user response. For example, when
+ you want to open a image in gimp program, you can open gimp and then use
+ the File Menu to open the image or you can use this module to select
+ the image in the command line.
+
+ We use Prompt to get the user command line. This also allow to autoexpand
+ the names of the files when we are writing the command line.
+ -}
+
+{- $tip
+
+First, you need to import necessary modules. Prompt is used to get the promp
+configuration and the AppLauncher module itself.
+
+> import XMonad.Prompt
+> import XMonad.Actions.AppLauncher as AL
+
+Then you can add the bindings to the applications.
+
+> ...
+> , ((modm, xK_g), AL.launchApp defaultXPConfig "gimp" )
+> , ((modm, xK_g), AL.launchApp defaultXPConfig "evince" )
+> ...
+
+ -}
+
+-- A customized prompt
+data AppPrompt = AppPrompt String
+instance XPrompt AppPrompt where
+ showXPrompt (AppPrompt n) = n ++ " "
+
+type Application = String
+type Parameters = String
+
+{- | Given an application and its parameters, launch the application. -}
+launch :: MonadIO m => Application -> Parameters -> m ()
+launch app params = spawn ( app ++ " " ++ params )
+
+
+{- | Get the user's response to a prompt an launch an application using the
+ input as command parameters of the application.-}
+launchApp :: XPConfig -> Application -> X ()
+launchApp config app = mkXPrompt (AppPrompt app) config (getShellCompl []) $ launch app
diff --git a/xmonad-contrib.cabal b/xmonad-contrib.cabal
index 7386ee0..df992ce 100644
--- a/xmonad-contrib.cabal
+++ b/xmonad-contrib.cabal
@@ -67,6 +67,7 @@ library
XMonad.Doc.Configuring
XMonad.Doc.Extending
XMonad.Doc.Developing
+ XMonad.Actions.AppLauncher
XMonad.Actions.Commands
XMonad.Actions.ConstrainedResize
XMonad.Actions.CopyWindow