mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
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:
parent
cbd978c3b5
commit
c4cae4839d
@ -15,7 +15,8 @@ module XMonad.Config.Gnome (
|
||||
-- * Usage
|
||||
-- $usage
|
||||
gnomeConfig,
|
||||
gnomeRun
|
||||
gnomeRun,
|
||||
gnomeRegister
|
||||
) where
|
||||
|
||||
import XMonad
|
||||
@ -23,14 +24,20 @@ import XMonad.Config.Desktop
|
||||
|
||||
import qualified Data.Map as M
|
||||
|
||||
import System.Environment (getEnvironment)
|
||||
import System.Cmd (rawSystem)
|
||||
|
||||
import Control.Concurrent (forkIO)
|
||||
|
||||
-- $usage
|
||||
-- To use this module, start with the following @~\/.xmonad\/xmonad.hs@:
|
||||
--
|
||||
-- > import XMonad
|
||||
-- > import XMonad.Config.Gnome
|
||||
-- >
|
||||
-- > main = xmonad gnomeConfig
|
||||
--
|
||||
-- > main = do
|
||||
-- > gnomeRegister
|
||||
-- > xmonad gnomeConfig
|
||||
|
||||
gnomeConfig = desktopConfig
|
||||
{ terminal = "gnome-terminal"
|
||||
@ -53,3 +60,24 @@ gnomeRun = withDisplay $ \dpy -> do
|
||||
setClientMessageEvent e rw gnome_panel 32 panel_run 0
|
||||
sendEvent dpy rw False structureNotifyMask e
|
||||
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]
|
||||
|
Loading…
x
Reference in New Issue
Block a user