2020-03-20 00:51:36 -04:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
|
2020-03-28 14:44:50 -04:00
|
|
|
module DBus.Common
|
|
|
|
( Client
|
|
|
|
, startXMonadService
|
|
|
|
, stopXMonadService)
|
|
|
|
where
|
2020-03-20 00:51:36 -04:00
|
|
|
|
2020-03-28 14:44:50 -04:00
|
|
|
import DBus.IntelBacklight
|
|
|
|
import DBus.Screensaver
|
2020-03-20 00:51:36 -04:00
|
|
|
|
2020-03-28 14:44:50 -04:00
|
|
|
import DBus.Client
|
2020-03-20 00:51:36 -04:00
|
|
|
|
|
|
|
startXMonadService :: IO Client
|
|
|
|
startXMonadService = do
|
|
|
|
client <- connectSession
|
|
|
|
requestResult <- requestName client "org.xmonad" []
|
|
|
|
-- TODO if the client is not released on shutdown the owner will be
|
|
|
|
-- different
|
|
|
|
if requestResult /= NamePrimaryOwner then
|
|
|
|
putStrLn "Another service owns \"org.xmonad\""
|
|
|
|
else do
|
|
|
|
putStrLn "Started xmonad dbus client"
|
2020-03-20 15:41:13 -04:00
|
|
|
exportIntelBacklight client
|
2020-03-20 20:10:15 -04:00
|
|
|
exportScreensaver client
|
2020-03-20 00:51:36 -04:00
|
|
|
return client
|
|
|
|
|
|
|
|
stopXMonadService :: Client -> IO ()
|
|
|
|
stopXMonadService client = do
|
2020-03-20 15:43:32 -04:00
|
|
|
_ <- releaseName client "org.xmonad"
|
2020-03-20 00:51:36 -04:00
|
|
|
disconnect client
|
|
|
|
return ()
|
|
|
|
|