repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

feat(system): battery charge/state, bigger sparklines, themed action buttons

ef0b0f49e16b69153fd8df4c8b02a320164f05d3

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

- Battery row now shows live charge % + state (charging/full/on battery),
  appending wear % only when supported — instead of a bare "health n/a".
- Fix UPower scale: percentage/healthPercentage are 0..1 fractions; scale
  to 0..100 at the Resources boundary so the view reads "100%" not "1%"
  and the detectIssues health<80 check stops false-firing on healthy packs.
- Expose battery percent/status in stateJson() (IPC truthfulness).
- Sparklines widened 60->104 and 16->22px so the trend reads at a glance.
- Issue action buttons restyled as ghost buttons (transparent, severity
  border + text, faint hover fill) to match the dark card theme.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Changed files (2)

quickshell/nuguland/PopoutHost.qml

Modified
808 808 if (!systemPanel.rs)
809 809 return "—";
811 + const p = systemPanel.rs.batteryPercent;
812 + const st = systemPanel.rs.batteryStatus;
811 813 const h = systemPanel.rs.healthPercentage;
812 - return (h === null || h === undefined) ? "battery health n/a" : `battery health ${Math.round(Number(h))}%`;
814 + let s = (p === null || p === undefined) ? "battery n/a" : `battery ${p}%`;
815 + if (st)
816 + s += ` · ${st}`;
817 + if (h !== null && h !== undefined)
818 + s += ` · health ${Math.round(Number(h))}%`;
819 + return s;
1087 1094 visible: !!issueCard.modelData.action
1088 1095 anchors.right: parent.right
1089 - anchors.rightMargin: 10
1096 + anchors.rightMargin: 12
1090 1097 anchors.verticalCenter: parent.verticalCenter
1091 - width: 66
1092 - height: 26
1093 - radius: 8
1094 - color: root.theme ? root.theme.withAlpha(issueCard.sevColor, 0.30) : "transparent"
1098 + width: 62
1099 + height: 24
1100 + radius: 7
1101 + // ghost button: transparent with a severity-tinted border + text,
1102 + // faint fill on hover — consistent with the dark card aesthetic.
1103 + color: actMouse.containsMouse && root.theme ? root.theme.withAlpha(issueCard.sevColor, 0.22) : "transparent"
1104 + border.width: 1
1105 + border.color: root.theme ? root.theme.withAlpha(issueCard.sevColor, 0.55) : issueCard.sevColor
1096 - NuguText {
1107 + Text {
1097 1108 anchors.centerIn: parent
1098 - theme: root.theme
1099 - variant: "meta"
1100 1109 text: "open"
1110 + color: issueCard.sevColor
1111 + font.family: "IBM Plex Sans"
1112 + font.pixelSize: 13
1103 1115 MouseArea {
1116 + id: actMouse
1104 1118 anchors.fill: parent
1119 + hoverEnabled: true
1105 1120 cursorShape: Qt.PointingHandCursor
1106 1121 onClicked: {
1107 1122 if (systemPanel.rs)
1452 1467 values: mrow.ring
1453 1468 scaleMax: mrow.sparkScaleMax
1454 1469 barColor: mrow.barColor
1455 - width: 60
1456 - height: 16
1470 + width: 104
1471 + height: 22
1459 1474 Rectangle {

quickshell/nuguland/Resources.qml

Modified
1 1 import QtQuick
2 2 import Quickshell
3 3 import Quickshell.Io
4 +import Quickshell.Services.UPower
4 5 import "sysinfo.js" as Sys
6 7 // Thin I/O + cadence service over the pure sysinfo.js core.
77 78 // --- battery / throttle (event-driven UPower bindings) ---
78 79 // healthPercentage is null when unsupported / no battery (NOT -1) so the
79 80 // detectIssues battery check is skipped rather than firing a false error.
81 + // UPower percentage/healthPercentage are 0..1 fractions (energy/energyCapacity);
82 + // scale to 0..100 at this boundary so the view and detectIssues see whole percents.
80 83 readonly property var healthPercentage: {
81 84 const d = upower ? upower.displayDevice : null;
82 - return (d && d.ready && d.isLaptopBattery && d.healthSupported) ? Number(d.healthPercentage) : null;
85 + return (d && d.ready && d.isLaptopBattery && d.healthSupported) ? Number(d.healthPercentage) * 100 : null;
84 87 readonly property bool isLaptopBattery: {
85 88 const d = upower ? upower.displayDevice : null;
86 89 return !!(d && d.ready && d.isLaptopBattery);
91 + // live charge 0..100 (null when no battery) + a short state word
92 + readonly property var batteryPercent: {
93 + const d = upower ? upower.displayDevice : null;
94 + return (d && d.ready && d.isLaptopBattery) ? Math.round(Number(d.percentage) * 100) : null;
95 + }
96 + readonly property string batteryStatus: {
97 + const d = upower ? upower.displayDevice : null;
98 + if (!d || !d.ready || !d.isLaptopBattery)
99 + return "";
101 + switch (d.state) {
102 + case UPowerDeviceState.Charging:
103 + case UPowerDeviceState.PendingCharge:
104 + return "charging";
105 + case UPowerDeviceState.FullyCharged:
106 + return "full";
107 + case UPowerDeviceState.Discharging:
108 + case UPowerDeviceState.PendingDischarge:
109 + return "on battery";
110 + default:
111 + return "";
88 114 readonly property var degradationReason: {
89 115 if (!powerProfiles)
90 116 return null;
362 388 "cores": cores
364 390 "battery": {
391 + "percent": batteryPercent,
392 + "status": batteryStatus,
365 393 "healthPercentage": healthPercentage,
366 394 "isLaptopBattery": isLaptopBattery