add quickshell

This commit is contained in:
Zoty 2026-04-15 10:38:34 -03:00
parent 3d48e35de5
commit 10960f620d
Signed by: Zoty
SSH key fingerprint: SHA256:WsGEGivgl37t3Mth6uugXMOgMCTR7QolIepNbC+j/tA
32 changed files with 1415 additions and 11 deletions

53
quickshell/NetMonitor.qml Normal file
View file

@ -0,0 +1,53 @@
pragma Singleton
import Quickshell
import Quickshell.Io
import QtQuick
Singleton {
id: root
property real rxSpeed: 0
property real txSpeed: 0
property var _prevRx: null
property var _prevTx: null
function _fmt(bytes) {
if (bytes >= 1048576) return (bytes / 1048576).toFixed(1) + " M"
if (bytes >= 1024) return (bytes / 1024).toFixed(0) + " K"
return bytes + " B"
}
readonly property string rxStr: _fmt(rxSpeed)
readonly property string txStr: _fmt(txSpeed)
Timer {
interval: 1000
running: true
repeat: true
triggeredOnStart: true
onTriggered: {
_proc.running = false
_proc.running = true
}
}
Process {
id: _proc
command: ["bash", "-c", "iface=$(ip route show default | awk '{print $5; exit}'); awk -v i=\"$iface:\" '$1==i {print $2, $10}' /proc/net/dev"]
stdout: SplitParser {
onRead: line => {
const parts = line.trim().split(/\s+/)
if (parts.length < 2) return
const rx = parseInt(parts[0])
const tx = parseInt(parts[1])
if (root._prevRx !== null) {
root.rxSpeed = Math.max(0, rx - root._prevRx)
root.txSpeed = Math.max(0, tx - root._prevTx)
}
root._prevRx = rx
root._prevTx = tx
}
}
}
}