[xmonad] darcs patch: generic menu and window bringer

Travis B. Hartwell nafai at travishartwell.net
Sat Oct 25 01:16:37 EDT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I've had to make some patches for XMonadContrib in order to support the
new Gtk replacement for dmenu I have written:

http://github.com/Nafai77/utilities/tree/master/src/gtkmenu.hs

Screenshot here:
http://www.travishartwell.net/switcher.png

I use these changes by doing this in my xmonad.hs:
import XMonad.Actions.WindowBringer (gotoMenu')

Then, for example, in a key binding:
 ("M-w", gotoMenu' "gtkmenu" )

Please let me know if there is a better way to make this generic and
clean it up.  What I have here compiles and works, so I thought I would
submit it.

Thanks for the great software and all the help on #xmonad!

- --
Travis B. Hartwell
Software Toolsmith

Blog:
http://www.travishartwell.net/blog

Where to find me:
http://www.travishartwell.net/blog/static/where_to_find_me
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJAqu1Ifupsj9YJrURAlG9AKDsVvHa9Ll4ExYFqVSlXjDx2mSCfACcDFjQ
l5KK0ERP4ltl1M9woi9HaHA=
=icOv
-----END PGP SIGNATURE-----
-------------- next part --------------
Fri Oct 24 23:07:14 MDT 2008  Travis B. Hartwell <nafai at travishartwell.net>
  * generic menu and window bringer

New patches:

[generic menu and window bringer
Travis B. Hartwell <nafai at travishartwell.net>**20081025050714] {
hunk ./XMonad/Actions/WindowBringer.hs 20
 module XMonad.Actions.WindowBringer (
                                     -- * Usage
                                     -- $usage
-                                    gotoMenu, bringMenu, windowMap,
+                                    gotoMenu, gotoMenu', bringMenu, windowMap,
                                     bringWindow
                                    ) where
 
hunk ./XMonad/Actions/WindowBringer.hs 30
 import qualified XMonad.StackSet as W
 import XMonad
 import qualified XMonad as X
-import XMonad.Util.Dmenu (dmenuMap)
+import XMonad.Util.Dmenu (dmenuMap, menu, menuMap)
 import XMonad.Util.NamedWindows (getName)
 
 -- $usage
hunk ./XMonad/Actions/WindowBringer.hs 53
 gotoMenu :: X ()
 gotoMenu = actionMenu W.focusWindow
 
+gotoMenu' :: String -> X ()
+gotoMenu' menuCmd = actionMenu' menuCmd 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 ()
hunk ./XMonad/Actions/WindowBringer.hs 68
 -- | Calls dmenuMap to grab the appropriate Window, and hands it off to action
 --   if found.
 actionMenu :: (Window -> X.WindowSet -> X.WindowSet) -> X()
-actionMenu action = windowMap >>= dmenuMap >>= flip X.whenJust (windows . action)
+actionMenu action = actionMenu'' dmenuMap action
 
hunk ./XMonad/Actions/WindowBringer.hs 70
+actionMenu' :: String -> (Window -> X.WindowSet -> X.WindowSet) -> X()
+actionMenu' menuCmd action = actionMenu'' menuMapFunction action
+    where
+      menuFunction :: [String] -> X String
+      menuFunction opts = menu menuCmd opts
+      menuMapFunction :: M.Map String a -> X (Maybe a)
+      menuMapFunction selectionMap = menuMap menuFunction selectionMap
+
+actionMenu'' :: (M.Map String Window -> X (Maybe a)) -> (a -> X.WindowSet -> X.WindowSet) -> X()
+actionMenu'' menuMapFunction action = windowMap >>= menuMapFunction >>= flip X.whenJust (windows . action)
+                                      
 -- | A map from window names to Windows.
 windowMap :: X (M.Map String Window)
 windowMap = do
hunk ./XMonad/Util/Dmenu.hs 20
 module XMonad.Util.Dmenu (
                             -- * Usage
                             -- $usage
-                            dmenu, dmenuXinerama, dmenuMap
+                            dmenu, dmenuXinerama, dmenuMap, menu, menuMap
                            ) where
 
 import XMonad
hunk ./XMonad/Util/Dmenu.hs 43
     io $ runProcessWithInput "dmenu" ["-xs", show (curscreen+1)] (unlines opts)
 
 dmenu :: [String] -> X String
-dmenu opts = io $ runProcessWithInput "dmenu" [] (unlines opts)
+dmenu opts = menu "demnu" opts
 
hunk ./XMonad/Util/Dmenu.hs 45
-dmenuMap :: M.Map String a -> X (Maybe a)
-dmenuMap selectionMap = do
-  selection <- dmenu (M.keys selectionMap)
-  return $ M.lookup selection selectionMap
+menu :: String -> [String] -> X String
+menu menuCmd opts = io $ runProcessWithInput menuCmd [] (unlines opts)
hunk ./XMonad/Util/Dmenu.hs 48
+menuMap :: ([String] -> X String) -> M.Map String a -> X (Maybe a)
+menuMap menuFunction selectionMap = do
+  selection <- menuFunction (M.keys selectionMap)
+  return $ M.lookup selection selectionMap
+         
+dmenuMap :: M.Map String a -> X (Maybe a)
+dmenuMap selectionMap = menuMap dmenu selectionMap
}

Context:

[Use the new completion on tab setting
Spencer Janssen <spencerjanssen at gmail.com>**20080911085940] 
[Only start to show the completion window with more than one match
Joachim Breitner <mail at joachim-breitner.de>**20080908110129] 
[XPrompt: Add showCompletionOnTab option
Joachim Breitner <mail at joachim-breitner.de>**20080908105758
 This patch partially implements
 http://code.google.com/p/xmonad/issues/detail?id=215
 It adds a XPConfig option that, if enabled, hides the completion window
 until the user presses Tab once. Default behaviour is preserved.
 TODO: If Tab causes a unique completion, continue to hide the completion
 window.
] 
[XMonad.Actions.Plane.planeKeys: function to make easier to configure
Marco Túlio Gontijo e Silva <marcot at riseup.net>**20080714153601] 
[XMonad.Actions.Plane: removed unneeded hiding
Marco Túlio Gontijo e Silva <marcot at riseup.net>**20080714152631] 
[Improvements in documentation
Marco Túlio Gontijo e Silva <marcot at riseup.net>**20080709002425] 
[Fix haddock typos in XMonad.Config.{Desktop,Gnome,Kde}
Spencer Janssen <spencerjanssen at gmail.com>**20080911040808] 
[add clearUrgents for your keys
Devin Mullins <me at twifkak.com>**20080909055425] 
[add reminder functionality to UrgencyHook
Devin Mullins <me at twifkak.com>**20080824200548
 I'm considering rewriting remindWhen and suppressWhen as UrgencyHookModifiers, so to speak. Bleh.
] 
[TAG 0.8
Spencer Janssen <spencerjanssen at gmail.com>**20080905195420] 
Patch bundle hash:
11524e162274c75cacad2dff1a155a91dda3868f


More information about the xmonad mailing list