Updates to dbus remote for plugins.
This commit is contained in:
@@ -144,6 +144,41 @@ Plugins that expose D-Bus decorators are automatically registered as modules usi
|
|||||||
convention `Plugin_<ModuleName>` (e.g., `Plugin_GameMode`, `Plugin_WindowTitleReader`). Use
|
convention `Plugin_<ModuleName>` (e.g., `Plugin_GameMode`, `Plugin_WindowTitleReader`). Use
|
||||||
`ListModules` to discover available plugin modules at runtime.
|
`ListModules` to discover available plugin modules at runtime.
|
||||||
|
|
||||||
|
#### Plugin_WindowTitleReader
|
||||||
|
|
||||||
|
Controls for the Window Title Reader plugin:
|
||||||
|
|
||||||
|
- Parameterized command: `SetEnabled` (`enabled`: bool)
|
||||||
|
- Runtime getter: `Enabled`
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gdbus call --session --dest org.stormux.Cthulhu.Service \
|
||||||
|
--object-path /org/stormux/Cthulhu/Service/Plugin_WindowTitleReader \
|
||||||
|
--method org.stormux.Cthulhu.Module.ExecuteParameterizedCommand \
|
||||||
|
'SetEnabled' '{"enabled": <true>}' false
|
||||||
|
|
||||||
|
# Check current state
|
||||||
|
gdbus call --session --dest org.stormux.Cthulhu.Service \
|
||||||
|
--object-path /org/stormux/Cthulhu/Service/Plugin_WindowTitleReader \
|
||||||
|
--method org.stormux.Cthulhu.Module.ExecuteRuntimeGetter 'Enabled'
|
||||||
|
```
|
||||||
|
|
||||||
|
Busctl example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
busctl --user call org.stormux.Cthulhu.Service \
|
||||||
|
/org/stormux/Cthulhu/Service/Plugin_WindowTitleReader \
|
||||||
|
org.stormux.Cthulhu.Module ExecuteParameterizedCommand \
|
||||||
|
s a{sv} b 'SetEnabled' 1 enabled b true false
|
||||||
|
|
||||||
|
# Check current state
|
||||||
|
busctl --user call org.stormux.Cthulhu.Service \
|
||||||
|
/org/stormux/Cthulhu/Service/Plugin_WindowTitleReader \
|
||||||
|
org.stormux.Cthulhu.Module ExecuteRuntimeGetter s 'Enabled'
|
||||||
|
```
|
||||||
|
|
||||||
### PluginSystemManager Module
|
### PluginSystemManager Module
|
||||||
|
|
||||||
The `PluginSystemManager` module provides session-only plugin control:
|
The `PluginSystemManager` module provides session-only plugin control:
|
||||||
|
|||||||
@@ -66,6 +66,34 @@ Session-only plugin control (does not persist preferences):
|
|||||||
Plugins that expose D-Bus decorators are automatically registered as modules using the naming
|
Plugins that expose D-Bus decorators are automatically registered as modules using the naming
|
||||||
convention `Plugin_<ModuleName>` (e.g., `Plugin_GameMode`, `Plugin_WindowTitleReader`).
|
convention `Plugin_<ModuleName>` (e.g., `Plugin_GameMode`, `Plugin_WindowTitleReader`).
|
||||||
|
|
||||||
|
#### WindowTitleReader (Plugin_WindowTitleReader)
|
||||||
|
|
||||||
|
- `SetEnabled` (parameterized) -> enabled (bool)
|
||||||
|
- `Enabled` (runtime getter)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gdbus call --session --dest org.stormux.Cthulhu.Service \
|
||||||
|
--object-path /org/stormux/Cthulhu/Service/Plugin_WindowTitleReader \
|
||||||
|
--method org.stormux.Cthulhu.Module.ExecuteParameterizedCommand \
|
||||||
|
'SetEnabled' '{"enabled": <true>}' false
|
||||||
|
```
|
||||||
|
|
||||||
|
Busctl example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
busctl --user call org.stormux.Cthulhu.Service \
|
||||||
|
/org/stormux/Cthulhu/Service/Plugin_WindowTitleReader \
|
||||||
|
org.stormux.Cthulhu.Module ExecuteParameterizedCommand \
|
||||||
|
s a{sv} b 'SetEnabled' 1 enabled b true false
|
||||||
|
```
|
||||||
|
|
||||||
|
# Check current state
|
||||||
|
busctl --user call org.stormux.Cthulhu.Service \
|
||||||
|
/org/stormux/Cthulhu/Service/Plugin_WindowTitleReader \
|
||||||
|
org.stormux.Cthulhu.Module ExecuteRuntimeGetter s 'Enabled'
|
||||||
|
|
||||||
See [README-REMOTE-CONTROLLER.md](README-REMOTE-CONTROLLER.md) for comprehensive D-Bus API documentation and usage examples.
|
See [README-REMOTE-CONTROLLER.md](README-REMOTE-CONTROLLER.md) for comprehensive D-Bus API documentation and usage examples.
|
||||||
|
|
||||||
## Verifying D-Bus Service Status
|
## Verifying D-Bus Service Status
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import logging
|
|||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
|
|
||||||
from cthulhu import debug
|
from cthulhu import debug
|
||||||
|
from cthulhu import dbus_service
|
||||||
from cthulhu.plugin import Plugin, cthulhu_hookimpl
|
from cthulhu.plugin import Plugin, cthulhu_hookimpl
|
||||||
|
|
||||||
xlibAvailable = True
|
xlibAvailable = True
|
||||||
@@ -136,6 +137,52 @@ class WindowTitleReader(Plugin):
|
|||||||
self._present_message("Window title reader unavailable")
|
self._present_message("Window title reader unavailable")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@dbus_service.parameterized_command
|
||||||
|
def set_enabled(
|
||||||
|
self,
|
||||||
|
enabled: bool,
|
||||||
|
notify_user: bool = True
|
||||||
|
) -> bool:
|
||||||
|
"""Enable or disable window title reader tracking."""
|
||||||
|
|
||||||
|
if enabled:
|
||||||
|
if self._enabled:
|
||||||
|
if notify_user:
|
||||||
|
self._present_message("Window title reader on")
|
||||||
|
return True
|
||||||
|
|
||||||
|
if not xlibAvailable:
|
||||||
|
if notify_user:
|
||||||
|
self._present_message("Window title reader unavailable")
|
||||||
|
debug.printMessage(
|
||||||
|
debug.LEVEL_INFO,
|
||||||
|
f"WindowTitleReader: python-xlib unavailable: {xlibImportError}",
|
||||||
|
True,
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
|
if self._start_tracking():
|
||||||
|
if notify_user:
|
||||||
|
self._present_message("Window title reader on")
|
||||||
|
return True
|
||||||
|
|
||||||
|
if notify_user:
|
||||||
|
self._present_message("Window title reader unavailable")
|
||||||
|
return False
|
||||||
|
|
||||||
|
if self._enabled:
|
||||||
|
self._stop_tracking()
|
||||||
|
|
||||||
|
if notify_user:
|
||||||
|
self._present_message("Window title reader off")
|
||||||
|
return True
|
||||||
|
|
||||||
|
@dbus_service.getter
|
||||||
|
def get_enabled(self) -> bool:
|
||||||
|
"""Returns True if the window title reader is enabled."""
|
||||||
|
|
||||||
|
return self._enabled
|
||||||
|
|
||||||
def _present_message(self, messageText):
|
def _present_message(self, messageText):
|
||||||
if not self.app:
|
if not self.app:
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user