From: Brice Waegeneire <brice.wge@gmail.com>
Date: Sun, 29 Apr 2018 20:05:24 +0000 (+0200)
Subject: add monitor list to hooks by environment variables
X-Git-Tag: 1.6~11
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=16ff46476517fcf2773b2cb781163d50470b7533;p=deb_pkgs%2Fautorandr.git

add monitor list to hooks by environment variables
---

diff --git a/README.md b/README.md
index 7518128..4b25a91 100644
--- a/README.md
+++ b/README.md
@@ -38,6 +38,7 @@ Contributors to this version of autorandr are:
 * Adrián López
 * andersonjacob
 * Alexander Wirt
+* Brice Waegeneire
 * Chris Dunder
 * Christoph Gysin
 * Daniel Hahler
@@ -189,7 +190,11 @@ If you switch back from `docked` to `mobile`, `~/.config/autorandr/postswitch`
 is executed instead of the `mobile` specific `postswitch`.
 
 In these scripts, some of autorandr's state is exposed as environment variables
-prefixed with `AUTORANDR_`. The most useful one is `$AUTORANDR_CURRENT_PROFILE`.
+prefixed with `AUTORANDR_`, such as:
+- `AUTORANDR_CURRENT_PROFILE`
+- `AUTORANDR_CURRENT_PROFILES`
+- `AUTORANDR_PROFILE_FOLDER`
+- `AUTORANDR_MONITORS`
 
 If you experience issues with xrandr being executed too early after connecting
 a new monitor, then you can use a `predetect` script to delay the execution.
diff --git a/autorandr.py b/autorandr.py
index 57943f7..391f356 100755
--- a/autorandr.py
+++ b/autorandr.py
@@ -1161,7 +1161,11 @@ def main(argv):
         try:
             profile_folder = os.path.join(profile_path, options["--save"])
             save_configuration(profile_folder, config)
-            exec_scripts(profile_folder, "postsave", {"CURRENT_PROFILE": options["--save"], "PROFILE_FOLDER": profile_folder})
+            exec_scripts(profile_folder, "postsave", {
+                "CURRENT_PROFILE": options["--save"],
+                "PROFILE_FOLDER": profile_folder,
+                "MONITORS": ":".join(load_config.keys()),
+            })
         except Exception as e:
             raise AutorandrException("Failed to save current configuration as profile '%s'" % (options["--save"],), e)
         print("Saved current configuration as profile '%s'" % options["--save"])
@@ -1281,6 +1285,7 @@ def main(argv):
                 script_metadata = {
                     "CURRENT_PROFILE": load_profile,
                     "PROFILE_FOLDER": scripts_path,
+                    "MONITORS": ":".join(load_config.keys()),
                 }
                 exec_scripts(scripts_path, "preswitch", script_metadata)
                 if "--debug" in options: