From 9ab39c001c988666d0aa20508b5e932d374bdbb0 Mon Sep 17 00:00:00 2001 From: Franz Berger Date: Fri, 26 Aug 2022 09:35:23 +0200 Subject: [PATCH] execute scripts in directories in a fixed order (by file name) --- README.md | 2 ++ autorandr.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c2308b0..531bdc2 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,8 @@ where they will only be executed on changes regarding that specific profile. Instead (or in addition) to these scripts, you can also place as many executable files as you like in subdirectories called `script_name.d` (e.g. `postswitch.d`). +The order of execution of scripts in these directories is by file name, you can +force a certain ordering by naming them `10-wallpaper`, `20-restart-wm`, etc. If a script with the same name occurs multiple times, user configuration takes precedence over system configuration (as specified by the diff --git a/autorandr.py b/autorandr.py index d9b853b..431069a 100755 --- a/autorandr.py +++ b/autorandr.py @@ -1187,7 +1187,7 @@ def exec_scripts(profile_path, script_name, meta_information=None): script_folder = os.path.join(folder, "%s.d" % script_name) if os.access(script_folder, os.R_OK | os.X_OK) and os.path.isdir(script_folder): - for file_name in os.listdir(script_folder): + for file_name in sorted(os.listdir(script_folder)): check_name = "d/%s" % (file_name,) if check_name not in ran_scripts: script = os.path.join(script_folder, file_name) -- 2.39.2