Introduce DBus-powered x1plusd to manage settings #223
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Continuing in the path of #196, we introduce a handful of infrastructure in this PR, and only a few tiny users :-) The core idea of this is that we introduce @riptidewave93 's
x1plusd
(and the associatedsettings
service), but instead of binding it to DDS, we bind it to DBus usingjeepney
(which @jphannifan found after I spent a night unsuccessfully wrestling with the library dependencies fordasbus
-- thanks!). Thex1plusd
registers a DBus bus namex1plus.x1plusd
that has an object/x1plus/settings
, which, in turn, exposes the following methods:x1plus.settings.GetSettings(json: string)
returns a JSON dictionary of all the current known X1Plus settings, loaded from the SD card's printer-specific X1Plus settings JSON.x1plus.settings.PutSettings(json: string)
updates the X1Plus settings with keys from the passed JSON dictionary.When a setting changes, it emits a signal:
x1plus.settings.SettingsChanged(json: string)
, with a dictionary that has set in it only the keys that have changed.We also introduce a QML API,
X1Plus.Settings.get
/X1Plus.Settings.put
.X1Plus.Settings.get
works like a QML binding, and if used in a QML binding context, will dynamically retrigger the binding if the setting changes either internally tobbl_screen
or externally, as part of another system user's DBus operation.Finally, we wire the lock screen's
locktype
andpasscode
variables toX1Plus.Settings
, to store them in thesettings.json
, and we migrate these settings on boot if they exist. To show the live QML binding behavior, we introduce ax1plus-test-settings.py
that commands the X1Plus daemon to change some settings. Test it by loading the lock screen configuration dialog, and then ssh'ing in and running something like:$ /opt/x1plus-test-settings.py passcode=1337
or:
$ /opt/x1plus-test-settings.py locktype=1
You should see the settings change in real time on the display.