Add script hook `predetect`, executed before invoking xrandr to detect the current config
See bug #61
This commit is contained in:
parent
986e5cfaf6
commit
dfa4525363
|
@ -117,6 +117,11 @@ about it. The same holds for `preswitch`, which is executed before the switch
|
|||
takes place, and `postsave`, which is executed after a profile was
|
||||
stored/altered.
|
||||
|
||||
If you experience issues with xrandr being executed too early after connecting
|
||||
a new monitor, then you can create a script `predetect`, which will be executed
|
||||
before autorandr attempts to run xrandr. Place e.g. `sleep 1` into that file
|
||||
to make autorandr wait a second before running xrandr.
|
||||
|
||||
All scripts can also be placed in any of the `$XDG_CONFIG_DIRS`. In addition to
|
||||
the script names themselves, any executables in subdirectories named
|
||||
`script_name.d` (e.g. `postswitch.d`) are executed as well. In scripts, some of
|
||||
|
@ -125,4 +130,5 @@ The most useful one is `$AUTORANDR_CURRENT_PROFILE`.
|
|||
|
||||
## Changelog
|
||||
|
||||
* *2016-11-15* New script hook, `predetect`
|
||||
* *2016-10-03* Install a desktop file to `/etc/xdg/autostart` by default
|
||||
|
|
10
autorandr.py
10
autorandr.py
|
@ -729,6 +729,8 @@ def exec_scripts(profile_path, script_name, meta_information=None):
|
|||
and system-wide configuration folders, named script_name or residing in
|
||||
subdirectories named script_name.d.
|
||||
|
||||
If profile_path is None, only global scripts will be invoked.
|
||||
|
||||
meta_information is expected to be an dictionary. It will be passed to the block scripts
|
||||
in the environment, as variables called AUTORANDR_<CAPITALIZED_KEY_HERE>.
|
||||
|
||||
|
@ -748,8 +750,11 @@ def exec_scripts(profile_path, script_name, meta_information=None):
|
|||
if not os.path.isdir(user_profile_path):
|
||||
user_profile_path = os.path.join(os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config")), "autorandr")
|
||||
|
||||
for folder in chain((profile_path, os.path.dirname(profile_path), user_profile_path),
|
||||
(os.path.join(x, "autorandr") for x in os.environ.get("XDG_CONFIG_DIRS", "/etc/xdg").split(":"))):
|
||||
candidate_directories = chain((user_profile_path,), (os.path.join(x, "autorandr") for x in os.environ.get("XDG_CONFIG_DIRS", "/etc/xdg").split(":")))
|
||||
if profile_path:
|
||||
candidate_directories = chain((profile_path,), candidate_directories)
|
||||
|
||||
for folder in candidate_directories:
|
||||
|
||||
if script_name not in ran_scripts:
|
||||
script = os.path.join(folder, script_name)
|
||||
|
@ -879,6 +884,7 @@ def main(argv):
|
|||
|
||||
profile_symlinks = { k: v for k, v in profile_symlinks.items() if v in (x[0] for x in virtual_profiles) or v in profiles }
|
||||
|
||||
exec_scripts(None, "predetect")
|
||||
config, modes = parse_xrandr_output()
|
||||
|
||||
if "--fingerprint" in options:
|
||||
|
|
Loading…
Reference in New Issue