Merge remote-tracking branch 'origin/main' into feat/panama-health

# Conflicts:
#	config/dot/quickshell/modules/settings/ServicesPage.qml
#	config/dot/quickshell/modules/settings/SettingsShell.qml
#	config/dot/quickshell/modules/settings/SettingsSidebar.qml
This commit is contained in:
Gabriel Brown
2026-08-18 11:23:07 -04:00
87 changed files with 4557 additions and 184 deletions
+15 -3
View File
@@ -78,9 +78,21 @@ Singleton {
root.lastError = "";
const scheme = root.dark ? "prefer-dark" : "prefer-light";
// Adwaita's light and dark are the same theme; only the preference and
// the -dark suffix differ, so applications that honour either agree.
const gtkTheme = root.dark ? "Adwaita-dark" : "Adwaita";
// adw-gtk3, not Adwaita. This is the bug that made dark mode look
// broken while light mode looked fine:
//
// Neither "Adwaita" nor "Adwaita-dark" is an installed theme on Fedora
// 44 -- only adw-gtk3 and adw-gtk3-dark are. Naming a theme that does
// not exist makes GTK fall back to its built-in default, which is
// LIGHT. So asking for light accidentally worked, asking for dark
// silently produced light, and applications that take their cue from
// the GTK theme rather than the portal -- Chromium and Electron, when
// built against GTK -- stayed light no matter what the portal said.
//
// gtk-theme-contract asserts these names are actually installed,
// because the failure mode is silent in exactly this way.
const gtkTheme = root.dark ? "adw-gtk3-dark" : "adw-gtk3";
const commands = [
["gsettings", "set", "org.gnome.desktop.interface", "color-scheme", scheme],
@@ -0,0 +1,54 @@
pragma Singleton
// Read-only device security facts: Secure Boot, TPM, disk encryption, SELinux,
// firewall.
//
// Nothing here is a preference. These are set in firmware, at install time, or
// by system policy, and a settings app that offered to change them from a
// switch would either fail or do something far-reaching from a control that
// looks like every other control. What this answers is "is this machine set up
// the way I think it is", which otherwise takes five commands and root.
//
// Read on demand. None of these can change while the desktop is running,
// short of a reboot.
import Quickshell
import Quickshell.Io
import QtQuick
Singleton {
id: root
readonly property string helperPath: Quickshell.shellDir + "/scripts/panama-security"
// [{ label, value, ok, detail }]
property var facts: []
property bool scanned: false
// The facts that are not in their reassuring state. The page leads with the
// count so a machine that is entirely fine says so in one line instead of
// making the user read five rows to find out.
readonly property int attentionCount: root.facts.filter(fact => !fact.ok).length
function refresh(): void {
if (!query.running)
query.running = true;
}
Process {
id: query
command: [root.helperPath]
stdout: StdioCollector {
onStreamFinished: {
try {
const parsed = JSON.parse(this.text);
root.facts = Array.isArray(parsed) ? parsed : [];
} catch (error) {
root.facts = [];
console.warn("DeviceSecurity: could not parse helper output:", error);
}
root.scanned = true;
}
}
}
}
@@ -0,0 +1,66 @@
pragma Singleton
// What input hardware this machine actually has.
//
// Exists so pages can hide controls for hardware that is not present. A
// touchpad card on a desktop is not merely useless -- it is misleading, because
// every switch on it appears to work: the preference is stored and Hyprland
// accepts the option for a device class it has no member of. The user is left
// toggling settings that will never affect anything, with nothing to say so.
//
// Touchpads are identified by name. libinput exposes them through the same
// "mice" list as everything else that reports pointer motion, and Hyprland
// passes the device name through, so an Elan or Synaptics touchpad arrives as
// something like "elan-touchpad". There is no device-class field to consult.
//
// Read on demand rather than polled. Input devices do come and go -- a mouse is
// unplugged, a receiver is moved -- so this also refreshes when Hyprland says
// the device list changed, which is the only moment the answer can differ.
import Quickshell
import Quickshell.Io
import Quickshell.Hyprland
import QtQuick
Singleton {
id: root
property var mice: []
property var keyboards: []
// True when anything that looks like a touchpad is attached.
readonly property bool hasTouchpad: root.mice.some(name =>
name.includes("touchpad") || name.includes("trackpad"))
readonly property bool hasMouse: root.mice.length > 0
function refresh(): void {
if (!query.running)
query.running = true;
}
Process {
id: query
running: true
command: ["hyprctl", "-j", "devices"]
stdout: StdioCollector {
onStreamFinished: {
try {
const parsed = JSON.parse(this.text);
root.mice = (parsed.mice ?? []).map(device => String(device.name ?? "").toLowerCase());
root.keyboards = (parsed.keyboards ?? []).map(device => String(device.name ?? "").toLowerCase());
} catch (error) {
console.warn("InputDevices: could not parse hyprctl devices:", error);
}
}
}
}
Connections {
target: Hyprland
function onRawEvent(event: var): void {
if (event.name === "device" || event.name === "configreloaded")
root.refresh();
}
}
}
@@ -0,0 +1,83 @@
pragma Singleton
// The login keyring's lock state.
//
// The keyring is unlocked at sign-in by pam_gnome_keyring, exactly as it is
// under GNOME. What a bare Hyprland session lacks is anywhere to see when that
// has stopped being true.
//
// It stops being true rarely but expensively: gnome-keyring-daemon can crash,
// D-Bus activates a replacement, and the replacement never received the login
// password -- so the keyring is locked in the middle of a session that unlocked
// it correctly. Nothing announces this. What the user sees instead is a mail
// account that will not authenticate, a git push that cannot find its key, or
// an integration reporting "not configured", none of which mention keyrings.
//
// Checked on demand and after an unlock, not polled: the state changes only
// when a daemon dies or a password is entered.
import Quickshell
import Quickshell.Io
import QtQuick
Singleton {
id: root
readonly property string helperPath: Quickshell.shellDir + "/scripts/panama-keyring"
property bool available: false
property bool locked: false
property bool scanned: false
property bool unlocking: false
property string lastError: ""
// "pam" when the daemon that holds the keyring is the one PAM started at
// login, "dbus" when it is a D-Bus-activated replacement -- which is the
// signature of the crash case, and worth showing, because a dbus daemon
// that is currently unlocked was unlocked by hand and will not survive.
property string daemon: ""
readonly property bool replacementDaemon: root.daemon === "dbus"
function refresh(): void {
if (!query.running)
query.running = true;
}
// Raises the standard password dialog. The password never passes through
// Panama -- the Secret Service prompts, the same way it does under GNOME.
function unlock(): void {
if (root.unlocking)
return;
root.unlocking = true;
unlockProcess.running = true;
}
function absorb(text: string): void {
try {
const parsed = JSON.parse(text);
root.available = parsed.available === true;
root.locked = parsed.locked === true;
root.daemon = String(parsed.daemon ?? "");
root.lastError = String(parsed.error ?? "");
} catch (error) {
root.available = false;
root.lastError = "Could not read the keyring helper's output.";
console.warn("Keyring: could not parse helper output:", error);
}
root.scanned = true;
}
Process {
id: query
command: [root.helperPath, "status"]
stdout: StdioCollector { onStreamFinished: root.absorb(this.text) }
}
Process {
id: unlockProcess
command: [root.helperPath, "unlock"]
stdout: StdioCollector { onStreamFinished: root.absorb(this.text) }
onExited: root.unlocking = false
}
}
@@ -0,0 +1,47 @@
pragma Singleton
// What this machine is: model, processor, memory, disk, OS, kernel.
//
// Read once, on demand. None of it changes while the desktop is running except
// free disk space, and About is not a monitor -- the vitals readout on the Home
// page is where live figures belong.
//
// Graphics is not here. GraphicsDevices already enumerates GPUs for the vitals
// readout, and naming them again would be a second source of truth that could
// disagree with the first; the About page joins the two instead.
import Quickshell
import Quickshell.Io
import QtQuick
Singleton {
id: root
readonly property string helperPath: Quickshell.shellDir + "/scripts/panama-about"
// [{ label, value }] in display order.
property var facts: []
property bool scanned: false
function refresh(): void {
if (!query.running)
query.running = true;
}
Process {
id: query
command: [root.helperPath]
stdout: StdioCollector {
onStreamFinished: {
try {
const parsed = JSON.parse(this.text);
root.facts = Array.isArray(parsed) ? parsed : [];
} catch (error) {
root.facts = [];
console.warn("MachineInfo: could not parse helper output:", error);
}
root.scanned = true;
}
}
}
}
@@ -0,0 +1,95 @@
pragma Singleton
// Online accounts, via GNOME Online Accounts.
//
// The daemon already runs in this session -- gvfs activates it, and accounts
// work without gnome-shell anywhere. Only the panel was GNOME's; the accounts
// are D-Bus objects anything may read and modify. So listing, per-service
// toggles, and removal all happen here, natively.
//
// Signing in is the exception, and only for OAuth providers. The daemon's
// AddAccount takes credentials as an argument rather than obtaining them, and
// the code that runs Google's OAuth exchange lives in libgoa-backend, which
// Fedora ships without a GIR binding. So that one step is handed to GNOME's
// panel and the user comes straight back here.
//
// Read on demand and after every change: accounts are added and removed by
// people, not by the system, so there is nothing to poll for.
import Quickshell
import Quickshell.Io
import QtQuick
Singleton {
id: root
readonly property string helperPath: Quickshell.shellDir + "/scripts/panama-accounts"
// [{ path, provider, providerName, identity, needsAttention, services: [{key,label,enabled}] }]
property var accounts: []
property bool scanned: false
property bool busy: false
property string lastError: ""
// Accounts whose stored credentials have stopped working -- an expired
// token, a changed password. GOA knows, and nothing outside its own panel
// ever says so, which is how an account quietly stops syncing for weeks.
readonly property int attentionCount: root.accounts.filter(a => a.needsAttention).length
readonly property bool available: root.lastError === ""
function refresh(): void {
if (!list.running)
list.running = true;
}
// Enabling a service clears GOA's "disabled" flag; the helper owns that
// inversion so the UI can speak in terms of what is on.
function setService(path: string, service: string, enabled: bool): void {
if (root.busy)
return;
root.busy = true;
write.command = [root.helperPath, "set", path, service, enabled ? "true" : "false"];
write.running = true;
}
function remove(path: string): void {
if (root.busy)
return;
root.busy = true;
write.command = [root.helperPath, "remove", path];
write.running = true;
}
Process {
id: list
command: [root.helperPath, "list"]
stdout: StdioCollector {
onStreamFinished: {
try {
const parsed = JSON.parse(this.text);
root.accounts = Array.isArray(parsed.accounts) ? parsed.accounts : [];
root.lastError = String(parsed.error ?? "");
} catch (error) {
root.accounts = [];
root.lastError = "Could not read the accounts helper's output.";
console.warn("OnlineAccounts: could not parse helper output:", error);
}
root.scanned = true;
}
}
}
Process {
id: write
stderr: StdioCollector {
onStreamFinished: if (this.text.trim() !== "") root.lastError = this.text.trim()
}
// Re-read rather than assuming the write landed: GOA may refuse, and a
// toggle that sprang back is the honest outcome.
onExited: {
root.busy = false;
root.refresh();
}
}
}
@@ -0,0 +1,107 @@
pragma Singleton
// The system power profile: power-saver, balanced, or performance.
//
// The same daemon GNOME's Power panel drives. On Fedora 44 the implementation
// is tuned-ppd rather than power-profiles-daemon, but it serves the same
// net.hadess.PowerProfiles interface -- so this talks to the interface, not to
// either binary. powerprofilesctl is not installed here at all.
//
// Not a stored preference. The profile lives in the daemon, survives Panama
// restarts, and can be changed by anything else on the system; keeping a copy
// in settings.json would mean restoring a value the daemon had moved past.
// Same reasoning as monitor brightness.
//
// Read on demand and after each change. The daemon does emit PropertiesChanged,
// but subscribing to it would mean holding a bus connection open for a value
// that changes only when someone chooses it.
import Quickshell
import Quickshell.Io
import QtQuick
Singleton {
id: root
readonly property string helperPath: Quickshell.shellDir + "/scripts/panama-power-profile"
property var profiles: []
property string active: ""
property bool scanned: false
property bool busy: false
property string lastError: ""
// Non-empty when the machine cannot actually deliver the profile it is set
// to -- thermal throttling, or a laptop running on battery. Worth showing,
// because otherwise "performance" is a claim the hardware is not honouring.
property string degraded: ""
readonly property bool available: root.profiles.length > 0
// Presentation lives here rather than in the page so the Control Center and
// Settings cannot disagree about what a profile is called.
function label(profile: string): string {
switch (profile) {
case "power-saver": return "Power Saver";
case "balanced": return "Balanced";
case "performance": return "Performance";
default: return profile;
}
}
function detail(profile: string): string {
switch (profile) {
case "power-saver": return "Reduces performance to save energy and run quieter";
case "balanced": return "Standard behaviour, scaling up only when needed";
case "performance": return "Holds higher clocks, using more power and making more noise";
default: return "";
}
}
function refresh(): void {
if (!query.running)
query.running = true;
}
function set(profile: string): void {
if (root.busy || profile === root.active)
return;
root.busy = true;
apply.command = [root.helperPath, "set", profile];
apply.running = true;
}
Process {
id: query
command: [root.helperPath, "list"]
stdout: StdioCollector {
onStreamFinished: {
try {
const parsed = JSON.parse(this.text);
root.profiles = Array.isArray(parsed.profiles) ? parsed.profiles : [];
root.active = String(parsed.active ?? "");
root.degraded = String(parsed.degraded ?? "");
root.lastError = String(parsed.error ?? "");
} catch (error) {
root.profiles = [];
root.lastError = "Could not read the power profile helper's output.";
console.warn("PowerProfiles: could not parse helper output:", error);
}
root.scanned = true;
}
}
}
Process {
id: apply
stderr: StdioCollector {
onStreamFinished: if (this.text.trim() !== "") root.lastError = this.text.trim()
}
// Re-read rather than assuming: the daemon may refuse, or may land on a
// different profile than the one asked for.
onExited: {
root.busy = false;
root.refresh();
}
}
}
@@ -33,6 +33,9 @@ Singleton {
"idle": "power",
"accessibility": "accessibility",
"input": "shortcuts",
"pointer": "mouse",
"touchpad": "mouse",
"multitasking": "desktop",
"weather": "appearance",
"notifications": "notifications",
"capture": "screen-intelligence"
@@ -92,7 +92,7 @@ Singleton {
}
function openSettings(page: string): void {
const allowed = ["home", "appearance", "displays", "connectivity", "home-phone", "desktop", "sound", "notifications", "screen-intelligence", "shortcuts", "accessibility", "power", "datetime", "applications", "services", "about"];
const allowed = ["home", "appearance", "displays", "connectivity", "home-phone", "desktop", "sound", "notifications", "screen-intelligence", "shortcuts", "mouse", "privacy", "region", "accounts", "accessibility", "power", "datetime", "applications", "services", "about"];
root.settingsPage = allowed.indexOf(page) >= 0 ? page : "home";
DesktopPreferences.set("lastPage", root.settingsPage);
root.settingsOpen = true;
@@ -0,0 +1,99 @@
pragma Singleton
// The system locale.
//
// Named SystemLocale, not Locale: QML has a built-in Locale value type, and a
// singleton of that name is silently shadowed by it. Every binding then reads
// properties off the wrong thing and the page renders empty with only
// "Cannot read property of undefined" to show for it.
//
// Changing it is privileged: localectl goes through polkit, which prompts
// (hyprpolkitagent serves that in this session). It also only applies to
// programs started afterwards, so `pendingRestart` goes true once a change is
// accepted and the page says a sign-out is needed. Reporting the new locale as
// simply "in effect" would be wrong -- almost nothing on screen would be using
// it yet.
import Quickshell
import Quickshell.Io
import QtQuick
Singleton {
id: root
readonly property string helperPath: Quickshell.shellDir + "/scripts/panama-locale"
// [{ value, label, detail }]
property var locales: []
property string current: ""
property bool scanning: false
property string lastError: ""
// True once a change has been accepted but the session has not restarted,
// so the UI can stop claiming the new locale is already in use.
property bool pendingRestart: false
readonly property string currentLabel: {
const match = root.locales.find(locale => locale.value === root.current);
return match ? match.label : root.current;
}
function refresh(): void {
if (root.scanning)
return;
root.scanning = true;
readCurrent.running = true;
list.running = true;
}
function set(value: string): void {
if (value === root.current)
return;
apply.command = [root.helperPath, "set", value];
apply.pendingValue = value;
apply.running = true;
}
Process {
id: list
command: [root.helperPath, "list"]
stdout: StdioCollector {
onStreamFinished: {
try {
const parsed = JSON.parse(this.text);
root.locales = Array.isArray(parsed) ? parsed : [];
} catch (error) {
root.locales = [];
console.warn("SystemLocale: could not parse the locale list:", error);
}
root.scanning = false;
}
}
}
Process {
id: readCurrent
command: [root.helperPath, "get"]
stdout: StdioCollector {
onStreamFinished: root.current = this.text.trim()
}
}
Process {
id: apply
property string pendingValue: ""
// A refused change -- polkit dismissed, or an unknown locale -- must not
// move the UI. The value is only adopted on a zero exit.
onExited: code => {
if (code === 0) {
root.current = apply.pendingValue;
root.pendingRestart = true;
root.lastError = "";
} else {
root.lastError = "The system did not accept that language. It may have needed a password.";
}
}
}
}
@@ -497,18 +497,35 @@ Singleton {
].indexOf(panel) >= 0;
}
function openGnomePanel(panel: string): bool {
// `subpage` reaches the panels GNOME 50 nests under System -- users,
// about, datetime, region -- which its own desktop entries open as
// `gnome-control-center system users`. Without it, a row labelled "Users"
// lands on System's front page and leaves the user to navigate, which is
// most of the way to a broken button.
function openGnomePanel(panel: string, subpage: string): bool {
if (!root.isGnomePanelAllowed(panel)) {
root.lastError = "That GNOME Settings panel is not available.";
return false;
}
const command = ["gnome-control-center", panel];
if (subpage !== undefined && subpage !== "" && root.isGnomeSubpageAllowed(panel, subpage))
command.push(subpage);
Quickshell.execDetached({
command: ["gnome-control-center", panel],
command: command,
environment: { "XDG_CURRENT_DESKTOP": "GNOME" }
});
return true;
}
// Only System nests panels, and only these. Read off the Exec lines of the
// gnome-*-panel desktop entries rather than guessed, for the same reason
// the panel list above was.
function isGnomeSubpageAllowed(panel: string, subpage: string): bool {
if (panel !== "system")
return false;
return ["users", "about", "datetime", "region", "remote-desktop"].indexOf(subpage) >= 0;
}
function openApplication(id: string): bool {
const commands = {
"nextcloud": ["nextcloud"],
@@ -0,0 +1,99 @@
pragma Singleton
// A QR code for a saved Wi-Fi network, so a guest can join by pointing a phone
// at the screen. GNOME's Wi-Fi panel has this and it is the most-used thing in
// it; reading a passphrase aloud is the alternative.
//
// The generated image contains the network password in machine-readable form,
// so the helper writes it under XDG_RUNTIME_DIR -- 0700, on tmpfs, gone at
// logout -- rather than anywhere persistent. Nothing here ever holds the
// passphrase itself; this service only ever sees a file path.
//
// Generated on demand. Producing a QR for every saved network up front would
// mean writing images of passwords nobody asked to see.
import Quickshell
import Quickshell.Io
import QtQuick
Singleton {
id: root
readonly property string helperPath: Quickshell.shellDir + "/scripts/panama-wifi-qr"
// [{ name, ssid, shareable }]
property var networks: []
property bool scanned: false
property string lastError: ""
// The network whose code is on screen, and where its image is. Empty when
// nothing is being shared.
property string sharing: ""
property string imagePath: ""
readonly property var shareable: root.networks.filter(n => n.shareable)
function refresh(): void {
if (!list.running)
list.running = true;
}
function share(name: string): void {
if (generate.running)
return;
// Cache-bust: the helper reuses one file per network, so a QML Image
// pointed at the same path would keep showing the previous render.
root.imagePath = "";
root.sharing = name;
generate.command = [root.helperPath, "qr", name];
generate.running = true;
}
function stopSharing(): void {
root.sharing = "";
root.imagePath = "";
}
Process {
id: list
command: [root.helperPath, "list"]
stdout: StdioCollector {
onStreamFinished: {
try {
const parsed = JSON.parse(this.text);
root.networks = Array.isArray(parsed.networks) ? parsed.networks : [];
root.lastError = String(parsed.error ?? "");
} catch (error) {
root.networks = [];
root.lastError = "Could not read the Wi-Fi helper's output.";
console.warn("WifiShare: could not parse helper output:", error);
}
root.scanned = true;
}
}
}
Process {
id: generate
stdout: StdioCollector {
onStreamFinished: {
try {
const parsed = JSON.parse(this.text);
const path = String(parsed.path ?? "");
const error = String(parsed.error ?? "");
if (error !== "" || path === "") {
root.lastError = error !== "" ? error : "No QR code was produced.";
root.sharing = "";
return;
}
root.lastError = "";
root.imagePath = path;
} catch (error) {
root.lastError = "Could not read the generated QR code's path.";
root.sharing = "";
console.warn("WifiShare: could not parse helper output:", error);
}
}
}
}
}