summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorBelal <belalkoko00@gmail.com>2025-09-09 11:34:16 +0300
committerGitHub <noreply@github.com>2025-09-09 18:34:16 +1000
commit767ced0df331596307388498623a9ff43a0523a4 (patch)
treeaa0ea197549ba90610e4939bf87b6e0de5b8cada /modules
parentdashboard: fix pfp picker (diff)
downloadcaelestia-shell-767ced0df331596307388498623a9ff43a0523a4.tar.gz
caelestia-shell-767ced0df331596307388498623a9ff43a0523a4.tar.bz2
caelestia-shell-767ced0df331596307388498623a9ff43a0523a4.zip
launcher: allow configuring actions (#558)
* refactor: make launcher actions configurable * use variants + internal -> setMode + format * reorder readme --------- Co-authored-by: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
Diffstat (limited to 'modules')
-rw-r--r--modules/launcher/items/ActionItem.qml2
-rw-r--r--modules/launcher/services/Actions.qml167
2 files changed, 28 insertions, 141 deletions
diff --git a/modules/launcher/items/ActionItem.qml b/modules/launcher/items/ActionItem.qml
index 54e38f3..78b608a 100644
--- a/modules/launcher/items/ActionItem.qml
+++ b/modules/launcher/items/ActionItem.qml
@@ -7,7 +7,7 @@ import QtQuick
Item {
id: root
- required property Actions.Action modelData
+ required property var modelData
required property var list
implicitHeight: Config.launcher.sizes.itemHeight
diff --git a/modules/launcher/services/Actions.qml b/modules/launcher/services/Actions.qml
index 8259437..5c1cb6b 100644
--- a/modules/launcher/services/Actions.qml
+++ b/modules/launcher/services/Actions.qml
@@ -10,156 +10,43 @@ import QtQuick
Searcher {
id: root
- readonly property list<Action> actions: [
- Action {
- name: qsTr("Calculator")
- desc: qsTr("Do simple math equations (powered by Qalc)")
- icon: "calculate"
-
- function onClicked(list: AppList): void {
- root.autocomplete(list, "calc");
- }
- },
- 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"
- disabled: true
-
- function onClicked(list: AppList): void {
- root.autocomplete(list, "transparency");
- }
- },
- Action {
- name: qsTr("Random")
- desc: qsTr("Switch to a random wallpaper")
- icon: "casino"
+ function transformSearch(search: string): string {
+ return search.slice(Config.launcher.actionPrefix.length);
+ }
- function onClicked(list: AppList): void {
- list.visibilities.launcher = false;
- Quickshell.execDetached(["caelestia", "wallpaper", "-r"]);
- }
- },
- Action {
- name: qsTr("Light")
- desc: qsTr("Change the scheme to light mode")
- icon: "light_mode"
+ list: variants.instances
+ useFuzzy: Config.launcher.useFuzzy.actions
- function onClicked(list: AppList): void {
- list.visibilities.launcher = false;
- Colours.setMode("light");
- }
- },
- Action {
- name: qsTr("Dark")
- desc: qsTr("Change the scheme to dark mode")
- icon: "dark_mode"
+ Variants {
+ id: variants
- function onClicked(list: AppList): void {
- list.visibilities.launcher = false;
- Colours.setMode("dark");
- }
- },
- Action {
- name: qsTr("Shutdown")
- desc: qsTr("Shutdown the system")
- icon: "power_settings_new"
- disabled: !Config.launcher.enableDangerousActions
+ model: Config.launcher.actions.filter(a => (a.enabled ?? true) && (Config.launcher.enableDangerousActions || !(a.dangerous ?? false)))
- function onClicked(list: AppList): void {
- list.visibilities.launcher = false;
- Quickshell.execDetached(["systemctl", "poweroff"]);
- }
- },
- Action {
- name: qsTr("Reboot")
- desc: qsTr("Reboot the system")
- icon: "cached"
- disabled: !Config.launcher.enableDangerousActions
+ Action {}
+ }
- function onClicked(list: AppList): void {
- list.visibilities.launcher = false;
- Quickshell.execDetached(["systemctl", "reboot"]);
- }
- },
- Action {
- name: qsTr("Logout")
- desc: qsTr("Log out of the current session")
- icon: "exit_to_app"
- disabled: !Config.launcher.enableDangerousActions
+ component Action: QtObject {
+ required property var modelData
+ readonly property string name: modelData.name ?? qsTr("Unnamed")
+ readonly property string desc: modelData.description ?? qsTr("No description")
+ readonly property string icon: modelData.icon ?? "help_outline"
+ readonly property list<string> command: modelData.command ?? []
+ readonly property bool enabled: modelData.enabled ?? true
+ readonly property bool dangerous: modelData.dangerous ?? false
- function onClicked(list: AppList): void {
- list.visibilities.launcher = false;
- Quickshell.execDetached(["loginctl", "terminate-user", ""]);
- }
- },
- Action {
- name: qsTr("Lock")
- desc: qsTr("Lock the current session")
- icon: "lock"
+ function onClicked(list: AppList): void {
+ if (command.length === 0)
+ return;
- function onClicked(list: AppList): void {
+ if (command[0] === "autocomplete" && command.length > 1) {
+ list.search.text = `${Config.launcher.actionPrefix}${command[1]} `;
+ } else if (command[0] === "setMode" && command.length > 1) {
list.visibilities.launcher = false;
- Quickshell.execDetached(["loginctl", "lock-session"]);
- }
- },
- Action {
- name: qsTr("Sleep")
- desc: qsTr("Suspend then hibernate")
- icon: "bedtime"
-
- function onClicked(list: AppList): void {
+ Colours.setMode(command[1]);
+ } else {
list.visibilities.launcher = false;
- Quickshell.execDetached(["systemctl", "suspend-then-hibernate"]);
+ Quickshell.execDetached(command);
}
}
- ]
-
- function transformSearch(search: string): string {
- return search.slice(Config.launcher.actionPrefix.length);
- }
-
- function autocomplete(list: AppList, text: string): void {
- list.search.text = `${Config.launcher.actionPrefix}${text} `;
- }
-
- list: actions.filter(a => !a.disabled)
- useFuzzy: Config.launcher.useFuzzy.actions
-
- component Action: QtObject {
- required property string name
- required property string desc
- required property string icon
- property bool disabled
-
- function onClicked(list: AppList): void {
- }
}
}