fix(ibus): skip IBus setup when daemon not running (#251)
On desktop environments like KDE Plasma, the IBus daemon is not started by default. Previously, Vocalinux would attempt to register its IBus engine anyway, which would fail and (before #240) not properly fall back to alternatives. This change: - Adds is_ibus_daemon_running() to check if ibus-daemon is running - Skips IBus setup entirely when daemon isn't running - Logs an informative message explaining why IBus is skipped - Falls back to ydotool/xdotool immediately (no wasted time) Fixes #250 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: AntoineMontane <monnet.antoine@gmail.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
AntoineMontane
Claude Opus 4.5
parent
c8142151eb
commit
0c5e641060
@@ -111,6 +111,28 @@ def is_ibus_available() -> bool:
|
||||
return IBUS_AVAILABLE
|
||||
|
||||
|
||||
def is_ibus_daemon_running() -> bool:
|
||||
"""
|
||||
Check if the IBus daemon (ibus-daemon) is currently running.
|
||||
|
||||
This is important because on some desktop environments (e.g., Fedora KDE),
|
||||
the IBus daemon is not started by default. Attempting to set up IBus
|
||||
when the daemon isn't running will fail.
|
||||
|
||||
Returns:
|
||||
True if ibus-daemon is running, False otherwise
|
||||
"""
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["pgrep", "-x", "ibus-daemon"],
|
||||
capture_output=True,
|
||||
timeout=2,
|
||||
)
|
||||
return result.returncode == 0
|
||||
except (subprocess.SubprocessError, FileNotFoundError):
|
||||
return False
|
||||
|
||||
|
||||
def _get_expected_component_xml() -> str:
|
||||
"""Generate the expected component XML content for the current installation."""
|
||||
engine_script = Path(__file__).resolve()
|
||||
|
||||
@@ -16,6 +16,7 @@ from typing import Optional # noqa: F401
|
||||
from .ibus_engine import (
|
||||
IBusTextInjector,
|
||||
is_ibus_available,
|
||||
is_ibus_daemon_running,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -134,18 +135,26 @@ class TextInjector:
|
||||
# Prefer IBus on both X11 and Wayland - it sends Unicode directly,
|
||||
# bypassing keyboard layout issues entirely
|
||||
if is_ibus_available():
|
||||
try:
|
||||
self._ibus_injector = IBusTextInjector(auto_activate=True)
|
||||
if self.environment == DesktopEnvironment.X11:
|
||||
self.environment = DesktopEnvironment.X11_IBUS
|
||||
else:
|
||||
self.environment = DesktopEnvironment.WAYLAND_IBUS
|
||||
# Check if ibus-daemon is running before attempting setup
|
||||
if not is_ibus_daemon_running():
|
||||
logger.info(
|
||||
f"Using IBus for {self.environment.value} text injection (best compatibility)"
|
||||
"IBus daemon not running. This is normal on some desktop environments "
|
||||
"(e.g., KDE Plasma). Using alternative text injection method. "
|
||||
"For IBus setup, see: https://github.com/jatinkrmalik/vocalinux/wiki/IBus-Setup"
|
||||
)
|
||||
return
|
||||
except Exception as e:
|
||||
logger.warning(f"IBus initialization failed: {e}, trying alternatives")
|
||||
else:
|
||||
try:
|
||||
self._ibus_injector = IBusTextInjector(auto_activate=True)
|
||||
if self.environment == DesktopEnvironment.X11:
|
||||
self.environment = DesktopEnvironment.X11_IBUS
|
||||
else:
|
||||
self.environment = DesktopEnvironment.WAYLAND_IBUS
|
||||
logger.info(
|
||||
f"Using IBus for {self.environment.value} text injection (best compatibility)"
|
||||
)
|
||||
return
|
||||
except Exception as e:
|
||||
logger.warning(f"IBus initialization failed: {e}, trying alternatives")
|
||||
|
||||
if self.environment == DesktopEnvironment.X11:
|
||||
# Check for xdotool
|
||||
|
||||
Reference in New Issue
Block a user