| 1 | import QtQuick |
| 2 | import QtQuick.Layouts |
| 3 | import Quickshell.Services.UPower |
| 4 | |
| 5 | // Settings app > Power: battery + battery care (Battery), power profile, graphics mode, idle timeouts (hypridle via Idle) and caffeine. |
| 6 | Flickable { |
| 7 | id: flick |
| 8 | clip: true |
| 9 | contentWidth: width |
| 10 | contentHeight: col.implicitHeight |
| 11 | boundsBehavior: Flickable.StopAtBounds |
| 12 | |
| 13 | // seconds -> "2m 30s" / "never" |
| 14 | function dur(s) { |
| 15 | if (s <= 0) return "never" |
| 16 | var m = Math.floor(s / 60), r = s % 60 |
| 17 | return m > 0 ? m + "m" + (r ? " " + r + "s" : "") : r + "s" |
| 18 | } |
| 19 | |
| 20 | // one timeout row: slider in 30s steps (0 = never) + readable value |
| 21 | component Timeout: RowLayout { |
| 22 | id: t |
| 23 | property string label: "" |
| 24 | property string key: "" |
| 25 | property int value: 0 |
| 26 | property int max: 1800 |
| 27 | Layout.fillWidth: true |
| 28 | spacing: 8 |
| 29 | Text { |
| 30 | Layout.preferredWidth: 150 |
| 31 | text: t.label |
| 32 | color: Theme.fg |
| 33 | font.family: Theme.font |
| 34 | font.pixelSize: Theme.fontSize |
| 35 | } |
| 36 | BarSlider { |
| 37 | Layout.fillWidth: true |
| 38 | from: 0 |
| 39 | to: t.max |
| 40 | step: 30 / t.max |
| 41 | value: t.value |
| 42 | onMoved: v => Idle.setTimeout(t.key, Math.round(v / 30) * 30) |
| 43 | } |
| 44 | Text { |
| 45 | Layout.preferredWidth: 70 |
| 46 | horizontalAlignment: Text.AlignRight |
| 47 | text: flick.dur(t.value) |
| 48 | color: t.value > 0 ? Theme.fg : Theme.dim |
| 49 | font.family: Theme.font |
| 50 | font.pixelSize: Theme.fontSize |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | ColumnLayout { |
| 55 | id: col |
| 56 | width: flick.width |
| 57 | spacing: 8 |
| 58 | |
| 59 | BatteryInfo {} |
| 60 | |
| 61 | SectionLabel { text: "battery care"; Layout.topMargin: 6; visible: Battery.hasBat } |
| 62 | Choice { |
| 63 | visible: Battery.supported |
| 64 | label: "charge limit" |
| 65 | options: [{ value: "off", label: "off" }, { value: "conservation", label: "conservation" }] |
| 66 | value: Settings.chargeMode === "off" ? "off" : "conservation" |
| 67 | onPicked: v => Settings.chargeMode = v |
| 68 | } |
| 69 | Text { |
| 70 | visible: Battery.supported |
| 71 | Layout.fillWidth: true |
| 72 | wrapMode: Text.WordWrap |
| 73 | text: Settings.chargeMode !== "off" |
| 74 | ? "the firmware stops charging at ~80%, even when aurora isn't running. Conservation mode is " |
| 75 | + (Battery.capOn ? "on" : "off") + "." |
| 76 | : "charges to 100%" |
| 77 | color: Theme.dim |
| 78 | font.family: Theme.font |
| 79 | font.pixelSize: Theme.fontSize - 2 |
| 80 | } |
| 81 | Knob { |
| 82 | visible: Battery.hasBat |
| 83 | label: "warn at" |
| 84 | from: 5; to: 40; unit: "%" |
| 85 | value: Settings.batLow |
| 86 | onMoved: v => Settings.batLow = v |
| 87 | } |
| 88 | Knob { |
| 89 | visible: Battery.hasBat |
| 90 | label: "critical at" |
| 91 | from: 2; to: 15; unit: "%" |
| 92 | value: Settings.batCritical |
| 93 | onMoved: v => Settings.batCritical = v |
| 94 | } |
| 95 | Choice { |
| 96 | visible: Battery.hasBat |
| 97 | label: "when critical" |
| 98 | options: [{ value: "none", label: "warn" }, { value: "suspend", label: "suspend" }, |
| 99 | { value: "poweroff", label: "power off" }] |
| 100 | value: Settings.batCriticalAction |
| 101 | onPicked: v => Settings.batCriticalAction = v |
| 102 | } |
| 103 | |
| 104 | Choice { |
| 105 | Layout.topMargin: 6 |
| 106 | visible: Battery.hasProfiles |
| 107 | label: "power profile" |
| 108 | options: [{ value: PowerProfile.PowerSaver, label: "saver" }, { value: PowerProfile.Balanced, label: "balanced" }] |
| 109 | .concat(PowerProfiles.hasPerformanceProfile ? [{ value: PowerProfile.Performance, label: "performance" }] : []) |
| 110 | value: PowerProfiles.profile |
| 111 | onPicked: v => PowerProfiles.profile = v |
| 112 | } |
| 113 | GpuSwitch { Layout.topMargin: 6 } |
| 114 | |
| 115 | SectionLabel { text: "when idle"; Layout.topMargin: 6 } |
| 116 | Timeout { label: "dim the screen"; key: "idleDim"; value: Idle.dim } |
| 117 | Timeout { label: "screen off"; key: "idleOff"; value: Idle.screenOff } |
| 118 | Timeout { label: "lock"; key: "idleLock"; value: Idle.lock } |
| 119 | Timeout { label: "suspend"; key: "idleSuspend"; value: Idle.suspend; max: 3600 } |
| 120 | Switch { |
| 121 | label: "caffeine" |
| 122 | hint: "keep the screen awake until turned off (not saved)" |
| 123 | checked: Toggles.caffeine |
| 124 | onToggled: on => Toggles.caffeine = on |
| 125 | } |
| 126 | Text { |
| 127 | Layout.fillWidth: true |
| 128 | text: "saved to ~/.config/aurora/hypridle.conf, hypridle restarts on change" |
| 129 | color: Theme.dim |
| 130 | elide: Text.ElideLeft |
| 131 | font.family: Theme.font |
| 132 | font.pixelSize: Theme.fontSize - 2 |
| 133 | } |
| 134 | } |
| 135 | } |