mirror of
https://github.com/moraroy/NonSteamLaunchers-On-Steam-Deck.git
synced 2024-12-21 07:11:52 +01:00
dbus check
This commit is contained in:
parent
1b445e7514
commit
b7c0100f25
@ -19,14 +19,20 @@ import logging
|
||||
# Create and configure a logger object
|
||||
logger = logging.getLogger('mylogger')
|
||||
logger.setLevel(logging.DEBUG)
|
||||
handler = logging.StreamHandler()
|
||||
formatter = logging.Formatter('%(levelname)s:%(message)s')
|
||||
handler.setFormatter(formatter)
|
||||
handler = logging.StreamHandler(stream=sys.stdout)
|
||||
logger.addHandler(handler)
|
||||
|
||||
# Get the session bus
|
||||
bus = dbus.SessionBus()
|
||||
|
||||
# Check the value of the DBUS_SESSION_BUS_ADDRESS environment variable
|
||||
dbus_address = os.environ.get('DBUS_SESSION_BUS_ADDRESS')
|
||||
if not dbus_address or not dbus_address.startswith('unix:path='):
|
||||
# Set the value of the DBUS_SESSION_BUS_ADDRESS environment variable
|
||||
dbus_address = f'unix:path=/run/user/{os.getuid()}/bus'
|
||||
os.environ['DBUS_SESSION_BUS_ADDRESS'] = dbus_address
|
||||
logger.info(f'Set the DBUS_SESSION_BUS_ADDRESS to {dbus_address}')
|
||||
|
||||
# Get the NetworkManager service object
|
||||
try:
|
||||
nm = bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager')
|
||||
@ -55,6 +61,7 @@ except dbus.DBusException as e:
|
||||
print(props)
|
||||
|
||||
|
||||
|
||||
# Path to the env_vars file
|
||||
env_vars_path = f"{os.environ['HOME']}/.config/systemd/user/env_vars"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user