Merge pull request #52 from thaemisch/betteractions

launcher: add shutdown, reboot and logout to actions
This commit is contained in:
2 * r + 2 * t 2025-06-16 00:42:36 +10:00 committed by GitHub
commit a1da662c38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 55 additions and 1 deletions

View file

@ -4,6 +4,7 @@ JsonObject {
property int maxShown: 8 property int maxShown: 8
property int maxWallpapers: 9 // Warning: even numbers look bad property int maxWallpapers: 9 // Warning: even numbers look bad
property string actionPrefix: ">" property string actionPrefix: ">"
property bool enableDangerousActions: false // Allow actions that can cause losing data, like shutdown, reboot and logout
property JsonObject sizes: JsonObject { property JsonObject sizes: JsonObject {
property int itemWidth: 600 property int itemWidth: 600

View file

@ -67,6 +67,39 @@ Singleton {
Colours.setMode("dark"); Colours.setMode("dark");
} }
}, },
Action {
name: qsTr("Shutdown")
desc: qsTr("Shutdown the system")
icon: "power_settings_new"
disabled: !Config.launcher.enableDangerousActions
function onClicked(list: AppList): void {
list.visibilities.launcher = false;
shutdown.running = true;
}
},
Action {
name: qsTr("Reboot")
desc: qsTr("Reboot the system")
icon: "cached"
disabled: !Config.launcher.enableDangerousActions
function onClicked(list: AppList): void {
list.visibilities.launcher = false;
reboot.running = true;
}
},
Action {
name: qsTr("Logout")
desc: qsTr("Log out of the current session")
icon: "exit_to_app"
disabled: !Config.launcher.enableDangerousActions
function onClicked(list: AppList): void {
list.visibilities.launcher = false;
logout.running = true;
}
},
Action { Action {
name: qsTr("Lock") name: qsTr("Lock")
desc: qsTr("Lock the current session") desc: qsTr("Lock the current session")
@ -89,7 +122,7 @@ Singleton {
} }
] ]
readonly property list<var> preppedActions: list.map(a => ({ readonly property list<var> preppedActions: list.filter(a => !a.disabled).map(a => ({
name: Fuzzy.prepare(a.name), name: Fuzzy.prepare(a.name),
desc: Fuzzy.prepare(a.desc), desc: Fuzzy.prepare(a.desc),
action: a action: a
@ -107,6 +140,24 @@ Singleton {
list.search.text = `${Config.launcher.actionPrefix}${text} `; list.search.text = `${Config.launcher.actionPrefix}${text} `;
} }
Process {
id: shutdown
command: ["systemctl", "poweroff"]
}
Process {
id: reboot
command: ["systemctl", "reboot"]
}
Process {
id: logout
command: ["sh", "-c", "(uwsm stop | grep -q 'Compositor is not running' && loginctl terminate-user $USER) || uwsm stop"]
}
Process { Process {
id: lock id: lock
@ -123,6 +174,8 @@ Singleton {
required property string name required property string name
required property string desc required property string desc
required property string icon required property string icon
property bool disabled
property string disabledReason
function onClicked(list: AppList): void { function onClicked(list: AppList): void {
} }