Example #1
0
                    args.pop(0)
                if _time and locker and nowlocker:
                    break
        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,
    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))
Example #3
0
                    args.pop(0)
                else:
                    args.pop(0)
        except Exception:
            continue

        for timer in timers:
            if valid_lockers_re.search(timer['locker']):
                return {'enabled': True, 'delay': timer['time']}
    return None


display_checkers = (gnome_xscreensaver_status, xautolock_status,
                    xidlehook_status, swayidle_status)

user_displays = find_x_users() + find_greetd_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',