mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Hooks: add noctaliaPerformance hooks
This commit is contained in:
@@ -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.",
|
||||
|
||||
@@ -1687,7 +1687,7 @@
|
||||
"label": "Hook command information"
|
||||
},
|
||||
"parameters": {
|
||||
"description": "• Wallpaper hook: $1 = wallpaper path, $2 = screen name<br>• Theme toggle hook: $1 = true/false (Dark Mode state)<br>• Screen lock/unlock hooks: No parameters",
|
||||
"description": "• Wallpaper hook: $1 = wallpaper path, $2 = screen name<br>• Theme toggle hook: $1 = true/false (Dark Mode state)<br>• Screen lock/unlock hooks: No parameters<br>• 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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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": "すべてのフックコマンドの有効・無効を切り替えます。",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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": "Включить или отключить все команды хуков.",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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": "Увімкнути або вимкнути всі команди хуків.",
|
||||
|
||||
@@ -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": "启用或禁用所有钩子命令。",
|
||||
|
||||
@@ -411,7 +411,9 @@
|
||||
"wallpaperChange": "",
|
||||
"darkModeChange": "",
|
||||
"screenLock": "",
|
||||
"screenUnlock": ""
|
||||
"screenUnlock": "",
|
||||
"performanceModeEnabled": "",
|
||||
"performanceModeDisabled": ""
|
||||
},
|
||||
"desktopWidgets": {
|
||||
"enabled": false,
|
||||
|
||||
@@ -619,6 +619,8 @@ Singleton {
|
||||
property string darkModeChange: ""
|
||||
property string screenLock: ""
|
||||
property string screenUnlock: ""
|
||||
property string performanceModeEnabled: ""
|
||||
property string performanceModeDisabled: ""
|
||||
}
|
||||
|
||||
// desktop widgets
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user