Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use existing display / set display number? #97

Open
plonknimbuzz opened this issue Nov 30, 2024 · 2 comments
Open

How to use existing display / set display number? #97

plonknimbuzz opened this issue Nov 30, 2024 · 2 comments

Comments

@plonknimbuzz
Copy link

Hi, there

i have this service:

#/etc/systemd/system/xvfb.service

[Unit]
Description=X virtual framebuffer

[Service]
Type=simple
User=root

ExecStart=/usr/bin/Xvfb :99 -ac

[Install]
WantedBy=multi-user.target
ps -ef|grep Xvfb
root     15802     1  0 Jul28 ?        00:00:00 /usr/bin/Xvfb :99 -ac

as u can see that i used :99 as display number
but i failed to set it using this script

from pyvirtualdisplay import Display
import os
print(os.environ.get("DISPLAY"))
os.environ["DISPLAY"] = ":99"
print(os.environ.get("DISPLAY"))
with Display() as disp:
    # display is active
    print(disp.is_alive()) # True
    print(os.environ.get("DISPLAY"))
# display is stopped
print(disp.is_alive())

result

None
:99
True
:0 ==> failed
False

my question is: how to set display number?
because i want to use display that created from outside of this library

@plonknimbuzz
Copy link
Author

or, if there is no available method for my case.
at least, how can i find my previous display?

something like this

def run(action):
    disp = Display() #idk how to attach old display
    if(disp.is_alive):
        if(action=='start'):
            print('continue existing display')
            return disp
        else:
            disp.stop()
            print('stop existing display')
            return None
    else:
        if(action=='start'):
            print('create new display')
            return disp #return something that i can use 1 hour later
        else:
            print('display not found. Cannot stop the display')
            return None

@The-Compiler
Copy link

What's the point? The whole idea behind this library is starting and managing an Xvfb process. If you already have one, there's nothing left for it to do?

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

No branches or pull requests

2 participants