[xmonad] 'resetScreenSaver' from 'Graphics.X11.Xlib.Misc'
YCH
dontdieych at gmail.com
Sun Feb 8 17:29:05 UTC 2015
I've got reply from libx11 bug tracker.
https://bugs.freedesktop.org/show_bug.cgi?id=89028#c1
Do `flush` from `Graphics.X11.Xlib.Event` after `resetScreenSaver` is
the solution. `getScreenSaver` calls XFlush() internally.
On Sun, Feb 8, 2015 at 10:10 PM, YCH <dontdieych at gmail.com> wrote:
> On Wed, Jan 21, 2015 at 3:22 PM, Dontdie YCH <dontdieych at gmail.com>
> wrote:
>> Hello,
>>
>> I'm looking for what is proper method to inhibit screensaver(DPMS)
>> without xscreensaver, KDE, GNOME ... .
>>
>> My video player 'bomi'(was cmplayer) try these, in order,
>>
>> ~~~
>> [App] Initialize screensaver functions.
>> [App] Try to connect 'org.gnome.SessionManager'.
>> [App] Failed to connect 'org.gnome.SessionManager'. Fallback to
>> 'org.freedesktop.ScreenSaver'.
>> [App] Failed to connect 'org.freedesktop.ScreenSaver'. Fallback to
>> XResetScreenSaver().
>> [App] Disable screensaver with XResetScreenSaver().
>> ~~~
>>
>> But it does not working. I didn't know how I directly deal with X11
>> lib. Fortunately, I found 'resetScreenSaver' from
>> 'Graphics.X11.Xlib.Misc' that say interface to XResetScreenSaver().
>>
>> resetScreenSaver.hs :
>>
>> ~~~
>> import Graphics.X11.Xlib
>> import Graphics.X11.Xlib.Misc
>> import Control.Concurrent
>> import Control.Monad
>>
>> main = do
>> dpy <- openDisplay ""
>> forever $ do
>> putStrLn "reset"
>> resetScreenSaver dpy
>> threadDelay (5*1000000)
>> ~~~
>>
>>
>> ~~~
>> $ xset s 10
>> $ runhaskell resetScreenSaver.hs
>> ~~~
>>
>> Unfortunately, It does not working. `activateScreenSaver` and
>> `forceScreenSaver` also does not working.
>>
>> But `xset s reset` is working as intended and also there is
>> `xdg-screensaver [ suspend | resume | reset ]` command from
>> 'xdg-utils' package (Arch). It looks like abstraction layer for xset,
>> xscreensaver, KDE, GNOME ... .
>>
>> So I'm curious about whether this is bug of xorg or I misunderstand
>> something. And what is right way to do this if I don't want any
>> screensaver daemon? `xset s` or `xdg-screensaver`?
>>
>> Thanks.
>
> I've experiment couple of things and then find relation between
> `getScreenSaver` and `resetScreenSaver`. resetScreenSaver only works
> if I call getScreenSaver immediately before.
>
> Any know about this?
>
> Working as intended,
>
> ~~~
> $ xset s 5; runhaskell withgetScreenSaver.hs
> $ cat withgetScreenSaver.hs
> import Graphics.X11.Xlib
> import Graphics.X11.Xlib.Misc
> import Control.Concurrent
> import Control.Monad
>
> main = do
> dpy <- openDisplay ""
> forever $ do
> getScreenSaver dpy
> resetScreenSaver dpy
> threadDelay (3*1000000)
> ~~~
>
> Does not working as intended,
>
> ~~~
> $ xset s 5; runhaskell onlyresetScreenSaver.hs
> $ cat onlyresetScreenSaver.hs
> import Graphics.X11.Xlib
> import Graphics.X11.Xlib.Misc
> import Control.Concurrent
> import Control.Monad
>
> main = do
> dpy <- openDisplay ""
> forever $ do
> resetScreenSaver dpy
> threadDelay (3*1000000)
> ~~~
>
> If I call `getScreenSaver` outside loop, it also does not working.
>
> ~~~
> import Graphics.X11.Xlib
> import Graphics.X11.Xlib.Misc
> import Control.Concurrent
> import Control.Monad
>
> main = do
> dpy <- openDisplay ""
> getScreenSaver dpy
> forever $ do
> resetScreenSaver dpy
> threadDelay (3*1000000)
> ~~~
>
> Thanks
More information about the xmonad
mailing list