me like nix
0

Configure Feed

Select the types of activity you want to include in your feed.

1pragma Singleton 2 3import QtQuick 4import Quickshell 5import Quickshell.Io 6 7QtObject { 8 readonly property int cpuUsage: _cpuUsage 9 readonly property int memUsage: _memUsage 10 readonly property int temperature: _temperature 11 12 property int _cpuUsage: 0 13 property int _memUsage: 0 14 property int _temperature: 0 15 property var _lastCpuIdle: 0 16 property var _lastCpuTotal: 0 17 18 property var _cpuProc: Process { 19 command: ["sh", "-c", "head -1 /proc/stat"] 20 stdout: SplitParser { 21 onRead: data => { 22 if (!data) return 23 var p = data.trim().split(/\s+/) 24 var idle = parseInt(p[4]) + parseInt(p[5]) 25 var total = p.slice(1, 8).reduce((a, b) => a + parseInt(b), 0) 26 if (_lastCpuTotal > 0) { 27 _cpuUsage = Math.round(100 * (1 - (idle - _lastCpuIdle) / (total - _lastCpuTotal))) 28 } 29 _lastCpuTotal = total 30 _lastCpuIdle = idle 31 } 32 } 33 Component.onCompleted: running = true 34 } 35 36 property var _memProc: Process { 37 command: ["sh", "-c", "free | grep Mem"] 38 stdout: SplitParser { 39 onRead: data => { 40 if (!data) return 41 var parts = data.trim().split(/\s+/) 42 var total = parseInt(parts[1]) || 1 43 var used = parseInt(parts[2]) || 0 44 _memUsage = Math.round(100 * used / total) 45 } 46 } 47 Component.onCompleted: running = true 48 } 49 50 property var _tempProc: Process { 51 command: ["sh", "-c", "cat /sys/class/thermal/thermal_zone0/temp 2>/dev/null || echo 0"] 52 stdout: SplitParser { 53 onRead: data => { 54 if (!data) return 55 _temperature = Math.round(parseInt(data.trim()) / 1000) 56 } 57 } 58 Component.onCompleted: running = true 59 } 60 61 property var _timer: Timer { 62 interval: 2000 63 running: true 64 repeat: true 65 onTriggered: { 66 _cpuProc.running = true 67 _memProc.running = true 68 _tempProc.running = true 69 } 70 } 71}