pax_global_header00006660000000000000000000000064144450562300014515gustar00rootroot0000000000000052 comment=d0f64bf215396f73a3b9fee1155f589ae5ab0d9c autorandr-1.14/000077500000000000000000000000001444505623000134415ustar00rootroot00000000000000autorandr-1.14/.flake8000066400000000000000000000000551444505623000146140ustar00rootroot00000000000000[flake8] ignore = E722 max-line-length = 130 autorandr-1.14/.gitignore000066400000000000000000000000071444505623000154260ustar00rootroot00000000000000.*.swp autorandr-1.14/Makefile000066400000000000000000000167501444505623000151120ustar00rootroot00000000000000DESTDIR=/ PREFIX=/usr/ RPM_SPEC=contrib/packaging/rpm/autorandr.spec CFLAGS?=-O2 -Wall CLEANUP_FILES= .PHONY: all install uninstall autorandr bash_completion autostart_config pmutils systemd udev all: @echo "Call \"make install\" to install this program." @echo "Call \"make uninstall\" to remove this program." @echo @echo "The following components were autodetected and will be installed:" @echo " "$(DEFAULT_TARGETS) @echo @echo "The following locations have been detected (from pkg-config):" @echo " - BASH_COMPLETIONS_DIR: $(BASH_COMPLETIONS_DIR)" @echo " - SYSTEMD_UNIT_DIR: $(SYSTEMD_UNIT_DIR)" @echo " - UDEV_RULES_DIR: $(UDEV_RULES_DIR)" @echo " - PM_SLEEPHOOKS_DIR: $(PM_SLEEPHOOKS_DIR)" @echo @echo "You can use the TARGETS variable to override this, but need to set" @echo "the SYSTEMD_UNIT_DIR, PM_SLEEPHOOKS_DIR and UDEV_RULES_DIR variables" @echo "in case they were not detected correctly." @echo @echo 'E.g. "make install TARGETS='autorandr pmutils' PM_UTILS_DIR=/etc/pm/sleep.d".' @echo @echo "An additional TARGETS variable \"launcher\" is available. This" @echo "installs a launcher called \"autorandr_launcher\". The launcher" @echo "is able to be run by the user and calls autorandr automatically" @echo "without using udev rules. The launcher is an alternative to the" @echo "udev/systemd setup that is more stable for some users." @echo @echo "The following additional targets are available:" @echo @echo " make deb creates a Debian package" @echo " make rpm creates a RPM package" # Rules for autorandr itself DEFAULT_TARGETS=autorandr install_autorandr: mkdir -p ${DESTDIR}${PREFIX}/bin install -m 755 autorandr.py ${DESTDIR}${PREFIX}/bin/autorandr uninstall_autorandr: rm -f ${DESTDIR}${PREFIX}/bin/autorandr # Rules for bash-completion BASH_COMPLETIONS_DIR:=$(shell pkg-config --variable=completionsdir bash-completion 2>/dev/null) ifneq (,$(BASH_COMPLETIONS_DIR)) DEFAULT_TARGETS+=bash_completion endif install_bash_completion: mkdir -p ${DESTDIR}/${BASH_COMPLETIONS_DIR} install -m 644 contrib/bash_completion/autorandr ${DESTDIR}/${BASH_COMPLETIONS_DIR}/autorandr uninstall_bash_completion: rm -f ${DESTDIR}/${BASH_COMPLETIONS_DIR}/autorandr # Rules for autostart config XDG_AUTOSTART_DIR=/etc/xdg/autostart DEFAULT_TARGETS+=autostart_config install_autostart_config: mkdir -p ${DESTDIR}/${XDG_AUTOSTART_DIR} install -m 644 contrib/etc/xdg/autostart/autorandr.desktop ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr.desktop # KDE-specific autostart (workaround for https://github.com/systemd/systemd/issues/18791) install -m 644 contrib/etc/xdg/autostart/autorandr.desktop ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr-kde.desktop desktop-file-edit --remove-key=X-GNOME-Autostart-Phase --add-only-show-in=KDE ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr-kde.desktop ifneq ($(PREFIX),/usr/) sed -i -re 's#/usr/bin/autorandr#$(subst #,\#,${PREFIX})/bin/autorandr#g' ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr.desktop sed -i -re 's#/usr/bin/autorandr#$(subst #,\#,${PREFIX})/bin/autorandr#g' ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr-kde.desktop endif uninstall_autostart_config: rm -f ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr.desktop rm -f ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr-kde.desktop # Rules for systemd SYSTEMD_UNIT_DIR:=$(shell pkg-config --variable=systemdsystemunitdir systemd 2>/dev/null) ifneq (,$(SYSTEMD_UNIT_DIR)) DEFAULT_TARGETS+=systemd endif install_systemd: $(if $(SYSTEMD_UNIT_DIR),,$(error SYSTEMD_UNIT_DIR is not defined)) mkdir -p ${DESTDIR}/${SYSTEMD_UNIT_DIR} install -m 644 contrib/systemd/autorandr.service ${DESTDIR}/${SYSTEMD_UNIT_DIR}/autorandr.service install -m 644 contrib/systemd/autorandr-lid-listener.service ${DESTDIR}/${SYSTEMD_UNIT_DIR}/autorandr-lid-listener.service ifneq ($(PREFIX),/usr/) sed -i -re 's#/usr/bin/autorandr#$(subst #,\#,${PREFIX})/bin/autorandr#g' ${DESTDIR}/${SYSTEMD_UNIT_DIR}/autorandr.service endif @echo @echo "To activate the systemd units, run this command as root:" @echo " systemctl daemon-reload" @echo " systemctl enable autorandr.service" @echo " systemctl enable autorandr-lid-listener.service" @echo uninstall_systemd: $(if $(SYSTEMD_UNIT_DIR),,$(error SYSTEMD_UNIT_DIR is not defined)) rm -f ${DESTDIR}/${SYSTEMD_UNIT_DIR}/autorandr.service rm -f ${DESTDIR}/${SYSTEMD_UNIT_DIR}/autorandr-lid-listener.service # Rules for pmutils PM_SLEEPHOOKS_DIR:=$(shell pkg-config --variable=pm_sleephooks pm-utils 2>/dev/null) ifneq (,$(PM_SLEEPHOOKS_DIR)) ifeq (,$(SYSTEMD_UNIT_DIR)) DEFAULT_TARGETS+=pmutils endif endif install_pmutils: $(if $(PM_SLEEPHOOKS_DIR),,$(error PM_SLEEPHOOKS_DIR is not defined)) mkdir -p ${DESTDIR}/${PM_SLEEPHOOKS_DIR} install -m 755 contrib/pm-utils/40autorandr ${DESTDIR}/${PM_SLEEPHOOKS_DIR}/40autorandr ifneq ($(PREFIX),/usr/) sed -i -re 's#/usr/bin/autorandr#$(subst #,\#,${PREFIX})/bin/autorandr#g' ${DESTDIR}/${PM_SLEEPHOOKS_DIR}/40autorandr endif uninstall_pmutils: $(if $(PM_SLEEPHOOKS_DIR),,$(error PM_SLEEPHOOKS_DIR is not defined)) rm -f ${DESTDIR}/${PM_SLEEPHOOKS_DIR}/40autorandr # Rules for udev UDEV_RULES_DIR:=$(shell pkg-config --variable=udevdir udev 2>/dev/null)/rules.d ifneq (/rules.d,$(UDEV_RULES_DIR)) DEFAULT_TARGETS+=udev endif install_udev: $(if $(UDEV_RULES_DIR),,$(error UDEV_RULES_DIR is not defined)) mkdir -p ${DESTDIR}/${UDEV_RULES_DIR}/ echo 'ACTION=="change", SUBSYSTEM=="drm", RUN+="$(if $(findstring systemd, $(DEFAULT_TARGETS)),/bin/systemctl start --no-block autorandr.service,${PREFIX}/bin/autorandr --batch --change --default default)"' > ${DESTDIR}/${UDEV_RULES_DIR}/40-monitor-hotplug.rules @echo @echo "To activate the udev rules, run this command as root:" @echo " udevadm control --reload-rules" @echo uninstall_udev: $(if $(UDEV_RULES_DIR),,$(error UDEV_RULES_DIR is not defined)) rm -f ${DESTDIR}/${UDEV_RULES_DIR}/40-monitor-hotplug.rules # Rules for manpage MANDIR:=${PREFIX}/share/man/man1 DEFAULT_TARGETS+=manpage install_manpage: mkdir -p ${DESTDIR}/${MANDIR} cp autorandr.1 ${DESTDIR}/${MANDIR} uninstall_manpage: rm -f ${DESTDIR}/${MANDIR}/autorandr.1 # Rules for launcher LAUNCHER_LDLIBS=$(shell pkg-config --libs pkg-config xcb xcb-randr 2>/dev/null) ifneq (,$(LAUNCHER_LDLIBS)) CLEANUP_FILES+=contrib/autorandr_launcher/autorandr-launcher LAUNCHER_CFLAGS=$(shell pkg-config --cflags pkg-config xcb xcb-randr 2>/dev/null) DEF_AUTORANDR_PATH="-DAUTORANDR_PATH=\"${DESTDIR}${PREFIX}/bin/autorandr\"" contrib/autorandr_launcher/autorandr-launcher: contrib/autorandr_launcher/autorandr_launcher.c $(CC) $(CFLAGS) $(LAUNCHER_CFLAGS) $(DEF_AUTORANDR_PATH) -o $@ $+ $(LDFLAGS) $(LAUNCHER_LDLIBS) $(LDLIBS) install_launcher: contrib/autorandr_launcher/autorandr-launcher mkdir -p ${DESTDIR}${PREFIX}/bin install -m 755 contrib/autorandr_launcher/autorandr-launcher ${DESTDIR}${PREFIX}/bin/autorandr-launcher mkdir -p ${DESTDIR}/${XDG_AUTOSTART_DIR} install -m 644 contrib/etc/xdg/autostart/autorandr-launcher.desktop ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr-launcher.desktop ifneq ($(PREFIX),/usr/) sed -i -re 's#/usr/bin/autorandr-launcher#$(subst #,\#,${PREFIX})/bin/autorandr-launcher#g' ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr-launcher.desktop endif endif uninstall_launcher: rm -f ${DESTDIR}${PREFIX}/bin/autorandr-launcher rm -f ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr-launcher.desktop TARGETS=$(DEFAULT_TARGETS) install: $(patsubst %,install_%,$(TARGETS)) uninstall: $(patsubst %,uninstall_%,$(TARGETS)) deb: ./contrib/packaging/debian/make_deb.sh rpm: spectool -g -R $(RPM_SPEC) rpmbuild -ba $(RPM_SPEC) clean: rm -f $(CLEANUP_FILES) autorandr-1.14/README.md000066400000000000000000000347751444505623000147400ustar00rootroot00000000000000# autorandr Automatically select a display configuration based on connected devices ## Branch information This is a compatible Python rewrite of [wertarbyte/autorandr](https://github.com/wertarbyte/autorandr). Contributions for bash-completion, fd.o/XDG autostart, Nitrogen, pm-utils, and systemd can be found under [contrib](contrib/). The original [wertarbyte/autorandr](https://github.com/wertarbyte/autorandr) tree is unmaintained, with lots of open pull requests and issues. I forked it and merged what I thought were the most important changes. If you are searching for that version, see the [`legacy` branch](https://github.com/phillipberndt/autorandr/tree/legacy). Note that the Python version is better suited for non-standard configurations, like if you use `--transform` or `--reflect`. If you use `auto-disper`, you have to use the bash version, as there is no disper support in the Python version (yet). Both versions use a compatible configuration file format, so you can, to some extent, switch between them. I will maintain the `legacy` branch until @wertarbyte finds the time to maintain his branch again. If you are interested in why there are two versions around, see [#7](https://github.com/phillipberndt/autorandr/issues/7), [#8](https://github.com/phillipberndt/autorandr/issues/8) and especially [#12](https://github.com/phillipberndt/autorandr/issues/12) if you are unhappy with this version and would like to contribute to the bash version. ## License information and authors autorandr is available under the terms of the GNU General Public License (version 3). Contributors to this version of autorandr are: * Adrián López * andersonjacob * Alexander Lochmann * Alexander Wirt * Brice Waegeneire * Chris Dunder * Christoph Gysin * Christophe-Marie Duquesne * Daniel Hahler * Maciej Sitarz * Mathias Svensson * Matthew R Johnson * Nazar Mokrynskyi * Phillip Berndt * Rasmus Wriedt Larsen * Sam Coulter * Simon Wydooghe * Stefan Tomanek * stormc * tachylatus * Timo Bingmann * Timo Kaufmann * Tomasz Bogdal * Victor Häggqvist * Jan-Oliver Kaiser * Alexandre Viau ## Installation/removal You can use the `autorandr.py` script as a stand-alone binary. If you'd like to install it as a system-wide application, there is a Makefile included that also places some configuration files in appropriate directories such that autorandr is invoked automatically when a monitor is connected or removed, the system wakes up from suspend, or a user logs into an X11 session. Run `make install` as root to install it. If you prefer to have a system wide install managed by your package manager, you can * Use the [official Arch package](https://www.archlinux.org/packages/community/any/autorandr/). * Use the [official Debian package](https://packages.debian.org/sid/x11/autorandr) on sid * Use the [FreeBSD Ports Collection](https://www.freshports.org/x11/autorandr/) on FreeBSD. * Use the [official Gentoo package](https://packages.gentoo.org/packages/x11-misc/autorandr). * Use the [nix package](https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/misc/autorandr.nix) on NixOS. * Use the [guix package](https://git.savannah.gnu.org/cgit/guix.git/log/gnu/packages/xdisorg.scm?qt=grep&q=autorandr) on Guix. * Use the [SlackBuild](https://slackbuilds.org/repository/14.2/desktop/autorandr/) on Slackware. * Use the automated nightlies generated by the [openSUSE build service](https://build.opensuse.org/package/show/home:phillipberndt/autorandr) for various distributions (RPM and DEB based). * Use the [X binary package system](https://wiki.voidlinux.eu/XBPS)' on Void Linux * Build a .deb-file from the source tree using `make deb`. * Build a .rpm-file from the source tree using `make rpm`. We appreciate packaging scripts for other distributions, please file a pull request if you write one. If you prefer `pip` over your package manager, you can install autorandr with: sudo pip install "git+http://github.com/phillipberndt/autorandr#egg=autorandr" or simply sudo pip install autorandr if you prefer to use a stable version. ## How to use Save your current display configuration and setup with: autorandr --save mobile Connect an additional display, configure your setup and save it: autorandr --save docked Now autorandr can detect which hardware setup is active: $ autorandr mobile docked (detected) To automatically reload your setup: $ autorandr --change To manually load a profile: $ autorandr --load or simply: $ autorandr autorandr tries to avoid reloading an identical configuration. To force the (re)configuration: $ autorandr --load --force To prevent a profile from being loaded, place a script call _block_ in its directory. The script is evaluated before the screen setup is inspected, and in case of it returning a value of 0 the profile is skipped. This can be used to query the status of a docking station you are about to leave. If no suitable profile can be identified, the current configuration is kept. To change this behaviour and switch to a fallback configuration, specify `--default `. The system-wide installation of autorandr by default calls autorandr with a parameter `--default default`. There are three special, virtual configurations called `horizontal`, `vertical` and `common`. They automatically generate a configuration that incorporates all screens connected to the computer. You can symlink `default` to one of these names in your configuration directory to have autorandr use any of them as the default configuration without you having to change the system-wide configuration. You can store default values for any option in an INI-file located at `~/.config/autorandr/settings.ini`. In a `config` section, you may place any default values in the form `option-name=option-argument`. A common and effective use of this is to specify default `skip-options`, for instance skipping the `gamma` setting if using [`redshift`](https://github.com/jonls/redshift) as a daemon. To implement the equivalent of `--skip-options gamma`, your `settings.ini` file should look like this: ``` [config] skip-options=gamma ``` ## Advanced usage ### Hook scripts Three more scripts can be placed in the configuration directory (as defined by the [XDG spec](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html), usually `~/.config/autorandr` or `~/.autorandr` if you have an old installation for user configuration and `/etc/xdg/autorandr` for system wide configuration): - `postswitch` is executed *after* a mode switch has taken place. This can be used to notify window managers or other applications about the switch. - `preswitch` is executed *before* a mode switch takes place. - `postsave` is executed after a profile was stored or altered. - `predetect` is executed before autorandr attempts to run xrandr. These scripts must be executable and can be placed directly in the configuration directory, where they will always be executed, or in the profile subdirectories, 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 [XDG spec](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)) and profile configuration over general configuration. As a concrete example, suppose you have the files - `/etc/xdg/autorandr/postswitch` - `~/.config/autorandr/postswitch` - `~/.config/autorandr/postswitch.d/notify-herbstluftwm` - `~/.config/autorandr/docked/postswitch` and switch from `mobile` to `docked`. Then `~/.config/autorandr/docked/postswitch` is executed, since the profile specific configuration takes precedence, and `~/.config/autorandr/postswitch.d/notify-herbstluftwm` is executed, since it has a unique name. If you switch back from `docked` to `mobile`, `~/.config/autorandr/postswitch` is executed instead of the `docked` specific `postswitch`. 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. Write e.g. `sleep 1` into that file to make autorandr wait a second before running `xrandr`. #### Variables Some of autorandr's state is exposed as environment variables prefixed with `AUTORANDR_`, such as: - `AUTORANDR_CURRENT_PROFILE` - `AUTORANDR_CURRENT_PROFILES` - `AUTORANDR_PROFILE_FOLDER` - `AUTORANDR_MONITORS` with the intention that they can be used within the hook scripts. For instance, you might display which profile has just been activated by including the following in a `postswitch` script: ```sh notify-send -i display "Display profile" "$AUTORANDR_CURRENT_PROFILE" ``` The one kink is that during `preswitch`, `AUTORANDR_CURRENT_PROFILE` is reporting the *upcoming* profile rather than the *current* one. ### Wildcard EDID matching The EDID strings in the `~/.config/autorandr/*/setup` files may contain an asterisk to enable wildcard matching: Such EDIDs are matched against connected monitors using the usual file name globbing rules. This can be used to create profiles matching multiple (or any) monitors. ### udev triggers with NVidia cards In order for `udev` to detect `drm` events from the native NVidia driver, the kernel parameter `nvidia-drm.modeset` must be set to 1. For example, add a file `/etc/modprobe.d/nvidia-drm-modeset.conf`: ``` options nvidia_drm modeset=1 ``` ### Wayland Before running autorandr will check the environment for the `WAYLAND_DISPLAY` variable to check if the program is running in a Wayland session. This is to avoid issues between usage of xrandr in Wayland environments. If you need to run autorandr in a Wayland environment, one workaround is to unset the `WAYLAND_DISPLAY` variable before running the program, such as: ``` WAYLAND_DISPLAY= autorandr ``` ## Changelog **autorandr 1.14** * *2023-06-22* Direct --match-edid renaming of output messages to stderr * *2023-06-22* Add Wayland awareness * *2023-06-22* Various minor auxiliary tooling bug fixes, see git-log **autorandr 1.13.3** * *2023-01-24* Revert udev rule to rely on "change" event (see #324) **autorandr 1.13.2** * *2023-01-23* Fix autostart in KDE (see #320) * *2023-01-23* Match add/remove rather than change in udev rule (see #321) * *2023-01-23* Fix wildcard use in EDIDs (see #322) * *2023-01-23* Do a final xrandr call to set the frame buffer size (see #319) **autorandr 1.13.1** * *2023-01-16* Fix bug with Version comparison **autorandr 1.13** * *2023-01-15* Add reversed horizontal/vertical profiles * *2023-01-15* Fix distutils deprecation warning * *2023-01-15* Print error when user script fails * *2022-12-01* Support `--skip-options set` to skip setting properties **autorandr 1.12.1** * *2021-12-22* Fix `--match-edid` (see #273) **autorandr 1.12** * *2021-12-16* Switch default interpreter to Python 3 * *2021-12-16* Add `--list` to list all profiles * *2021-12-16* Add `--cycle` to cycle all detected profiles * *2021-12-16* Store display properties (see #204) **autorandr 1.11** * *2020-05-23* Handle empty sys.executable * *2020-06-08* Fix Python 2 compatibility * *2020-10-06* Set group membership of users in batch mode **autorandr 1.10.1** * *2020-05-04* Revert making the launcher the default (fixes #195) **autorandr 1.10** * *2020-04-23* Fix hook script execution order to match description from readme * *2020-04-11* Handle negative gamma values (fixes #188) * *2020-04-11* Sort approximate matches in detected profiles by quality of match * *2020-01-31* Handle non-ASCII environment variables (fixes #180) * *2019-12-31* Fix output positioning if the top-left output is not the first * *2019-12-31* Accept negative gamma values (and interpret them as 0) * *2019-12-31* Prefer the X11 launcher over systemd/udev configuration **autorandr 1.9** * *2019-11-10* Count closed lids as disconnected outputs * *2019-10-05* Do not overwrite existing configurations without `--force` * *2019-08-16* Accept modes that don't match the WWWxHHH pattern * *2019-03-22* Improve bash autocompletion * *2019-03-21* Store CRTC values in configurations * *2019-03-24* Fix handling of recently disconnected outputs (See #128 and #143) **autorandr 1.8.1** * *2019-03-18* Removed mandb call from Makefile **autorandr 1.8** * *2019-02-17* Add an X11 daemon that runs autorandr when a display connects (by @rliou92, #127) * *2019-02-17* Replace width=0 check with disconnected to detect disconnected monitors (by @joseph-jones, #139) * *2019-02-17* Fix handling of empty padding (by @jschwab, #138) * *2019-02-17* Add a man page (by @somers-all-the-time, #133) **autorandr 1.7** * *2018-09-25* Fix FB size computation with rotated screens (by @Janno, #117) **autorandr 1.6** * *2018-04-19* Bugfix: Do not load default profile unless --change is set * *2018-04-30* Added a `AUTORANDR_MONITORS` variable to hooks (by @bricewge, #106) * *2018-06-29* Fix detection of current configuration if extra monitors are active * *2018-07-11* Bugfix in the latest change: Correctly handle "off" minitors when comparing * *2018-07-19* Do not kill spawned user processes from systemd unit * *2018-07-20* Correctly handle "off" monitors when comparing -- fixup for another bug. **autorandr 1.5** * *2018-01-03* Add --version * *2018-01-04* Fixed vertical/horizontal/clone-largest virtual profiles * *2018-03-07* Output all non-error messages to stdout instead of stderr * *2018-03-25* Add --detected and --current to filter the profile list output * *2018-03-25* Allow wildcard matching in EDIDs **autorandr 1.4** * *2017-12-22* Fixed broken virtual profile support * *2017-12-14* Added support for a settings file * *2017-12-14* Added a virtual profile `off`, which disables all screens **autorandr 1.3** * *2017-11-13* Add a short form for `--load` * *2017-11-21* Fix environment stealing in `--batch` mode (See #87) **autorandr 1.2** * *2017-07-16* Skip `--panning` unless it is required (See #72) * *2017-10-13* Add `clone-largest` virtual profile **autorandr 1.1** * *2017-06-07* Call systemctl with `--no-block` from udev rule (See #61) * *2017-01-20* New script hook, `predetect` * *2017-01-18* Accept comments (lines starting with `#`) in config/setup files **autorandr 1.0** * *2016-12-07* Tag the current code as version 1.0.0; see github issue #54 * *2016-10-03* Install a desktop file to `/etc/xdg/autostart` by default autorandr-1.14/autorandr.1000066400000000000000000000113051444505623000155220ustar00rootroot00000000000000.TH AUTORANDR 1 .SH NAME autorandr \- automatically select a display configuration based on connected devices .SH SYNOPSIS .B autorandr [\fIOPTION\fR] [\fIPROFILE\fR] .SH DESCRIPTION .PP This program automatically detects connected display hardware and then loads an appropriate X11 setup using xrandr. It also supports the use of display profiles for different hardware setups. .PP Autorandr also includes several virtual configurations including \fBoff\fR, \fBcommon\fR, \fBclone-largest\fR, \fBhorizontal\fR, and \fBvertical\fR. See the documentation for explanation of each. .SH OPTIONS .TP \fB\-h\fR, \fB\-\-help \fRDisplay help text and exit .TP \fB\-c\fR, \fB\-\-change \fRAutomatically load the first detected profile .TP \fB\-d\fR, \fB\-\-default \fIPROFILE \fRMake profile \fIPROFILE\fR the default profile. The default profile is used if no suitable profile can be identified. Else, the current configuration is kept. .TP \fB\-l\fR, \fB\-\-load \fIPROFILE \fRLoad profile \fIPROFILE .TP \fB\-s\fR, \fB\-\-save \fIPROFILE \fRSave the current setup to profile \fIPROFILE .TP \fB\-r\fR, \fB\-\-remove \fIPROFILE \fRRemove profile \fIPROFILE .TP .BR \-\-batch \fRRun autorandr for all users with active X11 sessions .TP .BR \-\-current List only the current (active) configuration(s) .TP .BR \-\-config Dump the variable values of your current xrandr setup .TP .BR \-\-cycle Cycle through all detected profiles .TP .BR \-\-debug Enable verbose output .TP .BR \-\-detected List only the detected (i.e. available) configuration(s) .TP .BR \-\-dry\-run Don't change anything, only print the xrandr commands .TP .BR \-\-fingerprint Fingerprint the current hardware setup .TP .BR \-\-match-edid Match displays based on edid instead of name .TP .BR \-\-ignore-lid By default, closed lids are considered as disconnected if other outputs are detected. This flag disables this behaviour. .TP .BR \-\-force Force loading or reloading of a profile .TP .BR \-\-list List all profiles .TP \fB\-\-skip\-options [\fIOPTION\fR] ... \fRSet a comma\-separated list of xrandr arguments to skip both in change detection and profile application. See \fBxrandr(1)\fR for xrandr arguments. .TP .BR \-\-version Show version information and exit .SH FILES Configuration files are searched for in the \fIautorandr \fRdirectory in the colon separated list of paths in \fI$XDG_CONFIG_DIRS \fR- or in \fI/etc/xdg \fRif that var is not set. They are then looked for in \fI~/.autorandr \fRand if that doesn't exist, in \fI$XDG_CONFIG_HOME/autorandr \fRor in \fI~/.config/autorandr\fR if that var is unset. In each of those directories it looks for directories with \fIconfig\fR and \fIsetup\fR in them. It is best to manage these files with the \fBautorandr\fR utility. .SH DEFAULT OPTIONS You can store default values for any option in an INI-file located at \fI~/.config/autorandr/settings.ini\fR. In a config section, you may place any default values in the form \fIoption-name=option-argument\fR. .SH HOOK SCRIPTS Four more scripts can be placed in the configuration directory: .TP \fIpostswitch\fR Executed after a mode switch has taken place. This can be used to notify window managers or other applications about the switch. .TP \fIpreswitch\fR Executed before a mode switch takes place. .TP \fIpostsave\fR Executed after a profile was stored or altered. .TP \fIpredetect\fR Executed before autorandr attempts to run xrandr. .PP These scripts must be executable and can be placed directly in the configuration directory, where they will always be executed, or in the profile subdirectories, 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). .PP Some of autorandr's state is exposed as environment variables prefixed with \fIAUTORANDR_\fR, such as: \fIAUTORANDR_CURRENT_PROFILE\fR, \fIAUTORANDR_CURRENT_PROFILES\fR, \fIAUTORANDR_PROFILE_FOLDER\fR, and \fIAUTORANDR_MONITORS\fR with the intention that they can be used within the hook scripts. The one kink is that during \fIpreswitch\fR, \fIAUTORANDR_CURRENT_PROFILE\fR is reporting the upcoming profile rather than the current one. .SH AUTHOR \fRPhillip Berndt .br See https://github.com/phillipberndt/autorandr for a full list of contributors. .SH REPORTING BUGS \fRReport issues upstream on GitHub: https://github.com/phillipberndt/autorandr/issues .br \fRPlease attach the output of \fBxrandr --verbose\fR to your bug report if appropriate. .SH SEE ALSO \fRFor examples, advanced usage (including predefined per-profile & global hooks and wildcard EDID matching), and full documentation, see https://github.com/phillipberndt/autorandr. autorandr-1.14/autorandr.py000077500000000000000000002230721444505623000160230ustar00rootroot00000000000000#!/usr/bin/env python3 # encoding: utf-8 # # autorandr.py # Copyright (c) 2015, Phillip Berndt # # Autorandr rewrite in Python # # This script aims to be fully compatible with the original autorandr. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # from __future__ import print_function import binascii import copy import getopt import hashlib import math import os import posix import pwd import re import shlex import subprocess import sys import shutil import time import glob from collections import OrderedDict from functools import reduce from itertools import chain if sys.version_info.major == 2: import ConfigParser as configparser else: import configparser __version__ = "1.14" try: input = raw_input except NameError: pass virtual_profiles = [ # (name, description, callback) ("off", "Disable all outputs", None), ("common", "Clone all connected outputs at the largest common resolution", None), ("clone-largest", "Clone all connected outputs with the largest resolution (scaled down if necessary)", None), ("horizontal", "Stack all connected outputs horizontally at their largest resolution", None), ("vertical", "Stack all connected outputs vertically at their largest resolution", None), ("horizontal-reverse", "Stack all connected outputs horizontally at their largest resolution in reverse order", None), ("vertical-reverse", "Stack all connected outputs vertically at their largest resolution in reverse order", None), ] properties = [ "Colorspace", "max bpc", "aspect ratio", "Broadcast RGB", "audio", "non-desktop", "TearFree", "underscan vborder", "underscan hborder", "underscan", "scaling mode", ] help_text = """ Usage: autorandr [options] -h, --help get this small help -c, --change automatically load the first detected profile -d, --default make profile the default profile -l, --load load profile -s, --save save your current setup to profile -r, --remove remove profile --batch run autorandr for all users with active X11 sessions --current only list current (active) configuration(s) --config dump your current xrandr setup --cycle automatically load the next detected profile --debug enable verbose output --detected only list detected (available) configuration(s) --dry-run don't change anything, only print the xrandr commands --fingerprint fingerprint your current hardware setup --ignore-lid treat outputs as connected even if their lids are closed --match-edid match displays based on edid instead of name --force force (re)loading of a profile / overwrite exiting files --list list configurations --skip-options