| @@ -96,29 +96,41 @@ Singleton { |
| 96 | 96 | | } |
| 97 | 97 | | |
| 98 | 98 | | // ---- power-profiles-daemon present? (Quickshell's PowerProfiles has no "available" flag) |
| 99 | + | // Don't touch PowerProfiles before it is: reading it D-Bus-activates ppd and blocks the whole shell until it |
| 100 | + | // runs, and ppd is After=multi-user.target (which waits on network-online), so that can be 30s+ after login. |
| 99 | 101 | | property bool hasProfiles: false |
| 102 | + | readonly property bool hasPerf: hasProfiles && PowerProfiles.hasPerformanceProfile |
| 103 | + | property int ppdTries: 0 |
| 100 | 104 | | Process { |
| 105 | + | id: ppdCheck |
| 101 | 106 | | command: ["busctl", "--system", "status", "org.freedesktop.UPower.PowerProfiles"] |
| 102 | 107 | | running: true |
| 103 | 108 | | stdout: StdioCollector {} |
| 104 | | − | onExited: code => { root.hasProfiles = code === 0; root.applyAuto() } |
| 109 | + | onExited: code => { root.ppdTries++; root.hasProfiles = code === 0; root.applyAuto() } |
| 110 | + | } |
| 111 | + | // keep looking for ~2 min after start |
| 112 | + | Timer { |
| 113 | + | interval: 5000 |
| 114 | + | repeat: true |
| 115 | + | running: !root.hasProfiles && root.ppdTries < 24 |
| 116 | + | onTriggered: if (!ppdCheck.running) ppdCheck.running = true |
| 105 | 117 | | } |
| 106 | 118 | | |
| 107 | 119 | | // ---- power profile: saver | balanced | performance (set in ppd, which remembers it), or auto = |
| 108 | 120 | | // Settings.powerAc / powerBat, switched when the power source changes |
| 109 | | − | readonly property string profile: Settings.powerAuto ? "auto" : nameOf(PowerProfiles.profile) |
| 121 | + | readonly property string profile: Settings.powerAuto ? "auto" : hasProfiles ? nameOf(PowerProfiles.profile) : "balanced" |
| 110 | 122 | | function nameOf(p) { |
| 111 | 123 | | return p === PowerProfile.PowerSaver ? "saver" : p === PowerProfile.Performance ? "performance" : "balanced" |
| 112 | 124 | | } |
| 113 | 125 | | function profileOf(name) { |
| 114 | 126 | | if (name === "saver") return PowerProfile.PowerSaver |
| 115 | | − | if (name === "performance" && PowerProfiles.hasPerformanceProfile) return PowerProfile.Performance |
| 127 | + | if (name === "performance" && hasPerf) return PowerProfile.Performance |
| 116 | 128 | | return PowerProfile.Balanced |
| 117 | 129 | | } |
| 118 | 130 | | function setProfile(name) { |
| 119 | 131 | | Settings.powerAuto = name === "auto" |
| 120 | 132 | | if (name === "auto") applyAuto() |
| 121 | | − | else PowerProfiles.profile = profileOf(name) |
| 133 | + | else if (hasProfiles) PowerProfiles.profile = profileOf(name) |
| 122 | 134 | | } |
| 123 | 135 | | function applyAuto() { |
| 124 | 136 | | if (!started || !hasProfiles || !Settings.powerAuto) return |