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-25 18:55:52 -04:00
|
|
|
import Control.Concurrent
|
|
|
|
import Control.Monad
|
2020-03-20 20:10:15 -04:00
|
|
|
|
2020-03-25 18:55:52 -04:00
|
|
|
import DBus.Screensaver
|
2020-03-15 15:10:25 -04:00
|
|
|
|
2020-03-25 18:55:52 -04:00
|
|
|
import Xmobar
|
|
|
|
import Xmobar.Common
|
2020-03-15 15:10:25 -04:00
|
|
|
|
2020-03-25 18:55:52 -04:00
|
|
|
newtype 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
|
2020-03-21 14:46:49 -04:00
|
|
|
forever (threadDelay 5000000)
|
2020-03-20 20:10:15 -04:00
|
|
|
where
|
|
|
|
fmtState = \case
|
2020-03-25 18:55:52 -04:00
|
|
|
Just s -> wrapColor (if s then colorOn else colorOff) text
|
2020-03-20 20:10:15 -04:00
|
|
|
Nothing -> "N/A"
|
2020-03-20 15:41:13 -04:00
|
|
|
|