Compare commits
2 commits
24d4c6cc3b
...
20ac6d0315
| Author | SHA1 | Date | |
|---|---|---|---|
| 20ac6d0315 | |||
| fb9ef6cd21 |
2 changed files with 59 additions and 39 deletions
14
flake.lock
generated
14
flake.lock
generated
|
|
@ -2,11 +2,11 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1759386674,
|
"lastModified": 1769740369,
|
||||||
"narHash": "sha256-wg1Lz/1FC5Q13R+mM5a2oTV9TA9L/CHHTm3/PiLayfA=",
|
"narHash": "sha256-xKPyJoMoXfXpDM5DFDZDsi9PHArf2k5BJjvReYXoFpM=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "625ad6366178f03acd79f9e3822606dd7985b657",
|
"rev": "6308c3b21396534d8aaeac46179c14c439a89b8a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -23,11 +23,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1759610621,
|
"lastModified": 1769593411,
|
||||||
"narHash": "sha256-P3UPFd95mS/3aNgy40nCXAmyfR2bEEBd+tX6xfkYFb0=",
|
"narHash": "sha256-WW00FaBiUmQyxvSbefvgxIjwf/WmRrEGBbwMHvW/7uQ=",
|
||||||
"rev": "c5c438f1cd1a76660a8658ef929a3d19e968e2ce",
|
"rev": "1e4d804e7f3fa7465811030e8da2bf10d544426a",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://git.outfoxxed.me/api/v1/repos/quickshell/quickshell/archive/c5c438f1cd1a76660a8658ef929a3d19e968e2ce.tar.gz"
|
"url": "https://git.outfoxxed.me/api/v1/repos/quickshell/quickshell/archive/1e4d804e7f3fa7465811030e8da2bf10d544426a.tar.gz"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Services.UPower
|
import Quickshell.Services.UPower
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
import QtQuick.Effects
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import qs.services
|
import qs.services
|
||||||
import qs.config
|
import qs.config
|
||||||
|
|
@ -84,7 +85,7 @@ Container {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MaterialIcon {
|
Item {
|
||||||
id: battery
|
id: battery
|
||||||
objectName: "battery"
|
objectName: "battery"
|
||||||
|
|
||||||
|
|
@ -92,47 +93,66 @@ Container {
|
||||||
Layout.leftMargin: hasBattery ? -2 : 0
|
Layout.leftMargin: hasBattery ? -2 : 0
|
||||||
Layout.topMargin: hasBattery ? 0.5 : 2
|
Layout.topMargin: hasBattery ? 0.5 : 2
|
||||||
|
|
||||||
|
implicitWidth: batteryIcon.width
|
||||||
|
implicitHeight: batteryIcon.height
|
||||||
|
|
||||||
readonly property bool hasBattery: UPower.displayDevice.isLaptopBattery
|
readonly property bool hasBattery: UPower.displayDevice.isLaptopBattery
|
||||||
readonly property real percentage: UPower.displayDevice.percentage
|
readonly property real percentage: 0.5 // Power.displayDevice.percentage
|
||||||
readonly property bool charging: !UPower.onBattery && batteryText.text !== "100"
|
readonly property bool charging: !UPower.onBattery && batteryText.text !== "100"
|
||||||
readonly property bool warning: UPower.onBattery && percentage < Config.services.batteryWarning + 0.01
|
readonly property bool warning: UPower.onBattery && percentage < Config.services.batteryWarning + 0.01
|
||||||
|
|
||||||
text: {
|
MaterialIcon {
|
||||||
if (!hasBattery) {
|
id: batteryIcon
|
||||||
if (PowerProfiles.profile === PowerProfile.PowerSaver)
|
anchors.centerIn: parent
|
||||||
return "energy_savings_leaf";
|
|
||||||
if (PowerProfiles.profile === PowerProfile.Performance)
|
|
||||||
return "rocket_launch";
|
|
||||||
return "balance";
|
|
||||||
}
|
|
||||||
return `battery_android_full`;
|
|
||||||
}
|
|
||||||
fill: 1
|
|
||||||
font.pointSize: hasBattery ? 18 : Config.font.size.normal
|
|
||||||
grade: 50
|
|
||||||
font.weight: 100
|
|
||||||
color: !hasBattery ? Config.colors.secondary :
|
|
||||||
warning ? Config.colors.errorBg :
|
|
||||||
batteryText.text === "100" ? Config.colors.battery :
|
|
||||||
Color.mute(Config.colors.battery, 0.6, 1.5)
|
|
||||||
|
|
||||||
CustomRect {
|
text: {
|
||||||
anchors.top: parent.top
|
if (!battery.hasBattery) {
|
||||||
anchors.bottom: parent.bottom
|
if (PowerProfiles.profile === PowerProfile.PowerSaver)
|
||||||
anchors.left: parent.left
|
return "energy_savings_leaf";
|
||||||
anchors.topMargin: 9
|
if (PowerProfiles.profile === PowerProfile.Performance)
|
||||||
anchors.bottomMargin: 9
|
return "rocket_launch";
|
||||||
anchors.leftMargin: 3
|
return "balance";
|
||||||
width: (battery.width - 7) * battery.percentage
|
}
|
||||||
radius: 2
|
return `battery_android_full`;
|
||||||
|
}
|
||||||
|
fill: 1
|
||||||
|
font.pointSize: battery.hasBattery ? 18 : Config.font.size.normal
|
||||||
|
grade: 50
|
||||||
|
font.weight: 100
|
||||||
|
color: !battery.hasBattery ? Config.colors.secondary :
|
||||||
|
battery.warning ? Config.colors.errorBg :
|
||||||
|
batteryText.text === "100" ? Config.colors.battery :
|
||||||
|
Color.mute(Config.colors.battery, 0.6, 1.5)
|
||||||
|
|
||||||
|
layer.enabled: true
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: meter
|
||||||
|
anchors.fill: batteryIcon
|
||||||
|
visible: false
|
||||||
|
|
||||||
|
CustomRect {
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.left: parent.left
|
||||||
|
width: battery.width * battery.percentage
|
||||||
|
color: battery.warning ? Config.colors.batteryWarning : Config.colors.battery
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MultiEffect {
|
||||||
|
anchors.fill: batteryIcon
|
||||||
|
|
||||||
visible: battery.hasBattery
|
visible: battery.hasBattery
|
||||||
color: battery.warning ? Config.colors.batteryWarning : Config.colors.battery
|
source: meter
|
||||||
|
maskEnabled: true
|
||||||
|
maskSource: batteryIcon
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
anchors.horizontalCenterOffset: battery.charging ? width / 20 : -width / 15
|
anchors.horizontalCenterOffset: battery.charging ? 0 : -width / 10
|
||||||
|
|
||||||
visible: battery.hasBattery
|
visible: battery.hasBattery
|
||||||
spacing: -1
|
spacing: -1
|
||||||
|
|
@ -155,7 +175,7 @@ Container {
|
||||||
visible: battery.charging
|
visible: battery.charging
|
||||||
text: "bolt"
|
text: "bolt"
|
||||||
fill: 1
|
fill: 1
|
||||||
color: Config.colors.bg
|
color: battery.warning ? Config.colors.batteryWarning : Config.colors.bg
|
||||||
font.pointSize: 7
|
font.pointSize: 7
|
||||||
font.weight: 300
|
font.weight: 300
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue