Krolyxon
Branch master

Branches

Refs →

aurora.configquickshellauroraSetPower.qml

184 lines · 6.8 KB · QML

1import QtQuick
2import QtQuick.Layouts
3import Quickshell.Services.UPower
4
5// Settings app > Power: battery + battery care (Battery), power profile, graphics mode, idle timeouts (hypridle via Idle) and caffeine.
6Flickable {
7 id: flick
8 clip: true
9 contentWidth: width
10 contentHeight: col.implicitHeight
11 boundsBehavior: Flickable.StopAtBounds
12
13 readonly property var profiles: [{ value: "saver", label: "saver" }, { value: "balanced", label: "balanced" }]
14 .concat(Battery.hasPerf ? [{ value: "performance", label: "performance" }] : [])
15
16 // seconds -> "2m 30s" / "never"
17 function dur(s) {
18 if (s <= 0) return "never"
19 var m = Math.floor(s / 60), r = s % 60
20 return m > 0 ? m + "m" + (r ? " " + r + "s" : "") : r + "s"
21 }
22
23 // one timeout row: slider in 30s steps (0 = never) + readable value
24 // one timeout row, like a Knob: slider in 30s steps (0 = never) + the readable value in a chip
25 component Timeout: RowLayout {
26 id: t
27 property string label: ""
28 property string keywords: ""
29 property string key: ""
30 property int value: 0
31 property int max: 1800
32 Layout.fillWidth: true
33 Layout.leftMargin: 18
34 Layout.rightMargin: 14
35 implicitHeight: 48
36 spacing: 16
37 Text {
38 Layout.preferredWidth: 200
39 text: t.label
40 color: Theme.fg
41 font.family: Theme.ui
42 font.pixelSize: 15
43 }
44 BarSlider {
45 Layout.fillWidth: true
46 from: 0
47 to: t.max
48 step: 30 / t.max
49 value: t.value
50 onMoved: v => Idle.setTimeout(t.key, Math.round(v / 30) * 30)
51 }
52 Rectangle {
53 Layout.preferredWidth: 76
54 implicitHeight: 32
55 radius: 16
56 color: Theme.s2
57 Lb {
58 anchors.centerIn: parent
59 text: flick.dur(t.value)
60 color: t.value > 0 ? Theme.fg : Theme.grey
61 }
62 }
63 }
64
65 ColumnLayout {
66 id: col
67 width: flick.width
68 spacing: 22
69
70 BatteryInfo { cards: true }
71
72 Group {
73 title: "battery care"
74 keywords: "battery health"
75 visible: Battery.hasBat
76 Choice {
77 visible: Battery.supported
78 label: "charge limit"
79 keywords: "conservation 80% battery health longevity"
80 options: [{ value: "off", label: "off" }, { value: "conservation", label: "conservation" }]
81 value: Settings.chargeMode === "off" ? "off" : "conservation"
82 onPicked: v => Settings.chargeMode = v
83 }
84 Text {
85 visible: Battery.supported
86 Layout.fillWidth: true
87 Layout.leftMargin: 18
88 Layout.rightMargin: 18
89 Layout.bottomMargin: 6
90 wrapMode: Text.WordWrap
91 text: Settings.chargeMode !== "off"
92 ? "the firmware stops charging at ~80%, even when aurora isn't running. Conservation mode is "
93 + (Battery.capOn ? "on" : "off") + "."
94 : "charges to 100%"
95 color: Theme.fgDim
96 font.family: Theme.ui
97 font.pixelSize: 13
98 }
99 Knob {
100 visible: Battery.hasBat
101 label: "warn at"
102 keywords: "low battery warning"
103 from: 5; to: 40; unit: "%"
104 value: Settings.batLow
105 onMoved: v => Settings.batLow = v
106 }
107 Knob {
108 visible: Battery.hasBat
109 label: "critical at"
110 keywords: "critical battery"
111 from: 2; to: 15; unit: "%"
112 value: Settings.batCritical
113 onMoved: v => Settings.batCritical = v
114 }
115 Choice {
116 visible: Battery.hasBat
117 label: "when critical"
118 keywords: "low battery action"
119 options: [{ value: "none", label: "warn" }, { value: "suspend", label: "suspend" },
120 { value: "poweroff", label: "power off" }]
121 value: Settings.batCriticalAction
122 onPicked: v => Settings.batCriticalAction = v
123 }
124 }
125
126 Group {
127 title: "power profile"
128 keywords: "performance balanced saver power-profiles-daemon"
129 visible: Battery.hasProfiles
130 Choice {
131 visible: Battery.hasProfiles
132 label: "power profile"
133 keywords: "performance balanced saver power-profiles-daemon"
134 options: flick.profiles.concat(Battery.hasBat ? [{ value: "auto", label: "auto" }] : [])
135 value: Battery.profile
136 onPicked: v => Battery.setProfile(v)
137 }
138 Choice {
139 visible: Battery.hasProfiles && Settings.powerAuto
140 label: "on AC"
141 keywords: "plugged in charger power profile"
142 options: flick.profiles
143 value: Settings.powerAc
144 onPicked: v => Settings.powerAc = v
145 }
146 Choice {
147 visible: Battery.hasProfiles && Settings.powerAuto
148 label: "on battery"
149 keywords: "unplugged power profile"
150 options: flick.profiles
151 value: Settings.powerBat
152 onPicked: v => Settings.powerBat = v
153 }
154 }
155
156 GpuSwitch { cards: true }
157
158 Group {
159 title: "when idle"
160 keywords: "idle timeout sleep hypridle"
161 Timeout { label: "dim the screen"; keywords: "idle dim timeout"; key: "idleDim"; value: Idle.dim }
162 Timeout { label: "screen off"; keywords: "dpms display off idle timeout"; key: "idleOff"; value: Idle.screenOff }
163 Timeout { label: "lock"; keywords: "lock screen hyprlock idle timeout"; key: "idleLock"; value: Idle.lock }
164 Timeout { label: "suspend"; keywords: "sleep idle timeout"; key: "idleSuspend"; value: Idle.suspend; max: 3600 }
165 Switch {
166 label: "caffeine"
167 keywords: "stay awake keep awake inhibit idle"
168 hint: "keep the screen awake until turned off (not saved)"
169 checked: Toggles.caffeine
170 onToggled: on => Toggles.caffeine = on
171 }
172 }
173 Text {
174 Layout.fillWidth: true
175 Layout.leftMargin: 18
176 text: "saved to ~/.config/aurora/hypridle.conf, hypridle restarts on change"
177 color: Theme.fgDim
178 elide: Text.ElideLeft
179 font.family: Theme.ui
180 font.pixelSize: 13
181 }
182 Item { Layout.preferredHeight: 12 }
183 }
184}