Skip to content

cs_thunderbolt.py: re-work module initialization, code cleanup#13691

Open
timfeierabend wants to merge 4 commits intolinuxmint:masterfrom
timfeierabend:rework-tbolt-settings
Open

cs_thunderbolt.py: re-work module initialization, code cleanup#13691
timfeierabend wants to merge 4 commits intolinuxmint:masterfrom
timfeierabend:rework-tbolt-settings

Conversation

@timfeierabend
Copy link
Copy Markdown
Contributor

Re-worked settings module initialization to simplify the startup checks. The main goal is to use D-Bus for all checks. The current solution performs 3 checks:

  1. Checks for whether bolt is installed by checking if boltctl exists on the file system.
  2. Checks for whether the system has thunderbolt by querying sysfs.
  3. Checks if the bolt daemon is alive.

This new implementation performs 2 checks:

  1. Checks if org.freedesktop.bolt is in the D-Bus activitable list. If it is installed and activatable, it will appear in this list. This replaces check number 1 above. Since this settings module uses D-Bus for all functionality, this is a more accurate check.
  2. If bolt is available, we initialize the Manager, and get the list of domains. Per the documentation, there will be 1 domain/device pair with the same uuid per thunderbolt controller in the system. This replaces check number 2 above. boltd knows how to examine sysfs, no need to re-invent the wheel, lets just ask it if it sees thunderbolt support on the system.

The check for number 3 is removed because if org.freedesktop.bolt isn't running, it will automatically start when we start interacting with it. Systems that do have thunderbolt, but don't have any devices connected via thunderbolt, won't automatically start the service until a device connects.

The wrapper classes around the DBus proxy objects were re-factored to make use of get_cached_property() feature of Gio.DBusProxy objects. No need to re-invent the wheel and manage a property cache when the proxy already does this. The "Proxy" part of their names were removed.

re-worked settings module init to simplify the startup checks.
the main goal is to use d-bus for all checks. the current solution
performs 3 checks:

1)	Checks for whether bolt is installed by checking if `boltctl`
	exists on the file system.
2)	Checks for whether the system has thunderbolt by querying sysfs.
3)	Checks if the bolt daemon is alive.

This new implementation performs 2 checks:

1)	Checks if `org.freedesktop.bolt` is in the D-Bus activitable list.
	if bolt is installed, it will appear in this list.
	This replaces check number 1 above. Since the whole settings module
	runs off d-bus, this is a more accurate check.
2)	If bolt is available, we initialize the Manager proxy, and get the
	list of domains. Per the documentation, there will be 1
	domain/device pair with the same uuid per thunderbolt controller
	in the system.
	This replaces check number 2 above. `boltd` knows how to examine
	sysfs, no need to re-invent the wheel, lets just ask it if it sees
	thunderbolt support on the system.

The check for number 3 is removed because if
`org.freedesktop.bolt` isn't running, it will automatically
start when we start interacting with it. systems that do have
thunderbolt, but don't have any devices connected via thunderbolt,
won't automatically start the service until a device connects.
Use the `get_cached_property()` feature of DBusProxy object
instead of re-inventing the wheel with the props object and
setattr.

Renamed DBusProxy to DBusObject since it is a wrapper class
around a Gio.DBusProxy.

Renamed BoltManagerProxy to BoltManager and BoltDeviceProxy
to BoltDevice since they are convienence wrapper classes.

Removed DBusProps empty class.

Added DBusProperty descriptor class. This class is designed for
use with the DBusObject class for easy access to properties.
It is used to expose the various properties needed from the
BoltDevice class.

Changed host device check to call
`org.freedesktop.DBus.Properties.Get()` method to get the
device type, prevent un-necessary creation of a BoltDevice
object.

Renamed all properties and methods in the BoltManager and
BoltDevice classes to match the DBus naming convention.
os module no longer needed due to refactoring of module
initialization
@timfeierabend timfeierabend marked this pull request as ready for review April 4, 2026 19:26
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

Successfully merging this pull request may close these issues.

1 participant