Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8e526ba
feat(battery): add screen-edge countdown overlay with layout struts
Abscissa24 Oct 5, 2026
65a4fbc
feat(battery): show live countdown row and dismiss card on plug-in an…
Abscissa24 Oct 5, 2026
bd03a24
feat(battery): add critical-action countdown state machine and dispatch
Abscissa24 Oct 5, 2026
6c64d4b
feat(config): add criticalActionEnabled, criticalActionDelay and crit…
Abscissa24 Oct 5, 2026
3b81b38
feat(settings): add Critical actions section to Power settings
Abscissa24 Oct 5, 2026
353467d
feat(shell): load CriticalBatteryOverlay
Abscissa24 Oct 5, 2026
15f5192
refactor(settings): drop Lock screen from critical action options
Abscissa24 Oct 5, 2026
2a95adb
refactor(battery): remove lock handling from critical action dispatch
Abscissa24 Oct 5, 2026
9d480f6
feat(overlay): border-only countdown loop with no window reservations
Abscissa24 Oct 15, 2026
387920e
feat(bar): keep bar static during critical-battery countdown
Abscissa24 Oct 15, 2026
75bc87b
feat(config): countdown overlay appearance options
Abscissa24 Oct 15, 2026
4f9acf4
feat(settings): critical charge behaviour section with appearance con…
Abscissa24 Oct 15, 2026
5c3cc2f
feat(battery): explicit suspend action with unknown fallback label
Abscissa24 Oct 15, 2026
5aab2cc
feat(bar): keep bar static during critical-battery countdown
Abscissa24 Oct 15, 2026
c8af5ed
fix(bar): keep top bar stationary during critical countdown
Abscissa24 Nov 11, 2026
004d830
feat(battery): simplify overlay checks
Abscissa24 Nov 11, 2026
bccf17f
feat(bar): add properties for island, autoHide, and reserveSpace
Abscissa24 Nov 11, 2026
5d43696
feat(battery): optimise critical action handling in Battery.qml
Abscissa24 Nov 11, 2026
acdfca3
faet(battery): optimise CriticalBatteryOverlay.qml to use EdgePath
Abscissa24 Nov 11, 2026
264b109
feat(shell): update theme loader file path in shell.qml
Abscissa24 Nov 11, 2026
66837c8
feat(sleex-core): emit prepareForSleep on sleep and resume
Abscissa24 Nov 11, 2026
2a93962
feat(sleex-core): expose prepareForSleep signal
Abscissa24 Nov 11, 2026
abb1b1d
Adjust critical overlay properties in Config.qml
Abscissa24 Nov 11, 2026
1310a49
feat(overlay): change exclusiveZone value to -1
Abscissa24 Nov 12, 2026
29c8541
feat(overlay): change WlrLayer from Overlay to Top
Abscissa24 Nov 12, 2026
63a43fd
fix(BatteryPopup): fix critical state handling
Abscissa24 Nov 12, 2026
09b3572
feat(config): adjust critical overlay default properties
Abscissa24 Nov 12, 2026
986ba5a
feat(rules): add 'Choose' dialog pattern and update layer rules
Abscissa24 Nov 12, 2026
840a0d8
Merge remote-tracking branch 'origin/main' into Critical-Actions
Abscissa24 Nov 12, 2026
f4214ae
perf(overlay): render the countdown border with the curve renderer
Abscissa24 Nov 13, 2026
f17d8dd
Merge remote-tracking branch 'origin/main' into Critical-Actions
Abscissa24 Nov 13, 2026
37f16fb
fix(overlay): align the border fallbacks with the config defaults
Abscissa24 Nov 13, 2026
93400fd
build: require Qt 6.10
Abscissa24 Nov 13, 2026
5cbc6b7
perf(battery): only rebuild the countdown label once a second
Abscissa24 Nov 13, 2026
37c8f27
build: keep the Qt requirement at 6.9
Abscissa24 Nov 13, 2026
25b35a9
fix(overlay): paint the countdown border with the error colour
Abscissa24 Nov 13, 2026
ce57b46
fix(overlay): keep the countdown border in the accent colour
Abscissa24 Nov 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/etc/sleex/hyprland/rules.lua
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ hl.layer_rule({
match = { namespace = "quickshell:bar" },
animation = "slide",
})
-- The critical battery countdown border shares the top layer with the bar.
-- A higher order renders lower, so this keeps the border underneath the bar
-- and the island, which then always cover the screen edges they share.
hl.layer_rule({
match = { namespace = "quickshell:criticalaction" },
order = 1,
})
hl.layer_rule({
match = { namespace = "quickshell:cheatsheet" },
animation = "slide bottom",
Expand Down
124 changes: 124 additions & 0 deletions src/share/sleex/CriticalBatteryOverlay.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import qs
import qs.modules.common
import qs.services
import SleexUiKit.Appearance
import QtQuick
import Quickshell
import Quickshell.Wayland
import QtQuick.Shapes

Scope {
id: root

// Fallbacks mirror the defaults in modules/common/Config.qml.
property int borderThick: Config.options.battery.criticalOverlayBorderThick ?? 5
property int pathInset: Config.options.battery.criticalOverlayPathInset ?? 0
property int cornerRadius: Config.options.battery.criticalOverlayCornerRadius ?? 25

Variants {
model: Quickshell.screens

PanelWindow {
id: win
required property var modelData
screen: modelData

readonly property real prog: Battery.criticalActionProgress

visible: Battery.criticalActionWanted
color: "transparent"

anchors { top: true; bottom: true; left: true; right: true }
exclusiveZone: -1
WlrLayershell.layer: WlrLayer.Top
WlrLayershell.namespace: "quickshell:criticalaction"
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
mask: Region { }

readonly property real halfThick: root.borderThick / 2
readonly property real radius: root.cornerRadius
readonly property real lineLeft: root.pathInset + halfThick
readonly property real lineTop: root.pathInset + halfThick
readonly property real lineRight: win.width - root.pathInset - halfThick
readonly property real lineBottom: win.height - root.pathInset - halfThick

component EdgePath: ShapePath {
strokeWidth: root.borderThick
strokeColor: Appearance.colors.colPrimary
fillColor: "transparent"
capStyle: ShapePath.RoundCap
joinStyle: ShapePath.MiterJoin

PathMove { x: win.width / 2; y: win.lineTop }
PathLine { x: win.lineRight - win.radius; y: win.lineTop }
PathAngleArc {
centerX: win.lineRight - win.radius
centerY: win.lineTop + win.radius
radiusX: win.radius
radiusY: win.radius
startAngle: -90
sweepAngle: 90
}
PathLine { x: win.lineRight; y: win.lineBottom - win.radius }
PathAngleArc {
centerX: win.lineRight - win.radius
centerY: win.lineBottom - win.radius
radiusX: win.radius
radiusY: win.radius
startAngle: 0
sweepAngle: 90
}
PathLine { x: win.lineLeft + win.radius; y: win.lineBottom }
PathAngleArc {
centerX: win.lineLeft + win.radius
centerY: win.lineBottom - win.radius
radiusX: win.radius
radiusY: win.radius
startAngle: 90
sweepAngle: 90
}
PathLine { x: win.lineLeft; y: win.lineTop + win.radius }
PathAngleArc {
centerX: win.lineLeft + win.radius
centerY: win.lineTop + win.radius
radiusX: win.radius
radiusY: win.radius
startAngle: 180
sweepAngle: 90
}
PathLine { x: win.width / 2; y: win.lineTop }
}
Comment thread
Abscissa24 marked this conversation as resolved.
Resolved

Shape {
id: trackShape
anchors.fill: parent
visible: Battery.criticalActionWanted
antialiasing: true

// The curve renderer antialiases the strokes on the GPU, so the
// shapes need no offscreen buffer of their own. layer.enabled
// would allocate a full screen sized (and, with layer.samples,
// multisampled) texture for each of them.
preferredRendererType: Shape.CurveRenderer
opacity: 0.15
EdgePath { }
}
Shape {
id: snakeShape
anchors.fill: parent
visible: Battery.criticalActionWanted
antialiasing: true

preferredRendererType: Shape.CurveRenderer
EdgePath {
// ShapePath.trim is a property group (QQuickShapeTrim) that
// holds fractions of the path length, so the snake stroke
// grows along the border as the countdown runs.
trim.start: 0
trim.end: Math.max(win.prog, 0.002)
}
}
}
}

}
17 changes: 17 additions & 0 deletions src/share/sleex/modules/BatteryPopup/BatteryPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,15 @@ Scope {
overlayLoader.loading = true
if (Config.options.battery.sound)
Audio.playSound("assets/sounds/battery/05_critical.wav")
} else {
root.isCritical = false
overlayLoader.active = false
}
}

function onCriticalActionExecuted() {
overlayLoader.active = false
}
}

LazyLoader {
Expand Down Expand Up @@ -245,6 +252,16 @@ Scope {
font.pixelSize: Appearance.font.pixelSize.small
color: Appearance.colors.colOnLayer1
}

StyledText {
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
visible: Battery.criticalActionWanted
text: qsTr("%1 in %2s").arg(Battery.criticalActionLabel).arg(Battery.criticalActionRemaining)
font.pixelSize: Appearance.font.pixelSize.small
font.weight: Font.Medium
color: Appearance.colors.colError
}
}

Divider {}
Expand Down
11 changes: 4 additions & 7 deletions src/share/sleex/modules/bar/Bar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ Scope {
property ShellScreen modelData
property bool centerPopupOpen: false
property bool barRevealed: !Config.options.bar.autoHide || barHoverArea.containsMouse || barRoot.centerPopupOpen || GlobalStates.dashboardOpen

readonly property bool criticalShift: Battery.criticalActionWanted && barRoot.barRevealed

readonly property int autoHideAnimMs: 400
property var brightnessMonitor: Brightness.getMonitorForScreen(modelData)
property real useShortenedForm: (Appearance.sizes.barHellaShortenScreenWidthThreshold >= screen.width) ? 2 :
Expand All @@ -76,8 +73,8 @@ Scope {
WlrLayershell.namespace: "quickshell:bar"
WlrLayershell.layer: WlrLayer.Top
WlrLayershell.keyboardFocus: barRoot.centerPopupOpen ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
implicitHeight: (barRoot.criticalShift ? 20 : 0) + barHeight + Appearance.rounding.screenRounding + centerPopup.popupHeight + Appearance.sizes.elevationMargin * 2
exclusiveZone: (Config.options.bar.autoHide && !Config.options.bar.reserveSpace ? (barContent.visible ? barHeight : 0) : barHeight) + (barRoot.criticalShift ? 20 : 0)
implicitHeight: barHeight + Appearance.rounding.screenRounding + centerPopup.popupHeight + Appearance.sizes.elevationMargin * 2
exclusiveZone: Config.options.bar.autoHide && !Config.options.bar.reserveSpace ? (barContent.visible ? barHeight : 0) : barHeight
mask: Region {
Region {
item: Config.options.bar.autoHide ? barHoverArea : null
Expand Down Expand Up @@ -136,8 +133,8 @@ Scope {
left: parent.left
top: !Config.options.bar.bottom ? parent.top : undefined
bottom: Config.options.bar.bottom ? parent.bottom : undefined
topMargin: !Config.options.bar.bottom ? ((barContent.visible ? 0 : -barHeight) + (barRoot.criticalShift ? 20 : 0)) : 0
bottomMargin: Config.options.bar.bottom ? ((barContent.visible ? 0 : -barHeight) + (barRoot.criticalShift ? 20 : 0)) : 0
topMargin: !Config.options.bar.bottom ? (barContent.visible ? 0 : -barHeight) : 0
bottomMargin: Config.options.bar.bottom ? (barContent.visible ? 0 : -barHeight) : 0
}

Behavior on anchors.topMargin {
Expand Down
6 changes: 6 additions & 0 deletions src/share/sleex/modules/common/Config.qml
Comment thread
Abscissa24 marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ Singleton {
property int suspend: 2
property bool sound: true //Added for Battery Sound Toggle
property bool overlayEnabled: true
property bool criticalActionEnabled: false
property int criticalActionDelay: 30
property string criticalAction: "suspend"
property int criticalOverlayBorderThick: 5
property int criticalOverlayPathInset: 0
property int criticalOverlayCornerRadius: 25
}

property JsonObject bar: JsonObject {
Expand Down
78 changes: 78 additions & 0 deletions src/share/sleex/modules/settings/BehaviorConfig.qml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,84 @@ ContentPage {
}
}
}
ContentSubsection {
title: "Critical charge behavior"
tooltip: "On critical battery, run a screen-edge countdown, then the chosen action."
visible: UPower.displayDevice.isLaptopBattery

ConfigSwitch {
text: "Enable critical charge behavior"
checked: Config.options.battery.criticalActionEnabled
onClicked: checked = !checked;
onCheckedChanged: {
Config.options.battery.criticalActionEnabled = checked;
}
}
ConfigSpinBox {
text: "Countdown (seconds)"
value: Config.options.battery.criticalActionDelay
from: 5
to: 120
stepSize: 5
onValueChanged: {
Config.options.battery.criticalActionDelay = value;
}
}
ContentSubsectionLabel {
text: "Action on countdown end"
}
ConfigSelectionArray {
currentValue: Config.options.battery.criticalAction
configOptionName: "battery.criticalAction"
onSelected: (newValue) => {
Config.options.battery.criticalAction = newValue;
}
options: [
{"value": "suspend", "displayName": "Suspend"},
{"value": "hibernate", "displayName": "Hibernate"},
{"value": "shutdown", "displayName": "Shut down"}
]
}
ContentSubsectionLabel {
text: "Countdown appearance"
}
ConfigRow {
uniform: true
ConfigSpinBox {
text: "Border thickness"
value: Config.options.battery.criticalOverlayBorderThick
from: 2
to: 40
stepSize: 1
onValueChanged: {
Config.options.battery.criticalOverlayBorderThick = value;
}
}
ConfigSpinBox {
text: "Path inset"
value: Config.options.battery.criticalOverlayPathInset
from: 0
to: 40
stepSize: 1
onValueChanged: {
Config.options.battery.criticalOverlayPathInset = value;
}
}
}
ConfigRow {
uniform: true
ConfigSpinBox {
text: "Corner radius"
value: Config.options.battery.criticalOverlayCornerRadius
from: 0
to: 60
stepSize: 1
onValueChanged: {
Config.options.battery.criticalOverlayCornerRadius = value;
}
}
}
}
ContentSubsectionLabel {
text: "Power profile"
}
Expand Down
3 changes: 2 additions & 1 deletion src/share/sleex/plugins/src/Sleex/core/dpmsFade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ void SuspendFader::releaseLock() {
}

void SuspendFader::onPrepareForSleep(bool sleeping) {
emit prepareForSleep(sleeping);
if (sleeping) {
std::system("wlr-dpms off");
std::this_thread::sleep_for(FADE_DURATION);
Expand All @@ -88,4 +89,4 @@ void SuspendFader::onPrepareForSleep(bool sleeping) {
std::system("wlr-dpms on");
acquireLock();
}
}
}
5 changes: 4 additions & 1 deletion src/share/sleex/plugins/src/Sleex/core/dpmsFade.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class SuspendFader : public QObject {
Q_INVOKABLE void start();
Q_INVOKABLE void stop();

// Emitted when the system is about to sleep (true) or has just woken up (false).
Q_SIGNAL void prepareForSleep(bool sleeping);

private:
void acquireLock();
void releaseLock();
Expand All @@ -32,4 +35,4 @@ class SuspendFader : public QObject {
sdbus::ServiceName destination;
sdbus::ObjectPath objectPath;
int lock_fd_{-1};
};
};
Loading
Loading