enum DesktopSettings
Swift
enum DesktopSettings
The desktop's own preferences, for the app that exists to change them.
Everything here is a round trip to the compositor, because everything here
is the compositor's: which screens are on, what the keyboard is, how round
the windows are. A client cannot see any of it from inside its own window,
and the config file is not the answer either — a settings app that edited
lava.conf and sent SIGHUP would be typing on the user's behalf, with no
idea what the running session actually has.
These throw, unlike the rest of LavaClient. A window that would not
maximize is a bad frame worth logging and forgetting; a setting that did
not take is something the user asked for and has to be told about. In
particular a SettingsWriteFailed means the change is on screen and will
not be after a restart, which is a sentence a settings app should be able
to say.
Synchronous on purpose. Every call lands on the compositor's event loop and answers in microseconds, and a settings panel that awaited them would need an async story for every switch and slider in it to no visible benefit.
Sources/LavaClient/DesktopSettings.swift:25
Properties
static var isAvailable: Bool { get }
Whether there is a compositor to ask. False in a windowed app, where none of this exists and the panel should say so rather than show controls that do nothing.
Sources/LavaClient/DesktopSettings.swift:29
Methods
static func appearance() throws -> Appearance
The desktop's corner radius and the shadow it puts under a window.
Sources/LavaClient/DesktopSettings.swift:34
static func arrangement() throws -> String
"extend" or "mirror".
Sources/LavaClient/DesktopSettings.swift:178
static func keyBindings() throws -> [KeyBinding]
Every shortcut the compositor takes before a client sees the key.
Read-only, and that is the honest shape today: the bindings are compiled in. Listing them is still worth doing — a desktop whose shortcuts can only be found by reading its source has no shortcuts, as far as most people are concerned.
Sources/LavaClient/DesktopSettings.swift:142
static func keyboard() throws -> KeyboardSettings
Not documented.
Sources/LavaClient/DesktopSettings.swift:87
static func keyboardLayouts() throws -> [KeyboardLayout]
Every layout and variant this machine's xkb offers.
Flat: an entry whose variant is empty is a layout, and the rest are
its variants. layoutsByCode() is the grouped form, which is what a
picker actually wants.
Slow enough to be worth caching — it is a parse of the whole xkb rules file, a few thousand entries — and constant for the life of the session, so it is cached here rather than in every caller.
Sources/LavaClient/DesktopSettings.swift:109
static func layoutsByCode() throws -> [(code: String, name: String, variants: [KeyboardLayout])]
The same list, grouped: each base layout with its variants after it, in the order xkb reports them.
Sources/LavaClient/DesktopSettings.swift:118
static func outputModes(_ name: String) throws -> [OutputMode]
Every mode a screen can run at, biggest first then fastest.
Sources/LavaClient/DesktopSettings.swift:153
static func outputs() throws -> [OutputInfo]
Not documented.
Sources/LavaClient/DesktopSettings.swift:148
static func request(from output: OutputInfo) -> OutputRequest
A request pre-filled from what a screen is doing now, so a caller changing one field does not have to restate the other six.
Sources/LavaClient/DesktopSettings.swift:189
static func setAppearance(_ appearance: Appearance) throws
Sets both, immediately and for the next session.
Immediately is the point: these are numbers the compositor reads per frame, so every window on screen takes the new ones before this call returns. That is what makes a slider here honest — the preview is the result.
Values out of range are clamped by the compositor rather than refused;
read appearance() back to see what was taken.
Sources/LavaClient/DesktopSettings.swift:47
static func setArrangement(_ mode: String) throws
Extend or mirror, immediately and for the next session.
Sources/LavaClient/DesktopSettings.swift:183
static func setKeyboard(_ settings: KeyboardSettings) throws
Changes the keyboard, immediately and for the next session.
wlroots hands the new keymap to every connected client as a side effect, so this reaches applications that are already running — which is the difference between this and editing the config file.
Sources/LavaClient/DesktopSettings.swift:96
static func setOutput(_ request: OutputRequest) throws
Reconfigures a screen, immediately and for the next session.
The whole state rather than one field, because applying it is one commit: a screen asked to change mode and then position would be re-laid-out twice, through an arrangement nobody asked for.
A mode the display refuses does not cost the session — the compositor
falls back to the preferred one rather than leaving a screen showing
nothing. Read outputs() back to find out whether what you asked for
is what you got.
Sources/LavaClient/DesktopSettings.swift:167
static func setPrimaryOutput(_ name: String) throws
Makes this screen the primary: the panel moves here, and new windows open here. Empty means no preference.
Sources/LavaClient/DesktopSettings.swift:173
static func setSystemTheme(_ theme: SystemTheme) throws
Pushes the name; every subscribed Lava window retints.
Sources/LavaClient/DesktopSettings.swift:57
static func setWallpaper(_ wallpaper: Wallpaper) throws
Sets the desktop background, immediately and for the next session.
The only setter here that can refuse. A picture that will not decode
throws WallpaperUnreadable and changes nothing — the old background
is still up and still saved — which is a different report from
SettingsWriteFailed, where the change is on screen and will not
survive a restart. A panel that collapses the two will tell the user
the wrong thing in one of the two cases.
Sources/LavaClient/DesktopSettings.swift:81
static func systemTheme() throws -> SystemTheme
Sources/LavaClient/DesktopSettings.swift:52
static func wallpaper() throws -> Wallpaper
What the desktop is painted with, behind every window.
Reports what is on screen. After a picture the compositor could not read, that is the background which survived — not the one that was asked for — so re-reading this after a failure is how a panel gets its controls back in step with the desktop.
Sources/LavaClient/DesktopSettings.swift:69