Xmonad/Config archive/Kapil gnomemenuadd.hs

From HaskellWiki
< Xmonad‎ | Config archive
Revision as of 04:41, 26 August 2012 by Kapil (talk | contribs) (Add note about delay)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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