Krolyxon
Commit fb9b856

Branches

Refs →

aurora.configquickshellauroraSession.qml

42 lines · 2.3 KB · QML

1pragma Singleton
2import QtQuick
3import Quickshell
4
5// Session / power actions shared by PowerMenu and Runner. `confirm` ones need the two-press "sure?" arm.
6Singleton {
7 readonly property var actions: [
8 { id: "lock", icon: Theme.iLock, label: "lock", confirm: false },
9 { id: "leave", icon: Theme.iLogout, label: "leave Hyprland", confirm: true },
10 { id: "renew", icon: Theme.iRefresh, label: "renew Hyprland", confirm: false },
11 { id: "hibernate", icon: Theme.iHibernate, label: "hibernate", confirm: true },
12 { id: "reboot", icon: Theme.iReboot, label: "reboot", confirm: true },
13 { id: "shutdown", icon: Theme.iPower, label: "shutdown", confirm: true },
14 { id: "sleep", icon: Theme.iSleep, label: "sleep", confirm: false },
15 { id: "display", icon: Theme.iMonitor, label: "display off", confirm: false }
16 ]
17
18 // Start an app in its own systemd scope. Spawned straight from quickshell it would sit in aurora.service's cgroup:
19 // killed on every `systemctl --user restart aurora`, and one that ignores SIGTERM stalls the restart for 90s.
20 function launch(cmd, wd) {
21 Quickshell.execDetached({ command: ["systemd-run", "--user", "--scope", "--quiet", "--collect", "--"].concat(cmd),
22 workingDirectory: wd || Quickshell.env("HOME") })
23 }
24
25 function run(id) {
26 switch (id) {
27 case "lock": Quickshell.execDetached(["loginctl", "lock-session"]); break
28 case "leave": Hypr.logout(); break
29 case "renew": Quickshell.execDetached(["hyprctl", "reload"]); break
30 case "hibernate": Quickshell.execDetached(["systemctl", "hibernate", "-i"]); break
31 case "reboot": Quickshell.execDetached(["systemctl", "reboot", "-i"]); break
32 case "shutdown": Quickshell.execDetached(["systemctl", "poweroff", "-i"]); break
33 case "sleep": Quickshell.execDetached(["systemctl", "suspend", "-i"]); break
34 case "display": dpmsDelay.restart(); break // let the Enter key-up pass first, it would wake the screen
35 }
36 }
37 Timer {
38 id: dpmsDelay
39 interval: 400
40 onTriggered: Quickshell.execDetached(["hyprctl", "dispatch", 'hl.dsp.dpms({action="off"})'])
41 }
42}