From 55321286c9872f8590002b869a4b47989e32e417 Mon Sep 17 00:00:00 2001 From: mathstuf Date: Sun, 5 Sep 2010 03:35:22 +0200 Subject: windowbringer-menu-choice Ignore-this: 3f57b88d725b04f07ce6a43b8d0f56ff Add functions to allow users to use a menu other than dmenu and pass arguments to the menu. darcs-hash:20100905013522-4ccff-7c0ff1eaed7d70d32ea6699a303deb3af44fcb7f.gz --- XMonad/Actions/WindowBringer.hs | 56 +++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 11 deletions(-) (limited to 'XMonad/Actions') diff --git a/XMonad/Actions/WindowBringer.hs b/XMonad/Actions/WindowBringer.hs index eeca913..e7c8fec 100644 --- a/XMonad/Actions/WindowBringer.hs +++ b/XMonad/Actions/WindowBringer.hs @@ -17,7 +17,9 @@ module XMonad.Actions.WindowBringer ( -- * Usage -- $usage - gotoMenu, gotoMenu', bringMenu, windowMap, + gotoMenu, gotoMenu', gotoMenuArgs, gotoMenuArgs', + bringMenu, bringMenu', bringMenuArgs, bringMenuArgs', + windowMap, bringWindow ) where @@ -27,7 +29,7 @@ import qualified Data.Map as M import qualified XMonad.StackSet as W import XMonad import qualified XMonad as X -import XMonad.Util.Dmenu (menuMap) +import XMonad.Util.Dmenu (menuMapArgs) import XMonad.Util.NamedWindows (getName) -- $usage @@ -44,19 +46,54 @@ import XMonad.Util.NamedWindows (getName) -- For detailed instructions on editing your key bindings, see -- "XMonad.Doc.Extending#Editing_key_bindings". +-- | Default menu command +defaultCmd :: String +defaultCmd = "dmenu" -- | Pops open a dmenu with window titles. Choose one, and you will be -- taken to the corresponding workspace. gotoMenu :: X () -gotoMenu = actionMenu W.focusWindow +gotoMenu = gotoMenuArgs [] +-- | Pops open a dmenu with window titles. Choose one, and you will be +-- taken to the corresponding workspace. This version takes a list of +-- arguments to pass to dmenu. +gotoMenuArgs :: [String] -> X () +gotoMenuArgs menuArgs = gotoMenuArgs' defaultCmd menuArgs + +-- | Pops open an application with window titles given over stdin. Choose one, +-- and you will be taken to the corresponding workspace. gotoMenu' :: String -> X () -gotoMenu' menuCmd = actionMenu' menuCmd W.focusWindow +gotoMenu' menuCmd = gotoMenuArgs' menuCmd [] + +-- | Pops open an application with window titles given over stdin. Choose one, +-- and you will be taken to the corresponding workspace. This version takes a +-- list of arguments to pass to dmenu. +gotoMenuArgs' :: String -> [String] -> X () +gotoMenuArgs' menuCmd menuArgs = actionMenu menuCmd menuArgs W.focusWindow -- | Pops open a dmenu with window titles. Choose one, and it will be -- dragged, kicking and screaming, into your current workspace. bringMenu :: X () -bringMenu = actionMenu bringWindow +bringMenu = bringMenuArgs [] + +-- | Pops open a dmenu with window titles. Choose one, and it will be +-- dragged, kicking and screaming, into your current workspace. This version +-- takes a list of arguments to pass to dmenu. +bringMenuArgs :: [String] -> X () +bringMenuArgs menuArgs = bringMenuArgs' defaultCmd menuArgs + +-- | Pops open an application with window titles given over stdin. Choose one, +-- and it will be dragged, kicking and screaming, into your current +-- workspace. +bringMenu' :: String -> X () +bringMenu' menuCmd = bringMenuArgs' menuCmd [] + +-- | Pops open an application with window titles given over stdin. Choose one, +-- and it will be dragged, kicking and screaming, into your current +-- workspace. This version allows arguments to the chooser to be specified. +bringMenuArgs' :: String -> [String] -> X () +bringMenuArgs' menuCmd menuArgs = actionMenu menuCmd menuArgs bringWindow -- | Brings the specified window into the current workspace. bringWindow :: Window -> X.WindowSet -> X.WindowSet @@ -64,14 +101,11 @@ bringWindow w ws = W.shiftWin (W.currentTag ws) w ws -- | Calls dmenuMap to grab the appropriate Window, and hands it off to action -- if found. -actionMenu :: (Window -> X.WindowSet -> X.WindowSet) -> X() -actionMenu action = actionMenu' "dmenu" action - -actionMenu' :: String -> (Window -> X.WindowSet -> X.WindowSet) -> X() -actionMenu' menuCmd action = windowMap >>= menuMapFunction >>= flip X.whenJust (windows . action) +actionMenu :: String -> [String] -> (Window -> X.WindowSet -> X.WindowSet) -> X () +actionMenu menuCmd menuArgs action = windowMap >>= menuMapFunction >>= flip X.whenJust (windows . action) where menuMapFunction :: M.Map String a -> X (Maybe a) - menuMapFunction selectionMap = menuMap menuCmd selectionMap + menuMapFunction selectionMap = menuMapArgs menuCmd menuArgs selectionMap -- | A map from window names to Windows. windowMap :: X (M.Map String Window) -- cgit v1.2.3