ADD xmobar screensaver plugin
This commit is contained in:
parent
c0d97e83e4
commit
f3ef72bbe3
|
@ -1,3 +1,5 @@
|
|||
import Xmobar.Screensaver
|
||||
|
||||
import Xmobar
|
||||
import XMonad (getXMonadDir)
|
||||
|
||||
|
@ -23,7 +25,8 @@ myTemplate :: String
|
|||
myTemplate = concat
|
||||
[ "%UnsafeStdinReader%"
|
||||
, " }{ "
|
||||
, "%wlp0s20f3wi%"
|
||||
, "%screensaver%"
|
||||
, sep, "%wlp0s20f3wi%"
|
||||
, sep, "%alsa:default:Master%"
|
||||
, sep, "%battery%"
|
||||
, sep, "%bright%"
|
||||
|
@ -104,6 +107,8 @@ config confDir = defaultConfig {
|
|||
|
||||
, Run $ Date "%Y-%m-%d %H:%M" "date" 10
|
||||
|
||||
, Run $ Screensaver ("<fn=1>\xf108</fn>", fgColor0, fgColor1) 10
|
||||
|
||||
, Run UnsafeStdinReader
|
||||
]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
module Xmobar.Screensaver where
|
||||
|
||||
-- import Control.Monad
|
||||
|
||||
import Graphics.X11.Xlib.Display
|
||||
import Graphics.X11.XScreenSaver
|
||||
|
||||
import Xmobar
|
||||
|
||||
data Screensaver = Screensaver (String, String, String) Int
|
||||
deriving (Read, Show)
|
||||
|
||||
instance Exec Screensaver where
|
||||
alias (Screensaver _ _) = "screensaver"
|
||||
run (Screensaver opts _) = run' opts
|
||||
rate (Screensaver _ r) = r
|
||||
|
||||
-- TODO make this respond to events rather than polling
|
||||
run' :: (String, String, String) -> IO String
|
||||
run' (text, colorOn, colorOff) = do
|
||||
dpy <- openDisplay ""
|
||||
xssi <- xScreenSaverQueryInfo dpy
|
||||
print "hi"
|
||||
closeDisplay dpy
|
||||
return $ case xssi of
|
||||
Just x -> wrapColor text
|
||||
$ case xssi_state x of
|
||||
ScreenSaverDisabled -> colorOff
|
||||
_ -> colorOn
|
||||
Nothing -> "N/A"
|
||||
where
|
||||
-- TODO not DRY
|
||||
wrapColor s c = "<fc=" ++ c ++ ">" ++ s ++ "</fc>"
|
||||
|
|
@ -7,8 +7,10 @@ library
|
|||
hs-source-dirs: lib
|
||||
exposed-modules: SendXMsg
|
||||
, ACPI
|
||||
, Xmobar.Screensaver
|
||||
build-depends: base
|
||||
, X11 >= 1.9.1
|
||||
, xmobar
|
||||
ghc-options: -Wall -Werror -fno-warn-missing-signatures
|
||||
default-language: Haskell2010
|
||||
|
||||
|
@ -31,6 +33,7 @@ executable xmobar
|
|||
build-depends: base
|
||||
, xmonad >= 0.13
|
||||
, xmobar
|
||||
, my-xmonad
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall -Werror -fno-warn-missing-signatures -threaded
|
||||
|
||||
|
|
Loading…
Reference in New Issue