fix(linux): Prevent exception if neither USER, LOGNAME nor SUDO_USER set

Closes #9542.

(cherry picked from commit ffa3324be2)
This commit is contained in:
Eberhard Beilharz 2023-09-05 09:17:10 +02:00
parent ed0956fe8d
commit a5a9c24acd
No known key found for this signature in database
GPG key ID: E9140597606020D3

View file

@ -88,6 +88,10 @@ def verify_ibus_daemon(start):
elif not user:
user = os.environ.get('LOGNAME')
if not user:
logging.debug('Neither SUDO_USER, USER nor LOGNAME set. Skipping ibus-daemon check.')
return
try:
ps = subprocess.run(('ps', '--user', user, '-o', 's=', '-o', 'cmd'), stdout=subprocess.PIPE).stdout
ibus_daemons = re.findall('^[^ZT] ibus-daemon .*--xim.*', ps.decode('utf-8'), re.MULTILINE)