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)
(No difference)

Revision as of 03:11, 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
     io $ threadDelay 105000

    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