From 5978db658c541d4acf4de4a14139232f4a57284c Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sat, 3 May 2025 14:32:53 +1000 Subject: feat: launcher actions --- modules/launcher/Actions.qml | 127 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 modules/launcher/Actions.qml (limited to 'modules/launcher/Actions.qml') diff --git a/modules/launcher/Actions.qml b/modules/launcher/Actions.qml new file mode 100644 index 0000000..4323bff --- /dev/null +++ b/modules/launcher/Actions.qml @@ -0,0 +1,127 @@ +pragma Singleton + +import "root:/utils/scripts/fuzzysort.js" as Fuzzy +import "root:/config" +import Quickshell +import Quickshell.Io +import QtQuick + +Singleton { + id: root + + readonly property list list: [ + Action { + name: qsTr("Scheme") + desc: qsTr("Change the current colour scheme") + icon: "palette" + + function onClicked(list: AppList): void { + root.autocomplete(list, "scheme"); + } + }, + Action { + name: qsTr("Wallpaper") + desc: qsTr("Change the current wallpaper") + icon: "image" + + function onClicked(list: AppList): void { + root.autocomplete(list, "wallpaper"); + } + }, + Action { + name: qsTr("Variant") + desc: qsTr("Change the current scheme variant") + icon: "colors" + + function onClicked(list: AppList): void { + root.autocomplete(list, "variant"); + } + }, + Action { + name: qsTr("Transparency") + desc: qsTr("Change shell transparency") + icon: "opacity" + + function onClicked(list: AppList): void { + root.autocomplete(list, "transparency"); + } + }, + Action { + name: qsTr("Light") + desc: qsTr("Change the scheme to light mode") + icon: "light_mode" + + function onClicked(list: AppList): void { + list.launcher.launcherVisible = false; + // TODO + } + }, + Action { + name: qsTr("Dark") + desc: qsTr("Change the scheme to dark mode") + icon: "dark_mode" + + function onClicked(list: AppList): void { + list.launcher.launcherVisible = false; + // TODO + } + }, + Action { + name: qsTr("Lock") + desc: qsTr("Lock the current session") + icon: "lock" + + function onClicked(list: AppList): void { + list.launcher.launcherVisible = false; + lock.running = true; + } + }, + Action { + name: qsTr("Sleep") + desc: qsTr("Suspend then hibernate") + icon: "bedtime" + + function onClicked(list: AppList): void { + list.launcher.launcherVisible = false; + sleep.running = true; + } + } + ] + + readonly property list preppedNames: list.map(a => ({ + name: Fuzzy.prepare(a.name), + action: a + })) + + function fuzzyQuery(search: string): var { + return Fuzzy.go(search.slice(LauncherConfig.actionPrefix.length), preppedNames, { + all: true, + key: "name" + }).map(r => r.obj.action); + } + + function autocomplete(list: AppList, text: string): void { + list.search.text = `${LauncherConfig.actionPrefix}${text} `; + } + + Process { + id: lock + + command: ["loginctl", "lock-session"] + } + + Process { + id: sleep + + command: ["systemctl", "suspend-then-hibernate"] + } + + component Action: QtObject { + required property string name + required property string desc + required property string icon + + function onClicked(list: AppList): void { + } + } +} -- cgit v1.2.3-freya