Difference between revisions of "Xmonad/Config archive/Kapil gnomemenuadd.hs"

From HaskellWiki
Jump to navigation Jump to search
(simple modification to XMonad.Config.Gnome to popup Gnome Menu)
 
m (Add note about delay)
 
Line 26: Line 26:
 
-- is specified at
 
-- is specified at
 
-- https://code.google.com/p/xmonad/issue/detail?id=451
 
-- https://code.google.com/p/xmonad/issue/detail?id=451
  +
-- Increase the delay if it doesn't work for you.
io $ threadDelay 105000
+
io $ threadDelay 200000
   
 
io $ allocaXEvent $ \e -> do
 
io $ allocaXEvent $ \e -> do

Latest revision as of 04:41, 26 August 2012

This gives a hacky solution to Issue 451 in xmonad

import XMonad
import XMonad.Config.Gnome
import XMonad.Config.Desktop

import Control.Concurrent (threadDelay)
import qualified Data.Map as M

main = xmonad $ gnomeConfig {
    ,keys         = addlKeys <+> keys desktopConfig
   }

addlKeys conf@(XConfig {modMask = modm}) = M.fromList $
    [ ((modm, xK_F1), gnomeMenu) ]

gnomeMenu :: X ()
gnomeMenu = withDisplay $ \dpy -> do
    rw <- asks theRoot
    gnome_panel <- getAtom "_GNOME_PANEL_ACTION"
    panel_menu  <- getAtom "_GNOME_PANEL_ACTION_MAIN_MENU"
   
    -- a "magic" delay that just makes this work. The problem
    -- is specified at
    -- https://code.google.com/p/xmonad/issue/detail?id=451
    -- Increase the delay if it doesn't work for you.
    io $ threadDelay 200000

    io $ allocaXEvent $ \e -> do
        setEventType e clientMessage
        setClientMessageEvent e rw gnome_panel 32 panel_menu 0
        sendEvent dpy rw False structureNotifyMask e
        sync dpy False