Use hook scripts for automation
masterYou can execute scripts during different stages of the profile switching process. Scripts can be placed in the main configuration directory (e.g., ~/.config/autorandr/) or within specific profile subdirectories.
Available hook types:
postswitch: Executed after a mode switch.preswitch: Executed before a mode switch.postsave: Executed after a profile is stored or altered.predetect: Executed beforeautorandrrunsxrandr(useful for adding delays withsleep).
Execution Order and Precedence:
- Profile-specific scripts (e.g.,
~/.config/autorandr/docked/postswitch) have the highest precedence. - User configuration (
~/.config/autorandr/) takes precedence over system configuration (/etc/xdg/autorandr/). - Scripts in
.ddirectories (e.g.,postswitch.d/) are executed by filename (e.g.,10-wallpaper,20-restart-wm).
Environment Variables: Use these variables within your scripts:
AUTORANDR_CURRENT_PROFILE: The profile being activated (Note: duringpreswitch, this reports the upcoming profile).AUTORANDR_CURRENT_PROFILES: List of current profiles.AUTORANDR_PROFILE_FOLDER: Path to the profile folder.AUTORANDR_MONITORS: Monitor information.
Example: Notify via desktop notification:
notify-send -i display "Display profile" "$AUTORANDR_CURRENT_PROFILE"notify-send -i display "Display profile" "$AUTORANDR_CURRENT_PROFILE"