Not attempting to call xmodmap -pke as the service

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

@ -90,21 +90,27 @@ class SystemMapping:
"""Get a mapping of all available names to their keycodes."""
logger.debug("Gathering available keycodes")
self.clear()
xmodmap_dict = {}
try:
xmodmap = subprocess.check_output(
["xmodmap", "-pke"], stderr=subprocess.STDOUT
).decode()
xmodmap = xmodmap
self._xmodmap = re.findall(r"(\d+) = (.+)\n", xmodmap + "\n")
xmodmap_dict = self._find_legit_mappings()
if len(xmodmap_dict) == 0:
logger.info("`xmodmap -pke` did not yield any symbol")
except (subprocess.CalledProcessError, FileNotFoundError):
# might be within a tty
logger.info("Optional `xmodmap` command not found. This is not critical.")
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 = {}
try:
xmodmap = subprocess.check_output(
["xmodmap", "-pke"], stderr=subprocess.STDOUT
).decode()
xmodmap = xmodmap
self._xmodmap = re.findall(r"(\d+) = (.+)\n", xmodmap + "\n")
xmodmap_dict = self._find_legit_mappings()
if len(xmodmap_dict) == 0:
logger.info("`xmodmap -pke` did not yield any symbol")
except FileNotFoundError:
logger.info(
"Optional `xmodmap` command not found. This is not critical."
)
except subprocess.CalledProcessError as e:
logger.error('Call to `xmodmap -pke` failed with "%s"', e)
# Clients usually take care of that, don't let the service do funny things.
# Write this stuff into the input-remapper config directory, because
# the systemd service won't know the user sessions xmodmap.
@ -114,8 +120,8 @@ class SystemMapping:
logger.debug('Writing "%s"', path)
json.dump(xmodmap_dict, file, indent=4)
for name, code in xmodmap_dict.items():
self._set(name, code)
for name, code in xmodmap_dict.items():
self._set(name, code)
for name, ecode in evdev.ecodes.ecodes.items():
if name.startswith("KEY") or name.startswith("BTN"):

Loading…
Cancel
Save