BoboTiG / python-mss

An ultra fast cross-platform multiple screenshots module in pure Python using ctypes.
https://pypi.org/project/mss/
MIT License
1.04k stars 94 forks source link

$DISPLAY not set. #263

Closed rominail closed 1 year ago

rominail commented 1 year ago

General information:

For GNU/Linux users:

Through the usage of pombo, when using it from CLI there is no problem, when executed from the cronjob I get the message "$DISPLAY not set." I don't know if I should change any conf for the crontask or if it's something with the library as it use to work (but I don't know when it stopped)

BoboTiG commented 1 year ago

When you execute anything from a cronjob, you have to define DISPLAY yourself.

  1. Get the current value in a terminal:
    $ echo $DISPLAY
    :0
  2. In your cronjob:
    * * * * * DISPLAY=:0 COMMAND

    Adapt the frequency, what is important is to prefix the command with DISPLAY=:0.

rominail commented 1 year ago

Thank you!

rominail commented 1 year ago

For information for other person who might experience the same issue (and might be nice to put it in the linux doc) I also added XAUTHORITY=/run/user/1000/gdm/Xauthority in my root crontab

WanMMao commented 1 year ago
image

May I ask if using crontab still results in $DISPLAY not set? Is there something wrong with me?

rominail commented 1 year ago

I don't know if there is something wrong with your code what I did is :

# m h  dom mon dow   command
DISPLAY=:0
XAUTHORITY=/run/user/1000/gdm/Xauthority
*/15 * * * * /usr/local/bin/pombo 2>/dev/null

Also, if your issue is not related to the repo, open an issue on a dedicated website (eg: stackexchange)