Add gnomeRegister to C.Gnome.

Credit to Joachim Breitner here:
http://www.haskell.org/pipermail/xmonad/2009-May/007984.html
This commit is contained in:
Adam Vogt 2009-09-17 23:21:50 +00:00
parent cbd978c3b5
commit c4cae4839d

View File

@ -15,7 +15,8 @@ module XMonad.Config.Gnome (
-- * Usage -- * Usage
-- $usage -- $usage
gnomeConfig, gnomeConfig,
gnomeRun gnomeRun,
gnomeRegister
) where ) where
import XMonad import XMonad
@ -23,14 +24,20 @@ import XMonad.Config.Desktop
import qualified Data.Map as M import qualified Data.Map as M
import System.Environment (getEnvironment)
import System.Cmd (rawSystem)
import Control.Concurrent (forkIO)
-- $usage -- $usage
-- To use this module, start with the following @~\/.xmonad\/xmonad.hs@: -- To use this module, start with the following @~\/.xmonad\/xmonad.hs@:
-- --
-- > import XMonad -- > import XMonad
-- > import XMonad.Config.Gnome -- > import XMonad.Config.Gnome
-- > -- >
-- > main = xmonad gnomeConfig -- > main = do
-- -- > gnomeRegister
-- > xmonad gnomeConfig
gnomeConfig = desktopConfig gnomeConfig = desktopConfig
{ terminal = "gnome-terminal" { terminal = "gnome-terminal"
@ -53,3 +60,24 @@ gnomeRun = withDisplay $ \dpy -> do
setClientMessageEvent e rw gnome_panel 32 panel_run 0 setClientMessageEvent e rw gnome_panel 32 panel_run 0
sendEvent dpy rw False structureNotifyMask e sendEvent dpy rw False structureNotifyMask e
sync dpy False sync dpy False
-- | Register xmonad with gnome. 'dbus-send' must be in the $PATH with which
-- xmonad is started.
--
-- This action reduces a delay on startup only only if you have configured
-- gnome-session>=2.26: to start xmonad with a command as such:
--
-- > gconftool-2 -s /desktop/gnome/session/required_components/windowmanager xmonad --type string
gnomeRegister :: IO ()
gnomeRegister = do
let void_ = fmap (const ())
x <- lookup "DESKTOP_AUTOSTART_ID" `fmap` getEnvironment
whenJust x $ \sessionId -> void_ $ forkIO $ void_ $
rawSystem "dbus-send"
["--session"
,"--print-reply=string"
,"--dest=org.gnome.SessionManager"
,"/org/gnome/SessionManager"
,"org.gnome.SessionManager.RegisterClient"
,"string:xmonad"
,"string:"++sessionId]