updated quickshell
This commit is contained in:
@@ -39,6 +39,7 @@ QtObject {
|
||||
property int brightness: 100
|
||||
|
||||
property bool wifiConnected: true
|
||||
property string connectionType: "off" // "wifi" | "eth" | "off"
|
||||
property string wifiSsid: "Wi-Fi"
|
||||
property string ipAddress: ""
|
||||
|
||||
@@ -47,6 +48,11 @@ QtObject {
|
||||
property bool batteryCharging: false
|
||||
property string batteryStatus: "Full"
|
||||
|
||||
// Disk Monitoring (root filesystem)
|
||||
property int diskPercent: 0
|
||||
property string diskUsedGb: "0"
|
||||
property string diskTotalGb: "0"
|
||||
|
||||
// GPU VRAM Monitoring (NVIDIA)
|
||||
property string gpuVramUsed: "0"
|
||||
property string gpuVramTotal: "0"
|
||||
@@ -98,31 +104,32 @@ QtObject {
|
||||
}
|
||||
|
||||
function switchWorkspace(n) {
|
||||
Hyprland.dispatch("workspace " + n);
|
||||
// NOTE: Hyprland's Lua config bridge requires typed dispatcher calls
|
||||
// (plain `hyprctl dispatch workspace 2` is mangled into invalid Lua).
|
||||
Hyprland.dispatch("hl.dsp.focus({workspace = " + n + "})");
|
||||
}
|
||||
|
||||
// Hyprland raw event processing
|
||||
readonly property Connections hyprConn: Connections {
|
||||
target: Hyprland
|
||||
function onRawEvent(event) { console.log(JSON.stringify(event), event.name, event.event, event.data);
|
||||
if (!event) return;
|
||||
if (event.startsWith("workspace>>")) {
|
||||
const data = event.substring(11);
|
||||
function onRawEvent(event) {
|
||||
if (!event || !event.name) return;
|
||||
const name = event.name;
|
||||
const data = event.data !== undefined ? String(event.data) : "";
|
||||
|
||||
if (name === "workspace") {
|
||||
const wsNum = parseInt(data);
|
||||
if (!isNaN(wsNum)) root.activeWorkspace = wsNum;
|
||||
} else if (event.startsWith("activewindow>>")) {
|
||||
const data = event.substring(14);
|
||||
} else if (name === "activewindow") {
|
||||
const parts = data.split(",");
|
||||
const title = parts[1] ? parts[1].trim() : (parts[0] ? parts[0].trim() : "");
|
||||
const cls = parts[0] ? parts[0].trim() : "Finder";
|
||||
|
||||
root.activeWindowClass = cls && cls.length > 0 ? cls : "Finder";
|
||||
const cls = parts[0] ? parts[0].trim() : "";
|
||||
const title = parts[1] ? parts[1].trim() : (cls || "");
|
||||
|
||||
root.activeWindowClass = cls && cls.length > 0 ? cls : "Desktop";
|
||||
root.activeWindowTitle = title && title.length > 0 ? title : root.activeWindowClass;
|
||||
} else if (event.startsWith("activewindowv2>>")) {
|
||||
} else if (name === "activewindowv2" || name === "openwindow" || name === "closewindow") {
|
||||
// Update running clients
|
||||
clientsProc.running = true;
|
||||
} else if (event.startsWith("openwindow>>") || event.startsWith("closewindow>>")) {
|
||||
clientsProc.running = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,6 +163,7 @@ QtObject {
|
||||
brightProc.running = true;
|
||||
mprisProc.running = true;
|
||||
gpuProc.running = true;
|
||||
diskProc.running = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,15 +208,16 @@ QtObject {
|
||||
}
|
||||
|
||||
readonly property Process wifiProc: Process {
|
||||
command: ["bash", "-c", "ssid=\"\"; if command -v nmcli &>/dev/null; then ssid=$(nmcli -t -f active,ssid dev wifi 2>/dev/null | grep '^yes:' | cut -d':' -f2); fi; [ -z \"$ssid\" ] && [ -f /proc/net/wireless ] && ssid=$(iwgetid -r 2>/dev/null); ip=$(ip -4 route get 1.1.1.1 2>/dev/null | awk '{print $7; exit}'); echo \"${ssid:-Ethernet} ${ip:-Offline}\""]
|
||||
// Emits: connectionType|ssid|ip ("wifi" | "eth" | "off")
|
||||
command: ["bash", "-c", "route=$(ip -4 route get 1.1.1.1 2>/dev/null); ip=$(echo \"$route\" | awk '{for(i=1;i<=NF;i++) if($i==\"src\") print $(i+1)}'); dev=$(echo \"$route\" | awk '{for(i=1;i<=NF;i++) if($i==\"dev\") print $(i+1)}'); type=\"off\"; ssid=\"\"; if [ -n \"$dev\" ]; then if [ -d \"/sys/class/net/$dev/wireless\" ]; then type=\"wifi\"; ssid=$(iwgetid -r 2>/dev/null); if [ -z \"$ssid\" ] && command -v nmcli &>/dev/null; then ssid=$(nmcli -t -f active,ssid dev wifi 2>/dev/null | grep '^yes:' | cut -d':' -f2); fi; else type=\"eth\"; fi; fi; echo \"$type|$ssid|$ip\""]
|
||||
stdout: StdioCollector {
|
||||
onDataChanged: {
|
||||
const str = String(data).trim();
|
||||
const parts = str.split(" ");
|
||||
if (parts.length >= 2) {
|
||||
root.wifiSsid = parts[0];
|
||||
root.ipAddress = parts[1];
|
||||
root.wifiConnected = parts[1] !== "Offline";
|
||||
const parts = String(data).trim().split("|");
|
||||
if (parts.length >= 3) {
|
||||
root.connectionType = parts[0] !== "" ? parts[0] : "off";
|
||||
root.wifiSsid = parts[1];
|
||||
root.ipAddress = parts[2];
|
||||
root.wifiConnected = parts[2] !== "" && parts[2] !== "Offline";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,6 +246,21 @@ QtObject {
|
||||
}
|
||||
}
|
||||
|
||||
readonly property Process diskProc: Process {
|
||||
// Emits: usedGB totalGB percent for the root filesystem
|
||||
command: ["bash", "-c", "df -BG / 2>/dev/null | awk 'NR==2 {u=$3; t=$2; gsub(/G/,\"\",u); gsub(/G/,\"\",t); if (t+0 > 0) print u, t, int(u*100/t)}'"]
|
||||
stdout: StdioCollector {
|
||||
onDataChanged: {
|
||||
const parts = String(data).trim().split(" ");
|
||||
if (parts.length >= 3) {
|
||||
root.diskUsedGb = parts[0];
|
||||
root.diskTotalGb = parts[1];
|
||||
root.diskPercent = parseInt(parts[2]) || 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readonly property Process mprisProc: Process {
|
||||
command: ["bash", "-c", "if command -v playerctl &>/dev/null; then t=$(playerctl metadata title 2>/dev/null); a=$(playerctl metadata artist 2>/dev/null); s=$(playerctl status 2>/dev/null); echo \"$s|$t|$a\"; fi"]
|
||||
stdout: StdioCollector {
|
||||
@@ -287,40 +311,40 @@ QtObject {
|
||||
}
|
||||
}
|
||||
|
||||
// Helper functions to control system
|
||||
// Helper functions to control system (execDetached: fire-and-forget)
|
||||
function setVolume(val) {
|
||||
root.volume = Math.max(0, Math.min(100, val));
|
||||
Process.exec(["pactl", "set-sink-volume", "@DEFAULT_SINK@", `${root.volume}%`]);
|
||||
Quickshell.execDetached(["pactl", "set-sink-volume", "@DEFAULT_SINK@", `${root.volume}%`]);
|
||||
}
|
||||
|
||||
function toggleVolumeMute() {
|
||||
Process.exec(["pactl", "set-sink-mute", "@DEFAULT_SINK@", "toggle"]);
|
||||
Quickshell.execDetached(["pactl", "set-sink-mute", "@DEFAULT_SINK@", "toggle"]);
|
||||
root.volumeMuted = !root.volumeMuted;
|
||||
}
|
||||
|
||||
function setBrightness(val) {
|
||||
root.brightness = Math.max(1, Math.min(100, val));
|
||||
Process.exec(["brightnessctl", "set", `${root.brightness}%`]);
|
||||
Quickshell.execDetached(["brightnessctl", "set", `${root.brightness}%`]);
|
||||
}
|
||||
|
||||
function mediaPlayPause() {
|
||||
Process.exec(["playerctl", "play-pause"]);
|
||||
Quickshell.execDetached(["playerctl", "play-pause"]);
|
||||
mprisProc.running = true;
|
||||
}
|
||||
|
||||
function mediaNext() {
|
||||
Process.exec(["playerctl", "next"]);
|
||||
Quickshell.execDetached(["playerctl", "next"]);
|
||||
mprisProc.running = true;
|
||||
}
|
||||
|
||||
function mediaPrevious() {
|
||||
Process.exec(["playerctl", "previous"]);
|
||||
Quickshell.execDetached(["playerctl", "previous"]);
|
||||
mprisProc.running = true;
|
||||
}
|
||||
|
||||
function launchApp(execCmd) {
|
||||
if (!execCmd) return;
|
||||
Process.exec(["bash", "-c", `${execCmd} &`]);
|
||||
Quickshell.execDetached(["sh", "-c", execCmd]);
|
||||
closeAllPopups();
|
||||
spotlightVisible = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user