{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
module XMonad.Config.Gnome (
gnomeConfig,
gnomeRun,
gnomeRegister,
desktopLayoutModifiers
) where
import XMonad
import XMonad.Config.Desktop
import XMonad.Util.Run (safeSpawn)
import qualified Data.Map as M
import System.Environment (getEnvironment)
gnomeConfig :: XConfig
(ModifiedLayout
AvoidStruts (Choose Tall (Choose (Mirror Tall) Full)))
gnomeConfig = XConfig
(ModifiedLayout
AvoidStruts (Choose Tall (Choose (Mirror Tall) Full)))
desktopConfig
{ terminal :: String
terminal = String
"gnome-terminal"
, keys :: XConfig Layout -> Map (ButtonMask, Time) (X ())
keys = forall {l :: * -> *}. XConfig l -> Map (ButtonMask, Time) (X ())
gnomeKeys forall a. Semigroup a => a -> a -> a
<> forall (l :: * -> *).
XConfig l -> XConfig Layout -> Map (ButtonMask, Time) (X ())
keys XConfig
(ModifiedLayout
AvoidStruts (Choose Tall (Choose (Mirror Tall) Full)))
desktopConfig
, startupHook :: X ()
startupHook = forall (m :: * -> *). MonadIO m => m ()
gnomeRegister forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (l :: * -> *). XConfig l -> X ()
startupHook XConfig
(ModifiedLayout
AvoidStruts (Choose Tall (Choose (Mirror Tall) Full)))
desktopConfig }
gnomeKeys :: XConfig l -> Map (ButtonMask, Time) (X ())
gnomeKeys XConfig{modMask :: forall (l :: * -> *). XConfig l -> ButtonMask
modMask = ButtonMask
modm} = forall k a. Ord k => [(k, a)] -> Map k a
M.fromList
[ ((ButtonMask
modm, Time
xK_p), X ()
gnomeRun)
, ((ButtonMask
modm forall a. Bits a => a -> a -> a
.|. ButtonMask
shiftMask, Time
xK_q), forall (m :: * -> *). MonadIO m => String -> m ()
spawn String
"gnome-session-quit --logout") ]
gnomeRun :: X ()
gnomeRun :: X ()
gnomeRun = forall a. (Display -> X a) -> X a
withDisplay forall a b. (a -> b) -> a -> b
$ \Display
dpy -> do
Time
rw <- forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Time
theRoot
Time
gnome_panel <- String -> X Time
getAtom String
"_GNOME_PANEL_ACTION"
Time
panel_run <- String -> X Time
getAtom String
"_GNOME_PANEL_ACTION_RUN_DIALOG"
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io forall a b. (a -> b) -> a -> b
$ forall a. (XEventPtr -> IO a) -> IO a
allocaXEvent forall a b. (a -> b) -> a -> b
$ \XEventPtr
e -> do
XEventPtr -> EventType -> IO ()
setEventType XEventPtr
e EventType
clientMessage
XEventPtr -> Time -> Time -> CInt -> Time -> Time -> IO ()
setClientMessageEvent XEventPtr
e Time
rw Time
gnome_panel CInt
32 Time
panel_run Time
0
Display -> Time -> Bool -> Time -> XEventPtr -> IO ()
sendEvent Display
dpy Time
rw Bool
False Time
structureNotifyMask XEventPtr
e
Display -> Bool -> IO ()
sync Display
dpy Bool
False
gnomeRegister :: MonadIO m => m ()
gnomeRegister :: forall (m :: * -> *). MonadIO m => m ()
gnomeRegister = forall (m :: * -> *) a. MonadIO m => IO a -> m a
io forall a b. (a -> b) -> a -> b
$ do
Maybe String
x <- forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup String
"DESKTOP_AUTOSTART_ID" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO [(String, String)]
getEnvironment
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe String
x forall a b. (a -> b) -> a -> b
$ \String
sessionId -> forall (m :: * -> *). MonadIO m => String -> [String] -> m ()
safeSpawn String
"dbus-send"
[String
"--session"
,String
"--print-reply=literal"
,String
"--dest=org.gnome.SessionManager"
,String
"/org/gnome/SessionManager"
,String
"org.gnome.SessionManager.RegisterClient"
,String
"string:xmonad"
,String
"string:"forall a. [a] -> [a] -> [a]
++String
sessionId]