From cd45c2d9cfae23416637903a2c9a107fc79f4392 Mon Sep 17 00:00:00 2001 From: Damocles Date: Sat, 11 Apr 2026 00:22:09 +0200 Subject: [PATCH] remove ws, fmt --- flake.nix | 1 + modules/Backlight.qml | 3 ++- modules/Bar.qml | 13 +++++++++---- modules/Battery.qml | 5 +++-- modules/Cpu.qml | 16 ++++++++++++---- modules/IdleInhibitor.qml | 4 +--- modules/Memory.qml | 6 ++++-- modules/Mpris.qml | 5 ++--- modules/Network.qml | 18 ++++++++++++------ modules/Notifications.qml | 31 +++++++++++++++++++------------ modules/PowerProfile.qml | 9 ++++++--- modules/Theme.qml | 24 ++++++++++++++++-------- modules/Tray.qml | 2 +- modules/Volume.qml | 6 +++--- modules/Wlogout.qml | 5 ++++- modules/Workspaces.qml | 9 +-------- modules/WorkspacesInner.qml | 36 ------------------------------------ 17 files changed, 96 insertions(+), 97 deletions(-) delete mode 100644 modules/WorkspacesInner.qml diff --git a/flake.nix b/flake.nix index 9d3b452..ec09d26 100644 --- a/flake.nix +++ b/flake.nix @@ -31,6 +31,7 @@ treefmt-config = { projectRootFile = "flake.nix"; programs.nixfmt.enable = true; + programs.qmlformat.enable = true; }; forAllSystems = fn: diff --git a/modules/Backlight.qml b/modules/Backlight.qml index ba90450..8eddbf2 100644 --- a/modules/Backlight.qml +++ b/modules/Backlight.qml @@ -25,7 +25,8 @@ Row { function _update() { const c = parseInt(current.text()); const m = parseInt(max.text()); - if (m > 0) root.percent = Math.round((c / m) * 100); + if (m > 0) + root.percent = Math.round((c / m) * 100); } Text { diff --git a/modules/Bar.qml b/modules/Bar.qml index c3c16fc..8035588 100644 --- a/modules/Bar.qml +++ b/modules/Bar.qml @@ -50,9 +50,12 @@ PanelWindow { anchors.verticalCenter: parent.verticalCenter spacing: 8 - M.Workspaces {} - M.Tray { bar: bar } - M.WindowTitle { Layout.maximumWidth: 400 } + M.Tray { + bar: bar + } + M.WindowTitle { + Layout.maximumWidth: 400 + } } // ---- right ---- @@ -62,7 +65,9 @@ PanelWindow { anchors.verticalCenter: parent.verticalCenter spacing: 12 - Item { Layout.fillWidth: true } + Item { + Layout.fillWidth: true + } M.Mpris {} M.Volume {} M.Bluetooth {} diff --git a/modules/Battery.qml b/modules/Battery.qml index ac1649f..50bb983 100644 --- a/modules/Battery.qml +++ b/modules/Battery.qml @@ -13,8 +13,9 @@ Row { Text { text: { - if (root.charging) return ""; - const icons = ["󰂎","󰁺","󰁻","󰁼","󰁽","󰁾","󰁿","󰂀","󰂁","󰂂","󱟢"]; + if (root.charging) + return ""; + const icons = ["󰂎", "󰁺", "󰁻", "󰁼", "󰁽", "󰁾", "󰁿", "󰂀", "󰂁", "󰂂", "󱟢"]; return icons[Math.min(10, Math.floor(root.pct / 10))]; } color: root.pct < 15 ? M.Theme.base08 : M.Theme.base05 diff --git a/modules/Cpu.qml b/modules/Cpu.qml index 331f9a3..b372566 100644 --- a/modules/Cpu.qml +++ b/modules/Cpu.qml @@ -21,9 +21,13 @@ Text { if (root._prev) { const dIdle = idle - root._prev.idle; const dTotal = total - root._prev.total; - if (dTotal > 0) root.usage = Math.round((1 - dIdle / dTotal) * 100); + if (dTotal > 0) + root.usage = Math.round((1 - dIdle / dTotal) * 100); } - root._prev = { idle, total }; + root._prev = { + idle, + total + }; } } FileView { @@ -31,7 +35,8 @@ Text { path: "/proc/cpuinfo" onLoaded: { const lines = text().split("\n").filter(l => l.startsWith("cpu MHz")); - if (lines.length === 0) return; + if (lines.length === 0) + return; const sum = lines.reduce((a, l) => a + parseFloat(l.split(":")[1]), 0); root.freqGhz = sum / lines.length / 1000; } @@ -40,7 +45,10 @@ Text { interval: 1000 running: true repeat: true - onTriggered: { stat.reload(); cpuinfo.reload(); } + onTriggered: { + stat.reload(); + cpuinfo.reload(); + } } text: " " + root.usage.toString().padStart(2) + "%@" + root.freqGhz.toFixed(2) diff --git a/modules/IdleInhibitor.qml b/modules/IdleInhibitor.qml index 171f890..4a85188 100644 --- a/modules/IdleInhibitor.qml +++ b/modules/IdleInhibitor.qml @@ -15,9 +15,7 @@ Text { Process { id: toggle - command: ["sh", "-c", root.active - ? "pkill -x systemd-inhibit || true" - : "systemd-inhibit --what=idle --who=nova-shell --why=user sleep infinity &"] + command: ["sh", "-c", root.active ? "pkill -x systemd-inhibit || true" : "systemd-inhibit --what=idle --who=nova-shell --why=user sleep infinity &"] } MouseArea { diff --git a/modules/Memory.qml b/modules/Memory.qml index e20b0ae..851e850 100644 --- a/modules/Memory.qml +++ b/modules/Memory.qml @@ -14,11 +14,13 @@ Text { const m = {}; text().split("\n").forEach(l => { const [k, v] = l.split(":"); - if (v) m[k.trim()] = parseInt(v.trim()); + if (v) + m[k.trim()] = parseInt(v.trim()); }); const total = m.MemTotal; const avail = m.MemAvailable; - if (total > 0) root.percent = Math.round(((total - avail) / total) * 100); + if (total > 0) + root.percent = Math.round(((total - avail) / total) * 100); } } Timer { diff --git a/modules/Mpris.qml b/modules/Mpris.qml index 826f193..eba740b 100644 --- a/modules/Mpris.qml +++ b/modules/Mpris.qml @@ -25,8 +25,7 @@ Row { anchors.verticalCenter: parent.verticalCenter } - MouseArea { - anchors.fill: parent - onClicked: root.player?.togglePlaying() + TapHandler { + onTapped: root.player?.togglePlaying() } } diff --git a/modules/Network.qml b/modules/Network.qml index 60c1add..65d07e8 100644 --- a/modules/Network.qml +++ b/modules/Network.qml @@ -26,9 +26,12 @@ Row { const parts = line.split(":"); root.essid = parts[0] || ""; root.ifname = parts[2] || ""; - if ((parts[1] || "").includes("wireless")) root.state = "wifi"; - else if (parts[0] === "linked") root.state = "linked"; - else root.state = "eth"; + if ((parts[1] || "").includes("wireless")) + root.state = "wifi"; + else if (parts[0] === "linked") + root.state = "linked"; + else + root.state = "eth"; } } } @@ -41,9 +44,12 @@ Row { Text { text: { - if (root.state === "wifi") return " " + root.essid; - if (root.state === "eth") return "󰈀"; - if (root.state === "linked") return "󱘖"; + if (root.state === "wifi") + return " " + root.essid; + if (root.state === "eth") + return "󰈀"; + if (root.state === "linked") + return "󱘖"; return "󰣽"; } color: M.Theme.base05 diff --git a/modules/Notifications.qml b/modules/Notifications.qml index 85b96f1..49bfc51 100644 --- a/modules/Notifications.qml +++ b/modules/Notifications.qml @@ -16,7 +16,7 @@ Row { command: ["swaync-client", "--subscribe-waybar"] stdout: SplitParser { splitMarker: "\n" - onRead: (line) => { + onRead: line => { try { const d = JSON.parse(line); const cls = d.class ?? ""; @@ -30,8 +30,10 @@ Row { Text { text: { - if (root.inhibited) return root.count > 0 ? "󰂛" : "󰪑"; - if (root.dnd) return root.count > 0 ? "󰂠" : "󰪓"; + if (root.inhibited) + return root.count > 0 ? "󰂛" : "󰪑"; + if (root.dnd) + return root.count > 0 ? "󰂠" : "󰪓"; return root.count > 0 ? "󱅫" : "󰂜"; } color: M.Theme.base05 @@ -47,16 +49,21 @@ Row { anchors.verticalCenter: parent.verticalCenter } - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: (m) => { - const cmd = m.button === Qt.RightButton - ? ["swaync-client", "--toggle-dnd", "--skip-wait"] - : ["swaync-client", "--toggle-panel", "--skip-wait"]; - clicker.command = cmd; + TapHandler { + acceptedButtons: Qt.LeftButton + onTapped: { + clicker.command = ["swaync-client", "--toggle-panel", "--skip-wait"]; clicker.running = true; } } - Process { id: clicker } + TapHandler { + acceptedButtons: Qt.RightButton + onTapped: { + clicker.command = ["swaync-client", "--toggle-dnd", "--skip-wait"]; + clicker.running = true; + } + } + Process { + id: clicker + } } diff --git a/modules/PowerProfile.qml b/modules/PowerProfile.qml index 940e248..34f7b92 100644 --- a/modules/PowerProfile.qml +++ b/modules/PowerProfile.qml @@ -23,9 +23,12 @@ Text { } text: { - if (root.profile === "performance") return ""; - if (root.profile === "power-saver") return ""; - if (root.profile === "balanced") return ""; + if (root.profile === "performance") + return ""; + if (root.profile === "power-saver") + return ""; + if (root.profile === "balanced") + return ""; return ""; } color: M.Theme.base05 diff --git a/modules/Theme.qml b/modules/Theme.qml index e242923..ef4972e 100644 --- a/modules/Theme.qml +++ b/modules/Theme.qml @@ -31,8 +31,7 @@ QtObject { property int barHeight: 32 property FileView _themeFile: FileView { - path: (Quickshell.env("XDG_CONFIG_HOME") || (Quickshell.env("HOME") + "/.config")) - + "/nova-shell/theme.json" + path: (Quickshell.env("XDG_CONFIG_HOME") || (Quickshell.env("HOME") + "/.config")) + "/nova-shell/theme.json" watchChanges: true onFileChanged: reload() onLoaded: root._apply(text()) @@ -40,14 +39,23 @@ QtObject { function _apply(raw) { let data; - try { data = JSON.parse(raw); } catch (e) { return; } + try { + data = JSON.parse(raw); + } catch (e) { + return; + } const c = data.colors || {}; for (const k of Object.keys(c)) { - if (k in root) root[k] = c[k]; + if (k in root) + root[k] = c[k]; } - if (data.fontFamily) root.fontFamily = data.fontFamily; - if (data.fontSize) root.fontSize = data.fontSize; - if (data.barOpacity !== undefined) root.barOpacity = data.barOpacity; - if (data.barHeight !== undefined) root.barHeight = data.barHeight; + if (data.fontFamily) + root.fontFamily = data.fontFamily; + if (data.fontSize) + root.fontSize = data.fontSize; + if (data.barOpacity !== undefined) + root.barOpacity = data.barOpacity; + if (data.barHeight !== undefined) + root.barHeight = data.barHeight; } } diff --git a/modules/Tray.qml b/modules/Tray.qml index f95b086..e9a0f07 100644 --- a/modules/Tray.qml +++ b/modules/Tray.qml @@ -28,7 +28,7 @@ RowLayout { MouseArea { anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: (mouse) => { + onClicked: mouse => { if (mouse.button === Qt.LeftButton) { iconItem.modelData.activate(); } else if (mouse.button === Qt.RightButton) { diff --git a/modules/Volume.qml b/modules/Volume.qml index bfa78d2..628b679 100644 --- a/modules/Volume.qml +++ b/modules/Volume.qml @@ -30,8 +30,8 @@ Row { anchors.verticalCenter: parent.verticalCenter } - MouseArea { - anchors.fill: parent - onClicked: if (root.sink?.audio) root.sink.audio.muted = !root.sink.audio.muted + TapHandler { + onTapped: if (root.sink?.audio) + root.sink.audio.muted = !root.sink.audio.muted } } diff --git a/modules/Wlogout.qml b/modules/Wlogout.qml index 5422986..acaf3ca 100644 --- a/modules/Wlogout.qml +++ b/modules/Wlogout.qml @@ -9,7 +9,10 @@ Text { font.family: M.Theme.fontFamily verticalAlignment: Text.AlignVCenter - Process { id: proc; command: ["wlogout"] } + Process { + id: proc + command: ["wlogout"] + } MouseArea { anchors.fill: parent diff --git a/modules/Workspaces.qml b/modules/Workspaces.qml index 97ff721..a134eda 100644 --- a/modules/Workspaces.qml +++ b/modules/Workspaces.qml @@ -1,14 +1,7 @@ import QtQuick import QtQuick.Layouts +// Placeholder — Quickshell.Services.Niri not yet available RowLayout { spacing: 4 - - Loader { - source: "WorkspacesInner.qml" - onStatusChanged: { - if (status === Loader.Error) - source = ""; - } - } } diff --git a/modules/WorkspacesInner.qml b/modules/WorkspacesInner.qml deleted file mode 100644 index 1cc1b12..0000000 --- a/modules/WorkspacesInner.qml +++ /dev/null @@ -1,36 +0,0 @@ -import QtQuick -import QtQuick.Layouts -import Quickshell.Services.Niri -import "." as M - -RowLayout { - spacing: 4 - - Repeater { - model: Niri.workspaces - - delegate: Rectangle { - required property var modelData - - implicitWidth: 24 - implicitHeight: 20 - radius: 4 - color: modelData.isFocused - ? M.Theme.base0D - : (modelData.isActive ? M.Theme.base03 : M.Theme.base02) - - Text { - anchors.centerIn: parent - text: modelData.idx ?? modelData.id - color: modelData.isFocused ? M.Theme.base00 : M.Theme.base05 - font.pixelSize: M.Theme.fontSize - font.family: M.Theme.fontFamily - } - - MouseArea { - anchors.fill: parent - onClicked: Niri.dispatch(["action", "focus-workspace", String(modelData.id)]) - } - } - } -}