diff options
author | mathstuf <mathstuf@gmail.com> | 2010-09-05 03:35:22 +0200 |
---|---|---|
committer | mathstuf <mathstuf@gmail.com> | 2010-09-05 03:35:22 +0200 |
commit | 55321286c9872f8590002b869a4b47989e32e417 (patch) | |
tree | 3dd4905231c1eb4b787a71894ed54d409515e179 /XMonad | |
parent | a21ffda23f27a7ce44c1791475664e070e983913 (diff) | |
download | XMonadContrib-55321286c9872f8590002b869a4b47989e32e417.tar.gz XMonadContrib-55321286c9872f8590002b869a4b47989e32e417.tar.xz XMonadContrib-55321286c9872f8590002b869a4b47989e32e417.zip |
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
Diffstat (limited to 'XMonad')
-rw-r--r-- | XMonad/Actions/WindowBringer.hs | 56 |
1 files changed, 45 insertions, 11 deletions
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) |