Access X11 in a background service

My snap (which is in devmode) works just fine if its not a background service, but if its made a background service I get errors as attached below.

Also tried exporting XAUTHORITY ($HOME/.Xauthority) and DISPLAY (:0) but that’s didn’t help either.

My snap basically exposes the API to move my laptop’s mouse over the network (using an Android app in this case) and uses XLib to actually do that. https://github.com/om26er/screen-brightness-server/blob/master/sbs/controller.py#L139

Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425]
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425]     :::::::::::::::::
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425]           :::::          _____                      __
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425]     :::::   :   :::::   / ___/____ ___   ___  ___  / /  __
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425]     :::::::   :::::::  / /__ / __// _ \ (_-< (_-< / _ \/ _
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425]     :::::   :   :::::  \___//_/   \___//___//___//_.__/\_,
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425]           :::::
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425]     :::::::::::::::::   Crossbar v18.12.1
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425]
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425]     Copyright (c) 2013-2018 Crossbar.io Technologies GmbH,
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425]
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425] Initializing <class 'crossbar.personality.Personality'> no
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425] New node key pair generated!
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425] File permissions on node private key fixed
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425] Node key loaded from /root/snap/screen-brightness-server/x
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425] Node configuration loaded from /snap/screen-brightness-ser
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425] Configuration source 2
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425] Entering event reactor ...
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425] Starting standalone node
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425] Node ID x1c6 set from hostname
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425] No extra node router roles
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425] RouterServiceAgent ready (realm_name="crossbar", on_ready=
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425] Registered 21 procedures
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425] Signal handler installed on process 15425 thread 140421108
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425] Using default node shutdown triggers ['shutdown_on_worker_
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425] Booting node
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425] Booting node from local configuration ..
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425] Will start 1 worker ..
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425] Order node to start Router worker001
Dec 27 23:06:54 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:54+0500 [Controller  15425] Starting router worker worker001
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] Starting worker "worker001" for node "x1c6" with personali
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] Running as PID 15473 on CPython-EPollReactor
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] Entering event reactor ...
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] Router worker session for "worker001" joined realm "crossb
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] Registered 38 procedures
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] Router worker session for "worker001" ready
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Controller  15425] Ok, node has started Router worker001
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Controller  15425] Configuring Router worker001 ..
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Controller  15425] Order Router worker001 to start Realm realm001
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] Starting router realm realm001
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] RouterServiceAgent ready (realm_name="realm1", on_ready=<D
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] Realm "realm001" (name="realm1") started
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Controller  15425] Ok, Router worker001 has started Realm realm001
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Controller  15425] Order Realm realm001 to start Role role001
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] Starting role "role001" on realm "realm001"
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] role role001 on realm realm001 started
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Controller  15425] Ok, Realm realm001 has started Role role001
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] started component: sbs.component.BrightnessServerSession i
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] session joined: SessionDetails(realm=<realm1>, session=788
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Controller  15425] Router worker001: component 'component001' started
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] Component instantiation failed
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: Traceback (most recent call last):
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/autobahn/wamp/websocket.py", line
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     self._session.onMessage(msg)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/autobahn/wamp/protocol.py", line 
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     on_reply = txaio.as_future(endpoint.fn, *invoke_args, **invoke_kwargs)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/txaio/tx.py", line 429, in as_fut
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     return maybeDeferred(fun, *args, **kwargs)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/twisted/internet/defer.py", line 
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     result = f(*args, **kw)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: --- <exception caught here> ---
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/crossbar/worker/router.py", line 
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     session = create_component(component_config)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/sbs/component.py", line 94, in __
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     self.mouse = Mouse()
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/sbs/controller.py", line 110, in 
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     self.display = display.Display()
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/Xlib/display.py", line 89, in __i
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     self.display = _BaseDisplay(display)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/Xlib/display.py", line 71, in __i
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     protocol_display.Display.__init__(self, *args, **keys)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/Xlib/protocol/display.py", line 8
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     name, protocol, host, displayno, screenno = connect.get_display(display)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/Xlib/support/connect.py", line 73
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     return mod.get_display(display)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/Xlib/support/unix_connect.py", li
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     raise error.DisplayNameError(display)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: Xlib.error.DisplayNameError: Bad display name ""
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] DisplayNameError: Bad display name "": Traceback (most rec
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/autobahn/twisted/websocket.py", l
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     self.onMessage(payload, isBinary)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/autobahn/wamp/websocket.py", line
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     self._session.onMessage(msg)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/autobahn/wamp/protocol.py", line 
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     on_reply = txaio.as_future(endpoint.fn, *invoke_args, **invoke_kwargs)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/txaio/tx.py", line 429, in as_fut
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     return maybeDeferred(fun, *args, **kwargs)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: --- <exception caught here> ---
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/twisted/internet/defer.py", line 
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     result = f(*args, **kw)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/crossbar/worker/router.py", line 
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     session = create_component(component_config)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/sbs/component.py", line 94, in __
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     self.mouse = Mouse()
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/sbs/controller.py", line 110, in 
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     self.display = display.Display()
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/Xlib/display.py", line 89, in __i
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     self.display = _BaseDisplay(display)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/Xlib/display.py", line 71, in __i
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     protocol_display.Display.__init__(self, *args, **keys)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/Xlib/protocol/display.py", line 8
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     name, protocol, host, displayno, screenno = connect.get_display(display)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/Xlib/support/connect.py", line 73
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     return mod.get_display(display)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/Xlib/support/unix_connect.py", li
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     raise error.DisplayNameError(display)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: Xlib.error.DisplayNameError: Bad display name ""
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Controller  15425] Could not start node: Traceback (most recent call last):
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: --- <exception caught here> ---
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/crossbar/node/node.py", line 361,
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     yield self.personality.Node.boot(self)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/crossbar/node/node.py", line 454,
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     yield config_fn(worker_logname, worker_id, worker)
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:   File "/snap/screen-brightness-server/x1/lib/python3.5/site-packages/crossbar/node/node.py", line 562,
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]:     yield self._controller.call(u'crossbar.worker.{}.start_router_component'.format(worker_id), compone
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: autobahn.wamp.exception.ApplicationError: ApplicationError(error=<wamp.error.runtime_error>, args=[''],
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Controller  15425] sending TERM to subprocess 15473
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Controller  15425] waiting for 15473 to exit...
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] Native worker received SIGTERM - shutting down ..
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] Shutdown of worker requested!
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] session left: CloseDetails(reason=<wamp.close.normal>, mes
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] stopped component: sbs.component.BrightnessServerSession i
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] component 'component001' disconnected
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Router      15473] Connection to node controller closed cleanly
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Controller  15425] Native worker connection closed cleanly.
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Controller  15425] Node worker worker001 ended successfully
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Controller  15425] Checking for node shutdown: worker_exit_success=True, shut
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Controller  15425] Node worker ended, and trigger 'shutdown_on_worker_exit' i
Dec 27 23:06:56 X1C6 screen-brightness-server.server[15425]: 2018-12-27T23:06:56+0500 [Controller  15425] Node shutdown requested (restart=False, mode=None, reactor
Dec 27 23:06:57 X1C6 systemd[1]: snap.screen-brightness-server.server.service: Main process exited, code=exited, status=1/FAILURE
Dec 27 23:06:57 X1C6 systemd[1]: snap.screen-brightness-server.server.service: Failed with result 'exit-code'.
component(component_config)
brightness-server/x1/lib/python3.5/site-packages/sbs/component.py", line 94, in __init__
e()
brightness-server/x1/lib/python3.5/site-packages/sbs/controller.py", line 110, in __init__
splay.Display()
brightness-server/x1/lib/python3.5/site-packages/Xlib/display.py", line 89, in __init__
aseDisplay(display)
brightness-server/x1/lib/python3.5/site-packages/Xlib/display.py", line 71, in __init__
Display.__init__(self, *args, **keys)
brightness-server/x1/lib/python3.5/site-packages/Xlib/protocol/display.py", line 85, in __init__
ost, displayno, screenno = connect.get_display(display)
brightness-server/x1/lib/python3.5/site-packages/Xlib/support/connect.py", line 73, in get_display
splay(display)
brightness-server/x1/lib/python3.5/site-packages/Xlib/support/unix_connect.py", line 61, in get_display
ayNameError(display)
eError: Bad display name ""
500 [Controller  15425] Could not start node: Traceback (most recent call last):
 here> ---
brightness-server/x1/lib/python3.5/site-packages/crossbar/node/node.py", line 361, in start
ality.Node.boot(self)
brightness-server/x1/lib/python3.5/site-packages/crossbar/node/node.py", line 454, in boot_from_config
orker_logname, worker_id, worker)
brightness-server/x1/lib/python3.5/site-packages/crossbar/node/node.py", line 562, in _configure_native_worker_router
oller.call(u'crossbar.worker.{}.start_router_component'.format(worker_id), component_id, component, options=CallOptions())
on.ApplicationError: ApplicationError(error=<wamp.error.runtime_error>, args=[''], kwargs={}, enc_algo=None)
500 [Controller  15425] sending TERM to subprocess 15473
500 [Controller  15425] waiting for 15473 to exit...
500 [Router      15473] Native worker received SIGTERM - shutting down ..
500 [Router      15473] Shutdown of worker requested!
500 [Router      15473] session left: CloseDetails(reason=<wamp.close.normal>, message='None')
500 [Router      15473] stopped component: sbs.component.BrightnessServerSession id=788993782427384
500 [Router      15473] component 'component001' disconnected
500 [Router      15473] Connection to node controller closed cleanly
500 [Controller  15425] Native worker connection closed cleanly.
500 [Controller  15425] Node worker worker001 ended successfully
500 [Controller  15425] Checking for node shutdown: worker_exit_success=True, shutdown_requested=False, node_shutdown_triggers=['shutdown_on_worker_exit']
500 [Controller  15425] Node worker ended, and trigger 'shutdown_on_worker_exit' is active: will shutdown node ..
500 [Controller  15425] Node shutdown requested (restart=False, mode=None, reactor.running=True) ..

Just to be super clear, I did create a symlink of $HOME/.Xauthority to /root/.Xauthority as $HOME is /root for the background service.

did you explicitly set it to /root ? else it will be pointing to $SNAP_USER_DATA by default IIRC …

1 Like

yep, that worked, thanks :slight_smile:

So how do I not change anything in the host (no symlink, whatsoever) and still have access to X11 in a background service ?

1 Like