Skip to content

Add DPMS extension#169

Merged
vasily-v-ryabov merged 2 commits intopython-xlib:masterfrom
thiagokokada:add-dpms-extension
Sep 11, 2020
Merged

Add DPMS extension#169
vasily-v-ryabov merged 2 commits intopython-xlib:masterfrom
thiagokokada:add-dpms-extension

Conversation

@thiagokokada
Copy link
Contributor

@thiagokokada thiagokokada commented Sep 11, 2020

Based on the documentation found here: https://www.x.org/releases/X11R7.7/doc/xextproto/dpms.html

It basically works, however there are some known issues:

  • Any rq.Request call (dpms_enable(), dpms_set_timeouts(), dpms_force_level()) only works if you call another rq.ReplyRequest function (dpms_get_version(), for example) afterwards. I tried to change them to use rq.ReplyRequest, this worked but since they don't return anything they got stucked waiting for a response from X11. Maybe I am missing some call to another function?

  • DPMSInfo doesn't work. I don't have a clue why, but it doesn't seem to be an issue with X11. I receive the following error when trying to call dpms_info():

    $ cat playground.py
    from Xlib import display
    
    d = display.Display()
    print(d.dpms_info())
    
    $ python3 playground.py
    Traceback (most recent call last):
      File "playground.py", line 4, in <module>
        print(d.dpms_info())
      File "Xlib/display.py", line 225, in __getattr__
        return types.MethodType(function, self)
    TypeError: first argument must be callable
    

    So I decided to comment this function for now.

Since I am not familiar with the X11 protocol there may be something wrong, but I did some tests and it seems to work fine.

I only tested on Python 3.8, but I think it should work in Python 2 too since I didn't use anything incompatible.

Based on the documentation found here:
https://www.x.org/releases/X11R7.7/doc/xextproto/dpms.html

It basically works, however there are some known issues:
- Any rq.Request call (dpms_enable(), dpms_set_timeouts(),
  dpms_force_level()) only works if you call another rq.ReplyRequest
  function (dpms_get_version(), for example) afterwards. I tried to
  change them to use rq.ReplyRequest, but since they don't return
  anything they got stucked waiting for a response from X11.
- DPMSInfo doesn't work. I don't have a clue why, I receive the
  following error when trying to call dpms_info():

  ```
  $ cat playground.py
  from Xlib import display

  d = display.Display()
  print(d.dpms_info())

  $ python3 playground.py
  Traceback (most recent call last):
    File "playground.py", line 4, in <module>
      print(d.dpms_info())
    File "Xlib/display.py", line 225, in __getattr__
      return types.MethodType(function, self)
  TypeError: first argument must be callable
  ```

  So I decided to comment this function for now.
@codecov-commenter
Copy link

codecov-commenter commented Sep 11, 2020

Codecov Report

Merging #169 into master will decrease coverage by 0.01%.
The diff coverage is 84.90%.

@@            Coverage Diff             @@
##           master     #169      +/-   ##
==========================================
- Coverage   81.98%   81.97%   -0.02%     
==========================================
  Files          40       42       +2     
  Lines        4746     4854     +108     
==========================================
+ Hits         3891     3979      +88     
- Misses        855      875      +20     

@thiagokokada
Copy link
Contributor Author

thiagokokada commented Sep 11, 2020

Any rq.Request call (dpms_enable(), dpms_set_timeouts(), dpms_force_level()) only works if you call another rq.ReplyRequest function (dpms_get_version(), for example) afterwards. I tried to change them to use rq.ReplyRequest, but since they don't return anything they got stucked waiting for a response from X11.

BTW, I actually had the same behavior using Xlib.c in the past: thiagokokada/python-dpms@72e984a. I only call pyDPMS_GetTimeouts after a call to DPMSSetTimeouts to "refresh" the timeout values.

So maybe this is an actual issue with the X protocol, I don't know 🤔.

@vasily-v-ryabov
Copy link
Collaborator

Hi @thiagokokada the code looks good to me. Good job done! I'd suggest to file the mentioned problems as an issue so we don't miss them in the future. I'm going to merge this PR soon.

@vasily-v-ryabov vasily-v-ryabov merged commit 1427cfa into python-xlib:master Sep 11, 2020
@thiagokokada thiagokokada deleted the add-dpms-extension branch September 11, 2020 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants