From c606cefb1131091ac67f242761acafa2f7c72c77 Mon Sep 17 00:00:00 2001 From: "zhen.sydow" Date: Tue, 13 May 2008 22:12:52 +0200 Subject: move AppLauncher from Actions module to Prompt module darcs-hash:20080513201252-3cf16-f92855fb696915644cc2cdbc52f7b3f860894f3d.gz --- XMonad/Actions/AppLauncher.hs | 70 ----------------------------------------- XMonad/Prompt/AppLauncher.hs | 72 +++++++++++++++++++++++++++++++++++++++++++ xmonad-contrib.cabal | 2 +- 3 files changed, 73 insertions(+), 71 deletions(-) delete mode 100644 XMonad/Actions/AppLauncher.hs create mode 100644 XMonad/Prompt/AppLauncher.hs diff --git a/XMonad/Actions/AppLauncher.hs b/XMonad/Actions/AppLauncher.hs deleted file mode 100644 index a2026ad..0000000 --- a/XMonad/Actions/AppLauncher.hs +++ /dev/null @@ -1,70 +0,0 @@ -{- | - Module : XMonad.Actions.AppLauncher - Copyright : (C) 2008 Luis Cabellos - License : None; public domain - - Maintainer : - 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/Prompt/AppLauncher.hs b/XMonad/Prompt/AppLauncher.hs new file mode 100644 index 0000000..4cb3ecc --- /dev/null +++ b/XMonad/Prompt/AppLauncher.hs @@ -0,0 +1,72 @@ +----------------------------------------------------------------------------- +-- | +-- Module : XMonad.Prompt.AppLauncher +-- Copyright : (C) 2008 Luis Cabellos +-- License : BSD3 +-- +-- 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.Prompt.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.Prompt.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 47bf46a..16706fd 100644 --- a/xmonad-contrib.cabal +++ b/xmonad-contrib.cabal @@ -67,7 +67,6 @@ library XMonad.Doc.Configuring XMonad.Doc.Extending XMonad.Doc.Developing - XMonad.Actions.AppLauncher XMonad.Actions.Commands XMonad.Actions.ConstrainedResize XMonad.Actions.CopyWindow @@ -165,6 +164,7 @@ library XMonad.Prompt.Directory XMonad.Prompt XMonad.Prompt.AppendFile + XMonad.Prompt.AppLauncher XMonad.Prompt.Input XMonad.Prompt.Email XMonad.Prompt.Layout -- cgit v1.2.3