try: subprocess.check_call(('dnf', 'info', 'xguest'), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) except (FileNotFoundError, subprocess.CalledProcessError): return None return any(l for l in open('/etc/passwd') if re.match(r'xguest:', l)) # Make sure xinit_checker is last. Just because somebody is running xinit # doesn't mean that they aren't _also_ running a display manager that has a # guest session, so xinit_checker should only be used as a last resort. checkers = (lightdm_checker, xinit_checker, gdm3_checker, xguest_checker) for checker in checkers: results = checker() if results is not None: break if results is None: results = 'unknown' results = ({ 'enabled': results } if results != 'unknown' or find_x_users() else None) results = cached_data('guest_session', results, add_timestamp=True, raise_exception=False) print(json.dumps(results))
except: continue if not nowlocker: nowlocker = locker if _time and valid_lockers_re.search(locker) and \ valid_lockers_re.search(nowlocker): return {'enabled': True, 'delay': _time} return None display_checkers = (gnome_xscreensaver_status, xautolock_status) user_displays = find_x_users() results = {} for user, display in user_displays: for checker in display_checkers: status = checker(user, display) if status: status['user'] = user results[user] = status break else: results[user] = {'user': user, 'enabled': 'unknown'} results = {'users': list(results.values())} if user_displays else None results = cached_data('screenlock', results, add_timestamp=True, raise_exception=False) print(json.dumps(results))