X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=autorandr.py;h=aa4b8f2483169ac1c38175c7a630c21e462291f3;hb=95fcdad8c1fef2adb2f3d2331412c9e551fb1b19;hp=84fb3b356e86aee9d00ab601f1b381461a9c0df5;hpb=5bf6790cdda4c8e25b964d943dcf878df99cbd05;p=deb_pkgs%2Fautorandr.git diff --git a/autorandr.py b/autorandr.py index 84fb3b3..aa4b8f2 100755 --- a/autorandr.py +++ b/autorandr.py @@ -798,7 +798,14 @@ def dispatch_call_to_sessions(argv): if not os.path.isfile(environ_file): continue uid = os.stat(environ_file).st_uid - if uid == 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. 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: continue process_environ = {} @@ -1033,7 +1040,7 @@ def main(argv): sys.exit(0) -if __name__ == '__main__': +def exception_handled_main(argv=sys.argv): try: main(sys.argv) except AutorandrException as e: @@ -1046,3 +1053,6 @@ if __name__ == '__main__': print("Unhandled exception ({0}). Please report this as a bug at https://github.com/phillipberndt/autorandr/issues.".format(e), file=sys.stderr) raise + +if __name__ == '__main__': + exception_handled_main()