2020-03-20 20:10:15 -04:00
|
|
|
{-# LANGUAGE LambdaCase #-}
|
|
|
|
|
2020-03-20 15:41:13 -04:00
|
|
|
module Xmobar.Plugins.Screensaver where
|
2020-03-15 15:10:25 -04:00
|
|
|
|
2020-03-20 20:10:15 -04:00
|
|
|
import Control.Concurrent
|
|
|
|
import Control.Monad
|
|
|
|
|
|
|
|
import DBus.Screensaver
|
2020-03-15 15:10:25 -04:00
|
|
|
|
|
|
|
import Xmobar
|
|
|
|
|
2020-03-20 20:10:15 -04:00
|
|
|
data Screensaver = Screensaver (String, String, String)
|
2020-03-20 15:41:13 -04:00
|
|
|
deriving (Read, Show)
|
2020-03-15 15:10:25 -04:00
|
|
|
|
|
|
|
instance Exec Screensaver where
|
2020-03-20 20:10:15 -04:00
|
|
|
alias (Screensaver _) = "screensaver"
|
|
|
|
start (Screensaver (text, colorOn, colorOff)) cb = do
|
|
|
|
_ <- matchSignal $ cb . fmtState
|
|
|
|
cb . fmtState =<< callQuery
|
|
|
|
forever (threadDelay 5000)
|
|
|
|
where
|
|
|
|
fmtState = \case
|
|
|
|
Just s -> wrapColor text $ if s then colorOn else colorOff
|
|
|
|
Nothing -> "N/A"
|
|
|
|
wrapColor s c = "<fc=" ++ c ++ ">" ++ s ++ "</fc>"
|
2020-03-20 15:41:13 -04:00
|
|
|
|