Fix sysmon: single Text element (no overlap), 1s refresh, center bar placement
swadhinbiswas committed 2 months ago
7dd47f5
1 parent 17073d0
commit 7dd47f5
2 files changed
+11 -12
Showing 2 changed files+11-12
▼shell/plugins/sysmon/BarWidget.qml
+10-11
| @@ -23,7 +23,7 @@ BarWidget { | ||
23 | 23 | command: ["bash", scriptPath] |
24 | 24 | stdout: SplitParser { |
25 | 25 | onRead: function(line) { |
26 | - var m = proc.stdout.match(/C=(\d+) M=(\d+) D=(\d+) G=(\d+) RX=([\d.]+) TX=([\d.]+)/) | |
26 | + var m = String(line).match(/C=(\d+) M=(\d+) D=(\d+) G=(\d+) RX=([\d.]+) TX=([\d.]+)/) | |
27 | 27 | if (m) { |
28 | 28 | root.cpuPct = parseInt(m[1]) |
29 | 29 | root.memPct = parseInt(m[2]) |
| @@ -36,19 +36,18 @@ BarWidget { | ||
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | - implicitWidth: row.implicitWidth + Style.spacing.controlPaddingX * 2 | |
39 | + implicitWidth: label.implicitWidth + Style.spacing.controlPaddingX * 2 | |
40 | 40 | implicitHeight: barSize |
41 | 41 | visible: !root.vertical |
42 | 42 | |
43 | - Row { | |
44 | - id: row | |
43 | + Text { | |
44 | + id: label | |
45 | 45 | anchors.verticalCenter: parent.verticalCenter |
46 | - spacing: Style.spacing.gap | |
47 | - | |
48 | - Text { text: "" + root.cpuPct + "%"; color: Color.foreground; font.family: bar.fontFamily; font.pixelSize: Style.font.body; opacity: 0.85 } | |
49 | - Text { text: "" + root.memPct + "%"; color: Color.foreground; font.family: bar.fontFamily; font.pixelSize: Style.font.body; opacity: 0.85 } | |
50 | - Text { text: "" + root.diskPct + "%"; color: Color.foreground; font.family: bar.fontFamily; font.pixelSize: Style.font.body; opacity: 0.85 } | |
51 | - Text { text: "" + root.gpuTemp + "°"; color: Color.foreground; font.family: bar.fontFamily; font.pixelSize: Style.font.body; opacity: 0.85 } | |
52 | - Text { text: "" + root.netDown + "↓ " + root.netUp + "↑"; color: Color.foreground; font.family: bar.fontFamily; font.pixelSize: Style.font.body; opacity: 0.85 } | |
46 | + anchors.horizontalCenter: parent.horizontalCenter | |
47 | + text: root.cpuPct + "%cpu " + root.memPct + "%ram " + root.gpuTemp + "°gpu " + root.diskPct + "%disk " + root.netDown + "↓ " + root.netUp + "↑" | |
48 | + color: root.bar ? root.bar.barForeground : Color.foreground | |
49 | + font.family: root.bar ? root.bar.fontFamily : Style.font.family | |
50 | + font.pixelSize: Style.font.body | |
51 | + opacity: 0.85 | |
53 | 52 | } |
54 | 53 | } |
55 | 54 | |
▼shell/plugins/sysmon/sysmon-stats.sh
+1-1
| @@ -3,7 +3,7 @@ | ||
3 | 3 | prev_cpu=$(awk '/^cpu /{print $2+$3+$4+$5+$6+$7+$8}' /proc/stat) |
4 | 4 | prev_idle=$(awk '/^cpu /{print $5}' /proc/stat) |
5 | 5 | while true; do |
6 | - sleep 2 | |
6 | + sleep 1 | |
7 | 7 | cur_cpu=$(awk '/^cpu /{print $2+$3+$4+$5+$6+$7+$8}' /proc/stat) |
8 | 8 | cur_idle=$(awk '/^cpu /{print $5}' /proc/stat) |
9 | 9 | dt=$(( cur_cpu - prev_cpu )) |
10 | 10 | |