diff --git a/Assets/Translations/de.json b/Assets/Translations/de.json index f032e52ef..39786055f 100644 --- a/Assets/Translations/de.json +++ b/Assets/Translations/de.json @@ -1701,6 +1701,16 @@ "label": "Bildschirm entsperrt", "placeholder": "z.B. notify-send \"Bildschirm\" \"Entsperrt\"" }, + "performance-mode-enabled": { + "description": "Befehl, der ausgeführt wird, wenn der Noctalia-Leistungsmodus aktiviert wird.", + "label": "Leistungsmodus aktiviert", + "placeholder": "z.B. notify-send \"Leistung\" \"Modus aktiviert\"" + }, + "performance-mode-disabled": { + "description": "Befehl, der ausgeführt wird, wenn der Noctalia-Leistungsmodus deaktiviert wird.", + "label": "Leistungsmodus deaktiviert", + "placeholder": "z.B. notify-send \"Leistung\" \"Modus deaktiviert\"" + }, "system-hooks": { "enable": { "description": "Alle Hook-Befehle aktivieren oder deaktivieren.", diff --git a/Assets/Translations/en.json b/Assets/Translations/en.json index f4d5a665d..c6922ca35 100644 --- a/Assets/Translations/en.json +++ b/Assets/Translations/en.json @@ -1687,7 +1687,7 @@ "label": "Hook command information" }, "parameters": { - "description": "• Wallpaper hook: $1 = wallpaper path, $2 = screen name
• Theme toggle hook: $1 = true/false (Dark Mode state)
• Screen lock/unlock hooks: No parameters", + "description": "• Wallpaper hook: $1 = wallpaper path, $2 = screen name
• Theme toggle hook: $1 = true/false (Dark Mode state)
• Screen lock/unlock hooks: No parameters
• Performance mode hooks: No parameters", "label": "Available parameters" } }, @@ -1701,6 +1701,16 @@ "label": "Screen unlocked", "placeholder": "e.g., notify-send \"Screen\" \"Unlocked\"" }, + "performance-mode-enabled": { + "description": "Command to be executed when Noctalia Performance Mode is enabled.", + "label": "Performance mode enabled", + "placeholder": "e.g., notify-send \"Performance\" \"Mode Enabled\"" + }, + "performance-mode-disabled": { + "description": "Command to be executed when Noctalia Performance Mode is disabled.", + "label": "Performance mode disabled", + "placeholder": "e.g., notify-send \"Performance\" \"Mode Disabled\"" + }, "system-hooks": { "enable": { "description": "Enable or disable all hook commands.", diff --git a/Assets/Translations/es.json b/Assets/Translations/es.json index 9ed138e0a..625391499 100644 --- a/Assets/Translations/es.json +++ b/Assets/Translations/es.json @@ -1701,6 +1701,16 @@ "label": "Pantalla desbloqueada", "placeholder": "ej., notify-send \"Pantalla\" \"Desbloqueada\"" }, + "performance-mode-enabled": { + "description": "Comando a ejecutar cuando se habilita el Modo de Rendimiento de Noctalia.", + "label": "Modo de rendimiento habilitado", + "placeholder": "ej., notify-send \"Rendimiento\" \"Modo Habilitado\"" + }, + "performance-mode-disabled": { + "description": "Comando a ejecutar cuando se deshabilita el Modo de Rendimiento de Noctalia.", + "label": "Modo de rendimiento deshabilitado", + "placeholder": "ej., notify-send \"Rendimiento\" \"Modo Deshabilitado\"" + }, "system-hooks": { "enable": { "description": "Activa o desactiva todos los comandos de hooks.", diff --git a/Assets/Translations/fr.json b/Assets/Translations/fr.json index c806c1515..52a7d4ba7 100644 --- a/Assets/Translations/fr.json +++ b/Assets/Translations/fr.json @@ -1701,6 +1701,16 @@ "label": "Écran déverrouillé", "placeholder": "ex: notify-send \"Écran\" \"Déverrouillé\"" }, + "performance-mode-enabled": { + "description": "Commande à exécuter lorsque le Mode Performance Noctalia est activé.", + "label": "Mode performance activé", + "placeholder": "ex: notify-send \"Performance\" \"Mode Activé\"" + }, + "performance-mode-disabled": { + "description": "Commande à exécuter lorsque le Mode Performance Noctalia est désactivé.", + "label": "Mode performance désactivé", + "placeholder": "ex: notify-send \"Performance\" \"Mode Désactivé\"" + }, "system-hooks": { "enable": { "description": "Activer ou désactiver toutes les commandes de hook.", diff --git a/Assets/Translations/ja.json b/Assets/Translations/ja.json index b745c982a..6d8beb83a 100644 --- a/Assets/Translations/ja.json +++ b/Assets/Translations/ja.json @@ -1701,6 +1701,16 @@ "label": "画面ロック解除時", "placeholder": "例: notify-send \"Screen\" \"Unlocked\"" }, + "performance-mode-enabled": { + "description": "Noctaliaパフォーマンスモードが有効になった際に実行されるコマンド。", + "label": "パフォーマンスモード有効時", + "placeholder": "例: notify-send \"Performance\" \"Mode Enabled\"" + }, + "performance-mode-disabled": { + "description": "Noctaliaパフォーマンスモードが無効になった際に実行されるコマンド。", + "label": "パフォーマンスモード無効時", + "placeholder": "例: notify-send \"Performance\" \"Mode Disabled\"" + }, "system-hooks": { "enable": { "description": "すべてのフックコマンドの有効・無効を切り替えます。", diff --git a/Assets/Translations/nl.json b/Assets/Translations/nl.json index 358d39c46..2cf627761 100644 --- a/Assets/Translations/nl.json +++ b/Assets/Translations/nl.json @@ -1701,6 +1701,16 @@ "label": "Scherm ontgrendeld", "placeholder": "bijv. notify-send \"Scherm\" \"Ontgrendeld\"" }, + "performance-mode-enabled": { + "description": "Commando dat wordt uitgevoerd wanneer de Noctalia Prestatiemodus wordt ingeschakeld.", + "label": "Prestatiemodus ingeschakeld", + "placeholder": "bijv. notify-send \"Prestatie\" \"Modus Ingeschakeld\"" + }, + "performance-mode-disabled": { + "description": "Commando dat wordt uitgevoerd wanneer de Noctalia Prestatiemodus wordt uitgeschakeld.", + "label": "Prestatiemodus uitgeschakeld", + "placeholder": "bijv. notify-send \"Prestatie\" \"Modus Uitgeschakeld\"" + }, "system-hooks": { "enable": { "description": "Schakel alle hook-commando's in of uit.", diff --git a/Assets/Translations/pt.json b/Assets/Translations/pt.json index fce0a8b3e..cf7b50a51 100644 --- a/Assets/Translations/pt.json +++ b/Assets/Translations/pt.json @@ -1701,6 +1701,16 @@ "label": "Tela desbloqueada", "placeholder": "ex., notify-send \"Tela\" \"Desbloqueada\"" }, + "performance-mode-enabled": { + "description": "Comando a ser executado quando o Modo de Desempenho Noctalia é habilitado.", + "label": "Modo de desempenho habilitado", + "placeholder": "ex., notify-send \"Desempenho\" \"Modo Habilitado\"" + }, + "performance-mode-disabled": { + "description": "Comando a ser executado quando o Modo de Desempenho Noctalia é desabilitado.", + "label": "Modo de desempenho desabilitado", + "placeholder": "ex., notify-send \"Desempenho\" \"Modo Desabilitado\"" + }, "system-hooks": { "enable": { "description": "Ativa ou desativa todos os comandos de hook.", diff --git a/Assets/Translations/ru.json b/Assets/Translations/ru.json index 91c115645..4bc50b867 100644 --- a/Assets/Translations/ru.json +++ b/Assets/Translations/ru.json @@ -1701,6 +1701,16 @@ "label": "Экран разблокирован", "placeholder": "например, notify-send \"Экран\" \"Разблокирован\"" }, + "performance-mode-enabled": { + "description": "Команда для выполнения при включении режима производительности Noctalia.", + "label": "Режим производительности включен", + "placeholder": "например, notify-send \"Производительность\" \"Режим Включен\"" + }, + "performance-mode-disabled": { + "description": "Команда для выполнения при выключении режима производительности Noctalia.", + "label": "Режим производительности выключен", + "placeholder": "например, notify-send \"Производительность\" \"Режим Выключен\"" + }, "system-hooks": { "enable": { "description": "Включить или отключить все команды хуков.", diff --git a/Assets/Translations/tr.json b/Assets/Translations/tr.json index b57e14460..ec86d7efb 100644 --- a/Assets/Translations/tr.json +++ b/Assets/Translations/tr.json @@ -1701,6 +1701,16 @@ "label": "Ekran kilidi açıldı", "placeholder": "örn., notify-send \"Ekran\" \"Açıldı\"" }, + "performance-mode-enabled": { + "description": "Noctalia Performans Modu etkinleştirildiğinde çalıştırılacak komut.", + "label": "Performans modu etkinleştirildi", + "placeholder": "örn., notify-send \"Performans\" \"Mod Etkin\"" + }, + "performance-mode-disabled": { + "description": "Noctalia Performans Modu devre dışı bırakıldığında çalıştırılacak komut.", + "label": "Performans modu devre dışı bırakıldı", + "placeholder": "örn., notify-send \"Performans\" \"Mod Devre Dışı\"" + }, "system-hooks": { "enable": { "description": "Tüm kanca komutlarını etkinleştirin veya devre dışı bırakın.", diff --git a/Assets/Translations/uk-UA.json b/Assets/Translations/uk-UA.json index dd4ef165e..dd0e27f5b 100644 --- a/Assets/Translations/uk-UA.json +++ b/Assets/Translations/uk-UA.json @@ -1701,6 +1701,16 @@ "label": "Екран розблоковано", "placeholder": "напр., notify-send \"Екран\" \"Розблоковано\"" }, + "performance-mode-enabled": { + "description": "Команда для виконання при увімкненні режиму продуктивності Noctalia.", + "label": "Режим продуктивності увімкнено", + "placeholder": "напр., notify-send \"Продуктивність\" \"Режим Увімкнено\"" + }, + "performance-mode-disabled": { + "description": "Команда для виконання при вимкненні режиму продуктивності Noctalia.", + "label": "Режим продуктивності вимкнено", + "placeholder": "напр., notify-send \"Продуктивність\" \"Режим Вимкнено\"" + }, "system-hooks": { "enable": { "description": "Увімкнути або вимкнути всі команди хуків.", diff --git a/Assets/Translations/zh-CN.json b/Assets/Translations/zh-CN.json index 1b438e21b..d14d9f6c9 100644 --- a/Assets/Translations/zh-CN.json +++ b/Assets/Translations/zh-CN.json @@ -1701,6 +1701,16 @@ "label": "屏幕已解锁", "placeholder": "例如:notify-send \"屏幕\" \"已解锁\"" }, + "performance-mode-enabled": { + "description": "启用 Noctalia 性能模式时执行的命令。", + "label": "性能模式已启用", + "placeholder": "例如:notify-send \"性能\" \"模式已启用\"" + }, + "performance-mode-disabled": { + "description": "禁用 Noctalia 性能模式时执行的命令。", + "label": "性能模式已禁用", + "placeholder": "例如:notify-send \"性能\" \"模式已禁用\"" + }, "system-hooks": { "enable": { "description": "启用或禁用所有钩子命令。", diff --git a/Assets/settings-default.json b/Assets/settings-default.json index d3bc30c3f..7764fcf93 100644 --- a/Assets/settings-default.json +++ b/Assets/settings-default.json @@ -411,7 +411,9 @@ "wallpaperChange": "", "darkModeChange": "", "screenLock": "", - "screenUnlock": "" + "screenUnlock": "", + "performanceModeEnabled": "", + "performanceModeDisabled": "" }, "desktopWidgets": { "enabled": false, diff --git a/Commons/Settings.qml b/Commons/Settings.qml index c40d21440..be6dbb684 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -619,6 +619,8 @@ Singleton { property string darkModeChange: "" property string screenLock: "" property string screenUnlock: "" + property string performanceModeEnabled: "" + property string performanceModeDisabled: "" } // desktop widgets diff --git a/Modules/Panels/Settings/Tabs/HooksTab.qml b/Modules/Panels/Settings/Tabs/HooksTab.qml index 6c661250f..45f83d9e3 100644 --- a/Modules/Panels/Settings/Tabs/HooksTab.qml +++ b/Modules/Panels/Settings/Tabs/HooksTab.qml @@ -121,6 +121,50 @@ ColumnLayout { Layout.fillWidth: true } + // Performance Mode Enabled Hook Section + NInputAction { + id: performanceModeEnabledHookInput + label: I18n.tr("settings.hooks.performance-mode-enabled.label") + description: I18n.tr("settings.hooks.performance-mode-enabled.description") + placeholderText: I18n.tr("settings.hooks.performance-mode-enabled.placeholder") + text: Settings.data.hooks.performanceModeEnabled + onEditingFinished: { + Settings.data.hooks.performanceModeEnabled = performanceModeEnabledHookInput.text; + } + onActionClicked: { + if (performanceModeEnabledHookInput.text) { + HooksService.executePerformanceModeEnabledHook(); + } + } + Layout.fillWidth: true + } + + NDivider { + Layout.fillWidth: true + } + + // Performance Mode Disabled Hook Section + NInputAction { + id: performanceModeDisabledHookInput + label: I18n.tr("settings.hooks.performance-mode-disabled.label") + description: I18n.tr("settings.hooks.performance-mode-disabled.description") + placeholderText: I18n.tr("settings.hooks.performance-mode-disabled.placeholder") + text: Settings.data.hooks.performanceModeDisabled + onEditingFinished: { + Settings.data.hooks.performanceModeDisabled = performanceModeDisabledHookInput.text; + } + onActionClicked: { + if (performanceModeDisabledHookInput.text) { + HooksService.executePerformanceModeDisabledHook(); + } + } + Layout.fillWidth: true + } + + NDivider { + Layout.fillWidth: true + } + // Info section ColumnLayout { spacing: Style.marginM diff --git a/Services/Control/HooksService.qml b/Services/Control/HooksService.qml index c76ac1d51..894c67b0f 100644 --- a/Services/Control/HooksService.qml +++ b/Services/Control/HooksService.qml @@ -3,6 +3,7 @@ pragma Singleton import QtQuick import Quickshell import qs.Commons +import qs.Services.Power import qs.Services.UI Singleton { @@ -51,6 +52,26 @@ Singleton { } } + // Track performance mode state for hooks + property bool wasPerformanceModeEnabled: false + + Connections { + target: PowerProfileService + function onNoctaliaPerformanceModeChanged() { + const isEnabled = PowerProfileService.noctaliaPerformanceMode; + + // Detect enabled: was disabled, now enabled + if (!wasPerformanceModeEnabled && isEnabled) { + executePerformanceModeEnabledHook(); + } + // Detect disabled: was enabled, now disabled + if (wasPerformanceModeEnabled && !isEnabled) { + executePerformanceModeDisabledHook(); + } + wasPerformanceModeEnabled = isEnabled; + } + } + // Execute wallpaper change hook function executeWallpaperHook(wallpaperPath, screenName) { if (!Settings.data.hooks?.enabled) { @@ -130,6 +151,42 @@ Singleton { } } + // Execute performance mode enabled hook + function executePerformanceModeEnabledHook() { + if (!Settings.data.hooks?.enabled) { + return; + } + + const script = Settings.data.hooks?.performanceModeEnabled; + if (!script || script === "") { + return; + } + + try { + Quickshell.execDetached(["sh", "-c", script]); + } catch (e) { + Logger.e("HooksService", `Failed to execute performance mode enabled hook: ${e}`); + } + } + + // Execute performance mode disabled hook + function executePerformanceModeDisabledHook() { + if (!Settings.data.hooks?.enabled) { + return; + } + + const script = Settings.data.hooks?.performanceModeDisabled; + if (!script || script === "") { + return; + } + + try { + Quickshell.execDetached(["sh", "-c", script]); + } catch (e) { + Logger.e("HooksService", `Failed to execute performance mode disabled hook: ${e}`); + } + } + // Initialize the service function init() { Logger.i("HooksService", "Service started"); @@ -139,6 +196,8 @@ Singleton { wasLocked = PanelService.lockScreen.active; lockScreenActiveConnection.target = PanelService.lockScreen; } + // Initialize performance mode state tracking + wasPerformanceModeEnabled = PowerProfileService.noctaliaPerformanceMode; }); } }