initial commit
This commit is contained in:
commit
9fde6d4fc6
27 changed files with 1110 additions and 0 deletions
51
modules/Network.qml
Normal file
51
modules/Network.qml
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import QtQuick
|
||||
import Quickshell.Io
|
||||
import "." as M
|
||||
|
||||
Row {
|
||||
id: root
|
||||
spacing: 4
|
||||
|
||||
property string ifname: ""
|
||||
property string essid: ""
|
||||
property string state: "disconnected"
|
||||
|
||||
Process {
|
||||
id: proc
|
||||
running: true
|
||||
command: ["sh", "-c", "nmcli -t -f NAME,TYPE,DEVICE connection show --active | head -1"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
const line = text.trim();
|
||||
if (!line) {
|
||||
root.state = "disconnected";
|
||||
root.essid = "";
|
||||
root.ifname = "";
|
||||
return;
|
||||
}
|
||||
const parts = line.split(":");
|
||||
root.essid = parts[0] || "";
|
||||
root.ifname = parts[2] || "";
|
||||
root.state = (parts[1] || "").includes("wireless") ? "wifi" : "eth";
|
||||
}
|
||||
}
|
||||
}
|
||||
Timer {
|
||||
interval: 5000
|
||||
running: true
|
||||
repeat: true
|
||||
onTriggered: proc.running = true
|
||||
}
|
||||
|
||||
Text {
|
||||
text: {
|
||||
if (root.state === "wifi") return " " + root.essid;
|
||||
if (root.state === "eth") return "";
|
||||
return "";
|
||||
}
|
||||
color: M.Theme.base05
|
||||
font.pixelSize: M.Theme.fontSize + 1
|
||||
font.family: M.Theme.fontFamily
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue