From f921f4a5f80d2cef9ba4f3a0abbddcc391d32009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Aceda=C5=84ski?= Date: Mon, 11 Mar 2019 00:32:15 +0100 Subject: [PATCH] Disable Howdy if lid is closed --- src/config.ini | 3 +++ src/pam.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/config.ini b/src/config.ini index 34d5685..d8a40a9 100644 --- a/src/config.ini +++ b/src/config.ini @@ -15,6 +15,9 @@ suppress_unknown = false # Disable Howdy in remote shells ignore_ssh = true +# Disable Howdy if lid is closed +ignore_closed_lid = true + # Auto dismiss lock screen on confirmation # Will run loginctl unlock-sessions after every auth # Experimental, can behave incorrectly on some systems diff --git a/src/pam.py b/src/pam.py index da98cf1..f539b32 100644 --- a/src/pam.py +++ b/src/pam.py @@ -4,6 +4,7 @@ import subprocess import sys import os +import glob # pam-python is running python 2, so we use the old module here import ConfigParser @@ -25,6 +26,11 @@ def doAuth(pamh): if "SSH_CONNECTION" in os.environ or "SSH_CLIENT" in os.environ or "SSHD_OPTS" in os.environ: sys.exit(0) + # Abort if lid is closed + if config.getboolean("core", "ignore_closed_lid"): + if any('closed' in open(f).read() for f in glob.glob('/proc/acpi/button/lid/*/state')): + sys.exit(0) + # Alert the user that we are doing face detection if config.get("core", "detection_notice") == "true": pamh.conversation(pamh.Message(pamh.PAM_TEXT_INFO, "Attempting face detection"))