Add Battery indicator to LockScreen
This commit is contained in:
parent
a722712913
commit
aabe05a7ea
2 changed files with 79 additions and 16 deletions
|
|
@ -5,6 +5,7 @@ import QtQuick.Effects
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
import Quickshell.Services.Pam
|
import Quickshell.Services.Pam
|
||||||
|
import Quickshell.Services.UPower
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import Quickshell.Widgets
|
import Quickshell.Widgets
|
||||||
import qs.Commons
|
import qs.Commons
|
||||||
|
|
@ -91,6 +92,46 @@ WlSessionLock {
|
||||||
}
|
}
|
||||||
|
|
||||||
WlSessionLockSurface {
|
WlSessionLockSurface {
|
||||||
|
// Battery indicator component
|
||||||
|
Item {
|
||||||
|
id: batteryIndicator
|
||||||
|
|
||||||
|
// Import UPower for battery data
|
||||||
|
property var battery: UPower.displayDevice
|
||||||
|
property bool isReady: battery && battery.ready && battery.isLaptopBattery && battery.isPresent
|
||||||
|
property real percent: isReady ? (battery.percentage * 100) : 0
|
||||||
|
property bool charging: isReady ? battery.state === UPowerDeviceState.Charging : false
|
||||||
|
property bool batteryVisible: isReady && percent > 0
|
||||||
|
|
||||||
|
// Choose icon based on charge and charging state
|
||||||
|
function getIcon() {
|
||||||
|
if (!batteryVisible)
|
||||||
|
return ""
|
||||||
|
|
||||||
|
if (charging)
|
||||||
|
return "battery_android_bolt"
|
||||||
|
|
||||||
|
if (percent >= 95)
|
||||||
|
return "battery_android_full"
|
||||||
|
|
||||||
|
// Hardcoded battery symbols
|
||||||
|
if (percent >= 85)
|
||||||
|
return "battery_android_6"
|
||||||
|
if (percent >= 70)
|
||||||
|
return "battery_android_5"
|
||||||
|
if (percent >= 55)
|
||||||
|
return "battery_android_4"
|
||||||
|
if (percent >= 40)
|
||||||
|
return "battery_android_3"
|
||||||
|
if (percent >= 25)
|
||||||
|
return "battery_android_2"
|
||||||
|
if (percent >= 10)
|
||||||
|
return "battery_android_1"
|
||||||
|
if (percent >= 0)
|
||||||
|
return "battery_android_0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Wallpaper image
|
// Wallpaper image
|
||||||
Image {
|
Image {
|
||||||
id: lockBgImage
|
id: lockBgImage
|
||||||
|
|
@ -354,6 +395,27 @@ WlSessionLock {
|
||||||
font.weight: Font.Bold
|
font.weight: Font.Bold
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Battery indicator
|
||||||
|
Row {
|
||||||
|
spacing: Style.marginSmall * scaling
|
||||||
|
visible: batteryIndicator.batteryVisible
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: batteryIndicator.getIcon()
|
||||||
|
font.family: "Material Symbols Outlined"
|
||||||
|
font.pointSize: Style.fontSizeMedium
|
||||||
|
color: batteryIndicator.charging ? Color.mPrimary : Color.mOnSurface
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: Math.round(batteryIndicator.percent) + "%"
|
||||||
|
color: Color.mOnSurface
|
||||||
|
font.family: "DejaVu Sans Mono"
|
||||||
|
font.pointSize: Style.fontSizeMedium
|
||||||
|
font.weight: Font.Bold
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
33
README.md
33
README.md
|
|
@ -64,6 +64,23 @@ A sleek, minimal, and thoughtfully crafted desktop shell for Wayland using **Qui
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
### Required
|
||||||
|
|
||||||
|
- `quickshell-git` - Core shell framework
|
||||||
|
- `material-symbols-git` - Icon font for UI elements
|
||||||
|
- `xdg-desktop-portal-gnome` - Desktop integration (or alternative portal)
|
||||||
|
|
||||||
|
### Optional
|
||||||
|
|
||||||
|
- `swww` - Wallpaper animations and effects
|
||||||
|
- `matugen` - Material You color scheme generation
|
||||||
|
- `cava` - Audio visualizer component
|
||||||
|
- `gpu-screen-recorder` - Screen recording functionality
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
@ -174,22 +191,6 @@ layer-rule {
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Dependencies
|
|
||||||
|
|
||||||
### Required
|
|
||||||
|
|
||||||
- `quickshell-git` - Core shell framework
|
|
||||||
- `material-symbols-git` - Icon font for UI elements
|
|
||||||
- `xdg-desktop-portal-gnome` - Desktop integration (or alternative portal)
|
|
||||||
|
|
||||||
### Optional
|
|
||||||
|
|
||||||
- `swww` - Wallpaper animations and effects
|
|
||||||
- `matugen` - Material You color scheme generation
|
|
||||||
- `cava` - Audio visualizer component
|
|
||||||
- `gpu-screen-recorder` - Screen recording functionality
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue