Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions proton/vpn/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,27 @@


async def _vpn_gui_running() -> bool:
bus = await MessageBus(bus_type=BusType.SESSION).connect()

reply = await bus.call(
Message(
destination="org.freedesktop.DBus",
path="/org/freedesktop/DBus",
interface="org.freedesktop.DBus",
member="ListNames",
try:
bus = await MessageBus(bus_type=BusType.SESSION).connect()

reply = await bus.call(
Message(
destination="org.freedesktop.DBus",
path="/org/freedesktop/DBus",
interface="org.freedesktop.DBus",
member="ListNames",
)
)
)

if reply.message_type == MessageType.ERROR:
return False
if reply.message_type == MessageType.ERROR:
return False

session_bus_names = reply.body[0]
return GTK_APP_ID in session_bus_names
session_bus_names = reply.body[0]
return GTK_APP_ID in session_bus_names
except Exception:
# No DBus session available (e.g. headless server).
# If DBus is not running, the GUI can't be running either.
return False


_CLICK_CONTEXT_SETTINGS = {"help_option_names": ['--help', '-h']}
Expand Down