2022-12-26 14:45:49 -05:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
|
2020-04-01 22:06:00 -04:00
|
|
|
--------------------------------------------------------------------------------
|
2022-12-30 14:58:23 -05:00
|
|
|
-- Screensaver plugin
|
2020-04-01 22:06:00 -04:00
|
|
|
--
|
|
|
|
-- Use the custom DBus interface exported by the XMonad process so I can react
|
|
|
|
-- to signals spawned by commands
|
|
|
|
|
2021-06-21 23:41:57 -04:00
|
|
|
module Xmobar.Plugins.Screensaver
|
2022-12-30 14:58:23 -05:00
|
|
|
( Screensaver (..)
|
2021-06-21 23:41:57 -04:00
|
|
|
, ssAlias
|
2022-12-30 14:58:23 -05:00
|
|
|
)
|
|
|
|
where
|
2020-03-15 15:10:25 -04:00
|
|
|
|
2023-01-03 22:18:55 -05:00
|
|
|
import Data.Internal.DBus
|
2022-12-30 14:58:23 -05:00
|
|
|
import qualified RIO.Text as T
|
|
|
|
import XMonad.Internal.DBus.Screensaver
|
|
|
|
import Xmobar
|
|
|
|
import Xmobar.Plugins.Common
|
2020-03-15 15:10:25 -04:00
|
|
|
|
2022-12-26 14:45:49 -05:00
|
|
|
newtype Screensaver = Screensaver (T.Text, Colors) deriving (Read, Show)
|
2020-03-15 15:10:25 -04:00
|
|
|
|
2022-12-26 14:45:49 -05:00
|
|
|
ssAlias :: T.Text
|
2021-06-21 23:41:57 -04:00
|
|
|
ssAlias = "screensaver"
|
|
|
|
|
2020-03-15 15:10:25 -04:00
|
|
|
instance Exec Screensaver where
|
2022-12-26 14:45:49 -05:00
|
|
|
alias (Screensaver _) = T.unpack ssAlias
|
2023-01-01 22:29:29 -05:00
|
|
|
start (Screensaver (text, colors)) cb =
|
2023-01-03 23:33:08 -05:00
|
|
|
withDBusClientConnection cb (Just "screensaver.log") $ \cl -> withDIO cl $ do
|
2023-01-03 22:18:55 -05:00
|
|
|
matchSignal dpy
|
|
|
|
dpy =<< callQuery
|
2021-11-24 01:22:03 -05:00
|
|
|
where
|
2023-01-01 22:29:29 -05:00
|
|
|
dpy = displayMaybe cb $ return . (\s -> colorText colors s text)
|