ADD xmobar screensaver plugin
This commit is contained in:
parent
c0d97e83e4
commit
f3ef72bbe3
|
@ -1,3 +1,5 @@
|
||||||
|
import Xmobar.Screensaver
|
||||||
|
|
||||||
import Xmobar
|
import Xmobar
|
||||||
import XMonad (getXMonadDir)
|
import XMonad (getXMonadDir)
|
||||||
|
|
||||||
|
@ -23,7 +25,8 @@ myTemplate :: String
|
||||||
myTemplate = concat
|
myTemplate = concat
|
||||||
[ "%UnsafeStdinReader%"
|
[ "%UnsafeStdinReader%"
|
||||||
, " }{ "
|
, " }{ "
|
||||||
, "%wlp0s20f3wi%"
|
, "%screensaver%"
|
||||||
|
, sep, "%wlp0s20f3wi%"
|
||||||
, sep, "%alsa:default:Master%"
|
, sep, "%alsa:default:Master%"
|
||||||
, sep, "%battery%"
|
, sep, "%battery%"
|
||||||
, sep, "%bright%"
|
, sep, "%bright%"
|
||||||
|
@ -104,6 +107,8 @@ config confDir = defaultConfig {
|
||||||
|
|
||||||
, Run $ Date "%Y-%m-%d %H:%M" "date" 10
|
, Run $ Date "%Y-%m-%d %H:%M" "date" 10
|
||||||
|
|
||||||
|
, Run $ Screensaver ("<fn=1>\xf108</fn>", fgColor0, fgColor1) 10
|
||||||
|
|
||||||
, Run UnsafeStdinReader
|
, 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
|
hs-source-dirs: lib
|
||||||
exposed-modules: SendXMsg
|
exposed-modules: SendXMsg
|
||||||
, ACPI
|
, ACPI
|
||||||
|
, Xmobar.Screensaver
|
||||||
build-depends: base
|
build-depends: base
|
||||||
, X11 >= 1.9.1
|
, X11 >= 1.9.1
|
||||||
|
, xmobar
|
||||||
ghc-options: -Wall -Werror -fno-warn-missing-signatures
|
ghc-options: -Wall -Werror -fno-warn-missing-signatures
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
@ -31,6 +33,7 @@ executable xmobar
|
||||||
build-depends: base
|
build-depends: base
|
||||||
, xmonad >= 0.13
|
, xmonad >= 0.13
|
||||||
, xmobar
|
, xmobar
|
||||||
|
, my-xmonad
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
ghc-options: -Wall -Werror -fno-warn-missing-signatures -threaded
|
ghc-options: -Wall -Werror -fno-warn-missing-signatures -threaded
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue