Krolyxon
Commit a78a1e5

Branches

Refs →

aurora.configquickshellwal-controlHomePage.qml

100 lines · 3.0 KB · QML

1import QtQuick
2import QtQuick.Layouts
3import Quickshell
4import Quickshell.Services.Pipewire
5
6ColumnLayout {
7 id: page
8 spacing: 12
9 signal closeRequested()
10
11 property string armed: ""
12 Timer { id: disarm; interval: 3000; onTriggered: page.armed = "" }
13
14 function act(name, cmd, confirm) {
15 if (confirm && armed !== name) { armed = name; disarm.restart(); return }
16 armed = ""
17 Quickshell.execDetached(cmd)
18 closeRequested()
19 }
20
21 Timer {
22 interval: 3000
23 running: page.visible
24 repeat: true
25 onTriggered: Bright.refresh()
26 }
27
28 MediaCard { Layout.fillWidth: true }
29
30 SectionLabel { text: "levels" }
31
32 SliderRow {
33 Layout.fillWidth: true
34 readonly property var audio: Pipewire.defaultAudioSink ? Pipewire.defaultAudioSink.audio : null
35 icon: Theme.volIcon(audio ? audio.volume : 0, audio ? audio.muted : true)
36 value: audio ? audio.volume : 0
37 muted: audio ? audio.muted : false
38 onMoved: v => { if (audio) audio.volume = v }
39 onIconClicked: if (audio) audio.muted = !audio.muted
40 }
41
42 SliderRow {
43 Layout.fillWidth: true
44 readonly property var audio: Pipewire.defaultAudioSource ? Pipewire.defaultAudioSource.audio : null
45 icon: audio && !audio.muted ? Theme.iMic : Theme.iMicOff
46 value: audio ? audio.volume : 0
47 muted: audio ? audio.muted : false
48 onMoved: v => { if (audio) audio.volume = v }
49 onIconClicked: if (audio) audio.muted = !audio.muted
50 }
51
52 SliderRow {
53 Layout.fillWidth: true
54 visible: Bright.available
55 icon: Theme.iBright
56 value: Bright.percent / 100
57 valueText: Bright.percent + "%"
58 onMoved: v => Bright.setPercent(Math.max(0.01, v) * 100)
59 }
60
61 Item { Layout.fillHeight: true }
62
63 SectionLabel { text: "session" }
64
65 RowLayout {
66 Layout.fillWidth: true
67 spacing: 6
68 IconBtn {
69 Layout.fillWidth: true
70 icon: Theme.iLock
71 onClicked: page.act("lock", ["loginctl", "lock-session"], false)
72 }
73 IconBtn {
74 Layout.fillWidth: true
75 icon: Theme.iSleep
76 onClicked: page.act("sleep", ["systemctl", "suspend"], false)
77 }
78 IconBtn {
79 Layout.fillWidth: true
80 icon: Theme.iLogout
81 label: page.armed === "logout" ? "sure?" : ""
82 active: page.armed === "logout"
83 onClicked: page.act("logout", ["hyprctl", "dispatch", "exit"], true)
84 }
85 IconBtn {
86 Layout.fillWidth: true
87 icon: Theme.iReboot
88 label: page.armed === "reboot" ? "sure?" : ""
89 active: page.armed === "reboot"
90 onClicked: page.act("reboot", ["systemctl", "reboot"], true)
91 }
92 IconBtn {
93 Layout.fillWidth: true
94 icon: Theme.iPower
95 label: page.armed === "off" ? "sure?" : ""
96 active: page.armed === "off"
97 onClicked: page.act("off", ["systemctl", "poweroff"], true)
98 }
99 }
100}