Not attempting to call xmodmap -pke as the service

pull/265/head
sezanzeb 3 years ago
parent 5588cbf3c5
commit 9037afe0f7

@ -90,6 +90,10 @@ class SystemMapping:
"""Get a mapping of all available names to their keycodes.""" """Get a mapping of all available names to their keycodes."""
logger.debug("Gathering available keycodes") logger.debug("Gathering available keycodes")
self.clear() self.clear()
if not is_service():
# xmodmap is only available from within the login session.
# The service that runs via systemd can't use this.
xmodmap_dict = {} xmodmap_dict = {}
try: try:
xmodmap = subprocess.check_output( xmodmap = subprocess.check_output(
@ -100,11 +104,13 @@ class SystemMapping:
xmodmap_dict = self._find_legit_mappings() xmodmap_dict = self._find_legit_mappings()
if len(xmodmap_dict) == 0: if len(xmodmap_dict) == 0:
logger.info("`xmodmap -pke` did not yield any symbol") logger.info("`xmodmap -pke` did not yield any symbol")
except (subprocess.CalledProcessError, FileNotFoundError): except FileNotFoundError:
# might be within a tty logger.info(
logger.info("Optional `xmodmap` command not found. This is not critical.") "Optional `xmodmap` command not found. This is not critical."
)
except subprocess.CalledProcessError as e:
logger.error('Call to `xmodmap -pke` failed with "%s"', e)
if not is_service():
# Clients usually take care of that, don't let the service do funny things. # Clients usually take care of that, don't let the service do funny things.
# Write this stuff into the input-remapper config directory, because # Write this stuff into the input-remapper config directory, because
# the systemd service won't know the user sessions xmodmap. # the systemd service won't know the user sessions xmodmap.

Loading…
Cancel
Save