mirror of
https://github.com/moraroy/NonSteamLaunchers-On-Steam-Deck.git
synced 2024-12-21 07:11:52 +01:00
dbus
This commit is contained in:
parent
21802c8036
commit
1b445e7514
@ -13,6 +13,47 @@ from urllib.request import urlopen
|
|||||||
from urllib.request import urlretrieve
|
from urllib.request import urlretrieve
|
||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
import dbus
|
||||||
|
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)
|
||||||
|
logger.addHandler(handler)
|
||||||
|
|
||||||
|
# Get the session bus
|
||||||
|
bus = dbus.SessionBus()
|
||||||
|
|
||||||
|
# Get the NetworkManager service object
|
||||||
|
try:
|
||||||
|
nm = bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager')
|
||||||
|
logger.info('Got the NetworkManager service object')
|
||||||
|
except dbus.DBusException as e:
|
||||||
|
logger.error('Failed to get the NetworkManager service object: %s', e)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
# Get the device interface
|
||||||
|
try:
|
||||||
|
device = dbus.Interface(nm, 'org.freedesktop.NetworkManager.Device')
|
||||||
|
logger.info('Got the device interface')
|
||||||
|
except dbus.DBusException as e:
|
||||||
|
logger.error('Failed to get the device interface: %s', e)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
# Get the properties of the eth0 device
|
||||||
|
try:
|
||||||
|
props = device.GetProperties('eth0')
|
||||||
|
logger.info('Got the properties of the eth0 device')
|
||||||
|
except dbus.DBusException as e:
|
||||||
|
logger.error('Failed to get the properties of the eth0 device: %s', e)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
# Print the properties
|
||||||
|
print(props)
|
||||||
|
|
||||||
|
|
||||||
# Path to the env_vars file
|
# Path to the env_vars file
|
||||||
env_vars_path = f"{os.environ['HOME']}/.config/systemd/user/env_vars"
|
env_vars_path = f"{os.environ['HOME']}/.config/systemd/user/env_vars"
|
||||||
|
Loading…
Reference in New Issue
Block a user