From 256f9b4a762c764978dc77c603997a4f4f1072f7 Mon Sep 17 00:00:00 2001 From: loner <2788892716@qq.com> Date: Sat, 27 Sep 2025 12:06:54 +0800 Subject: [PATCH] feat(launcher): add configurable terminal command The terminal command for launching applications was previously hardcoded to 'kitty', causing issues for users without it installed. This change introduces a new setting, 'appLauncher.terminalCommand', allowing users to specify their preferred terminal emulator. The default value is set to 'xterm -e'. The implementation includes: - Defining the setting in 'Commons/Settings.qml'. - Adding a text input in the launcher settings tab. - Updating the application plugin to use the new setting. --- Assets/Translations/en.json | 14 +++++++++----- Assets/settings-default.json | 3 ++- Commons/Settings.qml | 1 + Modules/Launcher/Plugins/ApplicationsPlugin.qml | 3 ++- Modules/Settings/Tabs/LauncherTab.qml | 10 ++++++++++ 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Assets/Translations/en.json b/Assets/Translations/en.json index 18bb5ce1..0d1d35f0 100644 --- a/Assets/Translations/en.json +++ b/Assets/Translations/en.json @@ -2,7 +2,7 @@ "settings": { "general": { "title": "General", - + "profile": { "section": { "label": "Profile", @@ -307,6 +307,10 @@ "use-app2unit": { "label": "Use App2Unit to launch applications", "description": "Uses an alternative launch method to better manage app processes and prevent issues." + }, + "terminal-command": { + "label": "Terminal command", + "description": "Command to launch a terminal. E.g., 'kitty -e' or 'gnome-terminal --'." } } }, @@ -1073,7 +1077,7 @@ "enter-width-pixels": "Enter width in pixels", "enter-command": "Enter command to execute (app or custom script)", "command-example": "echo \"Hello World\"", - + "search-wallpapers": "Type to filter wallpapers...", "search-launcher": "Search entries... or use > for commands", "search": "Search...", @@ -1174,7 +1178,7 @@ "lock-subtitle": "Lock your session", "end-subtitle": "End your session", "lock": "Lock", - "suspend": "Suspend", + "suspend": "Suspend", "reboot": "Reboot", "logout": "Logout", "shutdown": "Shutdown" @@ -1291,7 +1295,7 @@ }, "weather": { "clear-sky": "Clear sky", - "mainly-clear": "Mainly clear", + "mainly-clear": "Mainly clear", "partly-cloudy": "Partly cloudy", "overcast": "Overcast", "fog": "Fog", @@ -1301,7 +1305,7 @@ "thunderstorm": "Thunderstorm", "unknown": "Unknown" }, - + "authentication": { "failed": "Authentication failed", "error": "Authentication error" diff --git a/Assets/settings-default.json b/Assets/settings-default.json index 55a851c8..727337a4 100644 --- a/Assets/settings-default.json +++ b/Assets/settings-default.json @@ -109,7 +109,8 @@ "backgroundOpacity": 1, "pinnedExecs": [], "useApp2Unit": false, - "sortByMostUsed": true + "sortByMostUsed": true, + "terminalCommand": "xterm -e" }, "dock": { "autoHide": false, diff --git a/Commons/Settings.qml b/Commons/Settings.qml index 819f11be..3d25cf26 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -225,6 +225,7 @@ Singleton { property list pinnedExecs: [] property bool useApp2Unit: false property bool sortByMostUsed: true + property string terminalCommand: "xterm -e" } // dock diff --git a/Modules/Launcher/Plugins/ApplicationsPlugin.qml b/Modules/Launcher/Plugins/ApplicationsPlugin.qml index 36847501..c92d883b 100644 --- a/Modules/Launcher/Plugins/ApplicationsPlugin.qml +++ b/Modules/Launcher/Plugins/ApplicationsPlugin.qml @@ -142,7 +142,8 @@ Item { if (app.runInTerminal) { // If app.execute() fails for terminal apps, we handle it manually. Logger.log("ApplicationsPlugin", "Executing terminal app manually: " + app.name) - const command = ["kitty", "-e"].concat(app.command) + const terminal = Settings.data.appLauncher.terminalCommand.split(" ") + const command = terminal.concat(app.command) Quickshell.execDetached(command) } else if (app.execute) { // Default execution for GUI apps diff --git a/Modules/Settings/Tabs/LauncherTab.qml b/Modules/Settings/Tabs/LauncherTab.qml index 1a77f880..884ce3d3 100644 --- a/Modules/Settings/Tabs/LauncherTab.qml +++ b/Modules/Settings/Tabs/LauncherTab.qml @@ -99,6 +99,16 @@ ColumnLayout { onToggled: checked => Settings.data.appLauncher.useApp2Unit = checked } + NTextInput { + label: I18n.tr("settings.launcher.settings.terminal-command.label") + description: I18n.tr("settings.launcher.settings.terminal-command.description") + Layout.fillWidth: true + text: Settings.data.appLauncher.terminalCommand + onEditingFinished: { + Settings.data.appLauncher.terminalCommand = text + } + } + NDivider { Layout.fillWidth: true Layout.topMargin: Style.marginXL * scaling