mirror of
https://github.com/arthur-pbty/arthur-os.git
synced 2026-08-02 04:37:49 +02:00
Address review on Noctalia-inspired widgets
- nightLight queries hyprctl hyprsunset temperature to detect state instead of pgrep, since omarchy-toggle-nightlight keeps the daemon running across toggles. Adds a 'toggling' busy flag so repeated clicks do not stack the toggle script. - lockKeys reads each LED individually and emits 'missing' when the class is absent, fixing column-shift mislabels on keyboards that only expose a subset of the locks. Hides + stops polling when no LEDs are reported. Poll interval relaxed to 2s. - activeWindow right-click now calls toplevel.close() against the captured window instead of dispatching killactive against whatever is focused at click time. - Drop unused Common imports from activeWindow and lockKeys.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import "../common" as Common
|
||||
|
||||
Item {
|
||||
id: root
|
||||
@@ -60,7 +59,7 @@ Item {
|
||||
if (mouse.button === Qt.MiddleButton) {
|
||||
root.toplevel.close()
|
||||
} else if (mouse.button === Qt.RightButton) {
|
||||
if (root.bar) root.bar.run("hyprctl dispatch killactive")
|
||||
root.toplevel.close()
|
||||
} else {
|
||||
root.toplevel.activate()
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import "../common" as Common
|
||||
|
||||
Item {
|
||||
id: root
|
||||
@@ -29,29 +28,35 @@ Item {
|
||||
if (!stateProc.running) stateProc.running = true
|
||||
}
|
||||
|
||||
property bool ledsAvailable: true
|
||||
|
||||
Process {
|
||||
id: stateProc
|
||||
command: ["bash", "-lc", "cat /sys/class/leds/input*::capslock/brightness 2>/dev/null | head -1; cat /sys/class/leds/input*::numlock/brightness 2>/dev/null | head -1; cat /sys/class/leds/input*::scrolllock/brightness 2>/dev/null | head -1"]
|
||||
command: ["bash", "-lc", "read_led() { for path in /sys/class/leds/input*::$1; do if [[ -r $path/brightness ]]; then cat $path/brightness; return; fi; done; echo missing; }; read_led capslock; read_led numlock; read_led scrolllock"]
|
||||
stdout: StdioCollector {
|
||||
waitForEnd: true
|
||||
onStreamFinished: {
|
||||
var lines = String(text || "").split("\n")
|
||||
root.capsOn = parseInt(lines[0], 10) > 0
|
||||
root.numOn = parseInt(lines[1], 10) > 0
|
||||
root.scrollOn = parseInt(lines[2], 10) > 0
|
||||
var caps = String(lines[0] || "").trim()
|
||||
var num = String(lines[1] || "").trim()
|
||||
var scroll = String(lines[2] || "").trim()
|
||||
root.capsOn = caps !== "missing" && parseInt(caps, 10) > 0
|
||||
root.numOn = num !== "missing" && parseInt(num, 10) > 0
|
||||
root.scrollOn = scroll !== "missing" && parseInt(scroll, 10) > 0
|
||||
root.ledsAvailable = caps !== "missing" || num !== "missing" || scroll !== "missing"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 1000
|
||||
running: true
|
||||
interval: 2000
|
||||
running: root.ledsAvailable
|
||||
repeat: true
|
||||
onTriggered: root.refresh()
|
||||
}
|
||||
|
||||
readonly property bool anyOn: capsOn || numOn || scrollOn
|
||||
visible: hideWhenOff ? anyOn : true
|
||||
visible: ledsAvailable && (hideWhenOff ? anyOn : true)
|
||||
|
||||
readonly property bool vertical: bar ? bar.vertical : false
|
||||
|
||||
|
||||
@@ -12,6 +12,10 @@ Item {
|
||||
|
||||
property bool active: false
|
||||
property bool toolAvailable: false
|
||||
property bool toggling: false
|
||||
|
||||
readonly property int onTemp: 4000
|
||||
readonly property int offTemp: 6000
|
||||
|
||||
function setting(name, fallback) {
|
||||
var value = settings ? settings[name] : undefined
|
||||
@@ -23,6 +27,8 @@ Item {
|
||||
}
|
||||
|
||||
function toggle() {
|
||||
if (toggling) return
|
||||
toggling = true
|
||||
if (root.bar) root.bar.run("omarchy-toggle-nightlight")
|
||||
refreshTimer.restart()
|
||||
}
|
||||
@@ -31,20 +37,27 @@ Item {
|
||||
|
||||
Process {
|
||||
id: statusProc
|
||||
command: ["bash", "-lc", "if command -v hyprsunset >/dev/null && pgrep -x hyprsunset >/dev/null 2>&1; then echo on; elif command -v hyprsunset >/dev/null; then echo off; else echo missing; fi"]
|
||||
command: ["bash", "-lc", "command -v hyprsunset >/dev/null || { echo missing; exit; }; if pgrep -x hyprsunset >/dev/null 2>&1; then hyprctl hyprsunset temperature 2>/dev/null | grep -oE '[0-9]+' | head -1; else echo idle; fi"]
|
||||
stdout: StdioCollector {
|
||||
waitForEnd: true
|
||||
onStreamFinished: {
|
||||
var state = String(text || "").trim()
|
||||
root.toolAvailable = state !== "missing"
|
||||
root.active = state === "on"
|
||||
root.toggling = false
|
||||
if (state === "missing") {
|
||||
root.toolAvailable = false
|
||||
root.active = false
|
||||
return
|
||||
}
|
||||
root.toolAvailable = true
|
||||
var temp = parseInt(state, 10)
|
||||
root.active = !isNaN(temp) && temp < root.offTemp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: refreshTimer
|
||||
interval: 1200
|
||||
interval: 1500
|
||||
onTriggered: root.refresh()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user