extract BacklightApplet, add brightness and notif pills to lock screen right column
This commit is contained in:
parent
a55d232b9a
commit
08d34ac5c7
5 changed files with 163 additions and 79 deletions
|
|
@ -115,16 +115,6 @@ WlSessionLockSurface {
|
|||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
spacing: 24
|
||||
|
||||
LockNotifPills {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
// Spacer
|
||||
Item {
|
||||
width: 1
|
||||
height: 24
|
||||
}
|
||||
|
||||
// Password input
|
||||
LockInput {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Services.Mpris
|
||||
import Quickshell.Services.Pipewire
|
||||
import "../services" as S
|
||||
|
|
@ -28,13 +30,19 @@ Item {
|
|||
}
|
||||
|
||||
implicitHeight: _widgetContent.implicitHeight
|
||||
visible: _mprisCard.visible || _volumeCard.visible
|
||||
visible: _mprisCard.visible || _volumeCard.visible || _backlightCard.visible || _notifPills.visible
|
||||
|
||||
Column {
|
||||
id: _widgetContent
|
||||
width: parent.width
|
||||
spacing: 12
|
||||
|
||||
// Notification pills
|
||||
LockNotifPills {
|
||||
id: _notifPills
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
// Media widget
|
||||
Rectangle {
|
||||
id: _mprisCard
|
||||
|
|
@ -96,5 +104,74 @@ Item {
|
|||
accentColor: S.Theme.base0E
|
||||
}
|
||||
}
|
||||
|
||||
// Brightness widget
|
||||
Rectangle {
|
||||
id: _backlightCard
|
||||
width: parent.width
|
||||
height: _backlightContent.implicitHeight + 8
|
||||
radius: S.Theme.radius + 2
|
||||
color: Qt.rgba(S.Theme.base01.r, S.Theme.base01.g, S.Theme.base01.b, 0.7)
|
||||
border.color: Qt.rgba(S.Theme.base03.r, S.Theme.base03.g, S.Theme.base03.b, 0.3)
|
||||
border.width: 1
|
||||
visible: _blDev !== ""
|
||||
|
||||
property string _blDev: ""
|
||||
property int _percent: 0
|
||||
|
||||
Process {
|
||||
running: true
|
||||
command: ["sh", "-c", "ls /sys/class/backlight/ 2>/dev/null | head -1"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
const dev = text.trim();
|
||||
if (dev)
|
||||
_backlightCard._blDev = "/sys/class/backlight/" + dev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: _blCurrent
|
||||
path: _backlightCard._blDev ? _backlightCard._blDev + "/brightness" : ""
|
||||
watchChanges: true
|
||||
onFileChanged: reload()
|
||||
onLoaded: _backlightCard._updatePercent()
|
||||
}
|
||||
FileView {
|
||||
id: _blMax
|
||||
path: _backlightCard._blDev ? _backlightCard._blDev + "/max_brightness" : ""
|
||||
onLoaded: _backlightCard._updatePercent()
|
||||
}
|
||||
|
||||
function _updatePercent() {
|
||||
const c = parseInt(_blCurrent.text());
|
||||
const m = parseInt(_blMax.text());
|
||||
if (m > 0)
|
||||
_percent = Math.round((c / m) * 100);
|
||||
}
|
||||
|
||||
Process {
|
||||
id: _blAdj
|
||||
property string cmd: ""
|
||||
command: ["sh", "-c", cmd]
|
||||
onRunningChanged: if (!running && cmd !== "")
|
||||
_blCurrent.reload()
|
||||
}
|
||||
|
||||
C.BacklightApplet {
|
||||
id: _backlightContent
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 4
|
||||
percent: _backlightCard._percent
|
||||
accentColor: S.Theme.base0A
|
||||
onSetPercent: pct => {
|
||||
_blAdj.cmd = "light -S " + Math.round(Math.max(0, Math.min(100, pct)));
|
||||
_blAdj.running = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue