]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
Prefer X11 launcher (like srandr) over udev/systemd setup
authorPhillip Berndt <phillip.berndt@googlemail.com>
Tue, 31 Dec 2019 10:41:27 +0000 (11:41 +0100)
committerPhillip Berndt <phillip.berndt@googlemail.com>
Tue, 31 Dec 2019 10:41:27 +0000 (11:41 +0100)
See #162. The X11 launcher, that waits for randr events in X11 and runs
autorandr manually, proved to be more reliable than the setup using udev
and systemd. Make it the default.

Makefile
README.md
contrib/etc/xdg/autostart/autorandr-launcher.desktop [new file with mode: 0644]

index d8b27c6e5eac1ce9627e2cb224c3c2aa6473180e..a4a70e4a1958315e1240995822edb46e8b2e9b28 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
 DESTDIR=/
 PREFIX=/usr/
 RPM_SPEC=contrib/packaging/rpm/autorandr.spec
+CFLAGS=-O2
 
 .PHONY: all install uninstall autorandr bash_completion autostart_config pmutils systemd udev
 
@@ -23,10 +24,9 @@ all:
        @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."
+       @echo "By default, if xcb libraries are available, autorandr prefers to"
+       @echo "install a launcher that listens for X11 randr events and runs"
+       @echo "autorandr whenever something changes, over udev/systemd rules."
        @echo
        @echo "The following additional targets are available:"
        @echo
@@ -139,12 +139,24 @@ uninstall_manpage:
        rm -f ${DESTDIR}/${MANDIR}/autorandr.1
 
 # Rules for launcher
+LAUNCHER_FLAGS=$(shell pkg-config --libs --cflags pkg-config xcb xcb-randr 2>/dev/null)
+ifneq (,$(LAUNCHER_FLAGS))
+DEFAULT_TARGETS+=launcher
+DEFAULT_TARGETS:=$(filter-out systemd udev,$(DEFAULT_TARGETS))
+endif
+
 install_launcher:
-       gcc -Wall contrib/autorandr_launcher/autorandr_launcher.c -o contrib/autorandr_launcher/autorandr_launcher -lxcb -lxcb-randr
-       install -D -m 755 contrib/autorandr_launcher/autorandr_launcher ${DESTDIR}${PREFIX}/bin/autorandr_launcher
+       gcc -Wall $(CFLAGS) contrib/autorandr_launcher/autorandr_launcher.c -o contrib/autorandr_launcher/autorandr-launcher $(LAUNCHER_FLAGS)
+       install -D -m 755 contrib/autorandr_launcher/autorandr_launcher ${DESTDIR}${PREFIX}/bin/autorandr-launcher
+
+       install -D -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
 
 uninstall_launcher:
-       rm -f ${DESTDIR}${PREFIX}/bin/autorandr_launcher
+       rm -f ${DESTDIR}${PREFIX}/bin/autorandr-launcher
+       rm -f ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr-launcher.desktop
 
 TARGETS=$(DEFAULT_TARGETS)
 install: $(patsubst %,install_%,$(TARGETS))
index 145074bfd71894c249534167af8c186b5bd46d7e..ad32de434bdbef9449eb23995de955a286a215d5 100644 (file)
--- a/README.md
+++ b/README.md
@@ -217,6 +217,7 @@ profiles matching multiple (or any) monitors.
 **autorandr 1.10 (dev)**
 * *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**
 
diff --git a/contrib/etc/xdg/autostart/autorandr-launcher.desktop b/contrib/etc/xdg/autostart/autorandr-launcher.desktop
new file mode 100644 (file)
index 0000000..1a5bff0
--- /dev/null
@@ -0,0 +1,6 @@
+[Desktop Entry]
+Name=Autorandr Launcher
+Comment=Automatically run autorandr whenever the configuration changes
+Type=Application
+Exec=/usr/bin/autorandr-launcher
+X-GNOME-Autostart-Phase=Initialization