From d75a27a310a595a8da7e19c6ab794b6939dd9022 Mon Sep 17 00:00:00 2001 From: utf8please Date: Sun, 8 May 2022 22:10:40 -0700 Subject: [PATCH] Allow overriding min UID with AUTORANDR_UID_MIN env var. --- autorandr.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/autorandr.py b/autorandr.py index b7940bc..e7b8702 100755 --- a/autorandr.py +++ b/autorandr.py @@ -1198,6 +1198,16 @@ def dispatch_call_to_sessions(argv): sys.exit(1) os.waitpid(child_pid, 0) + # The following line assumes that user accounts start at 1000 and that no + # one works using the root or another system account. This is rather + # restrictive, but de facto default. If this breaks your use case, set the + # env var AUTORANDR_UID_MIN as appropriate. (Alternatives would be to use + # the UID_MIN from /etc/login.defs or FIRST_UID from /etc/adduser.conf; but + # effectively, both values aren't binding in any way.) + uid_min = 1000 + if 'AUTORANDR_UID_MIN' in os.environ: + uid_min = int(os.environ['AUTORANDR_UID_MIN']) + for directory in os.listdir("/proc"): directory = os.path.join("/proc/", directory) if not os.path.isdir(directory): @@ -1207,13 +1217,7 @@ def dispatch_call_to_sessions(argv): continue uid = os.stat(environ_file).st_uid - # The following line assumes that user accounts start at 1000 and that - # no one works using the root or another system account. This is rather - # restrictive, but de facto default. Alternatives would be to use the - # UID_MIN from /etc/login.defs or FIRST_UID from /etc/adduser.conf; - # but effectively, both values aren't binding in any way. - # If this breaks your use case, please file a bug on Github. - if uid < 1000: + if uid < uid_min: continue process_environ = {} -- 2.39.2