]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/blob - contrib/packaging/rpm/autorandr.spec
Improved .spec file for RPM builds
[deb_pkgs/autorandr.git] / contrib / packaging / rpm / autorandr.spec
1 %define name autorandr
2 %define version 1.8.1
3 %define release 1
4
5 # pmutils
6 %define use_pm_utils 1
7 %if 0%{?fedora} > 22
8 %define use_pm_utils 0
9 %endif
10 %if 0%{?rhel} > 7
11 %define use_pm_utils 0
12 %endif
13
14 # python 2 or 3
15 %define py_ver 3
16 %if 0%{?rhel}
17 %define py_ver 2
18 %endif
19
20 Summary: Automatically select a display configuration based on connected devices
21 Name: %{name}
22 Version: %{version}
23 Release: %{release}%{?dist}
24 Source0: https://github.com/phillipberndt/%{name}/archive/%{version}/%{name}-%{version}.tar.gz
25 License: GPLv3
26 Group: Development/Libraries
27 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
28 Prefix: %{_prefix}
29 BuildArch: noarch
30 Vendor: Phillip Berndt <phillip.berndt@googlemail.com>
31 Url: https://github.com/phillipberndt/autorandr
32 Requires: python%{py_ver}
33 %if 0%{?use_pm_utils}
34 Requires:       pm-utils
35 %endif
36 %{?systemd_ordering}
37 BuildRequires: bash-completion
38 BuildRequires: python%{py_ver}-devel
39 BuildRequires: systemd
40 BuildRequires: udev
41
42 %description
43 # autorandr
44
45 Automatically select a display configuration based on connected devices
46
47 ## Branch information
48
49 This is a compatible Python rewrite of
50 [wertarbyte/autorandr](https://github.com/wertarbyte/autorandr). Contributions
51 for bash-completion, fd.o/XDG autostart, Nitrogen, pm-utils, and systemd can be
52 found under [contrib](contrib/).
53
54 The original [wertarbyte/autorandr](https://github.com/wertarbyte/autorandr)
55 tree is unmaintained, with lots of open pull requests and issues. I forked it
56 and merged what I thought were the most important changes. If you are searching
57 for that version, see the [`legacy` branch](https://github.com/phillipberndt/autorandr/tree/legacy).
58 Note that the Python version is better suited for non-standard configurations,
59 like if you use `--transform` or `--reflect`. If you use `auto-disper`, you
60 have to use the bash version, as there is no disper support in the Python
61 version (yet). Both versions use a compatible configuration file format, so
62 you can, to some extent, switch between them.  I will maintain the `legacy`
63 branch until @wertarbyte finds the time to maintain his branch again.
64
65 If you are interested in why there are two versions around, see
66 [#7](https://github.com/phillipberndt/autorandr/issues/7),
67 [#8](https://github.com/phillipberndt/autorandr/issues/8) and
68 especially
69 [#12](https://github.com/phillipberndt/autorandr/issues/12)
70 if you are unhappy with this version and would like to contribute to the bash
71 version.
72
73 ## License information and authors
74
75 autorandr is available under the terms of the GNU General Public License
76 (version 3).
77
78 Contributors to this version of autorandr are:
79
80 * Adrián López
81 * andersonjacob
82 * Alexander Wirt
83 * Brice Waegeneire
84 * Chris Dunder
85 * Christoph Gysin
86 * Daniel Hahler
87 * Maciej Sitarz
88 * Mathias Svensson
89 * Matthew R Johnson
90 * Nazar Mokrynskyi
91 * Phillip Berndt
92 * Rasmus Wriedt Larsen
93 * Simon Wydooghe
94 * Stefan Tomanek
95 * stormc
96 * tachylatus
97 * Timo Bingmann
98 * Timo Kaufmann
99 * Tomasz Bogdal
100 * Victor Häggqvist
101 * Jan-Oliver Kaiser
102
103 ## Installation/removal
104
105 You can use the `autorandr.py` script as a stand-alone binary. If you'd like to
106 install it as a system-wide application, there is a Makefile included that also
107 places some configuration files in appropriate directories such that autorandr
108 is invoked automatically when a monitor is connected or removed, the system
109 wakes up from suspend, or a user logs into an X11 session. Run `make install`
110 as root to install it.
111
112 If you prefer to have a system wide install managed by your package manager,
113 you can
114
115 * Use the [official Arch package](https://www.archlinux.org/packages/community/any/autorandr/).
116 * Use the [official Debian package](https://packages.debian.org/sid/x11/autorandr) on sid
117 * Use the [ebuild from zugaina](https://gpo.zugaina.org/x11-misc/autorandr) on Gentoo.
118 * Use the
119   [nix package](https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/misc/autorandr.nix)
120   on NixOS.
121 * Use the automated nightlies generated by the
122   [openSUSE build service](https://build.opensuse.org/package/show/home:phillipberndt/autorandr)
123   for various distributions (RPM and DEB based).
124 * Use the [X binary package system](https://wiki.voidlinux.eu/XBPS)' on Void Linux 
125 * Build a .deb-file from the source tree using `make deb`.
126
127 We appreciate packaging scripts for other distributions, please file a pull
128 request if you write one.
129
130 If you prefer `pip` over your package manager, you can install autorandr with:
131
132     sudo pip install "git+http://github.com/phillipberndt/autorandr#egg=autorandr"
133
134 or simply
135
136     sudo pip install autorandr
137
138 if you prefer to use a stable version.
139
140 ## How to use
141
142 Save your current display configuration and setup with:
143
144     autorandr --save mobile
145
146 Connect an additional display, configure your setup and save it:
147
148     autorandr --save docked
149
150 Now autorandr can detect which hardware setup is active:
151
152     $ autorandr
153       mobile
154       docked (detected)
155
156 To automatically reload your setup:
157
158     $ autorandr --change
159
160 To manually load a profile:
161
162     $ autorandr --load <profile>
163
164 or simply:
165
166     $ autorandr <profile>
167
168 autorandr tries to avoid reloading an identical configuration. To force the
169 (re)configuration:
170
171     $ autorandr --load <profile> --force
172
173 To prevent a profile from being loaded, place a script call _block_ in its
174 directory. The script is evaluated before the screen setup is inspected, and
175 in case of it returning a value of 0 the profile is skipped. This can be used
176 to query the status of a docking station you are about to leave.
177
178 If no suitable profile can be identified, the current configuration is kept.
179 To change this behaviour and switch to a fallback configuration, specify
180 `--default <profile>`. The system-wide installation of autorandr by default
181 calls autorandr with a parameter `--default default`. There are three special,
182 virtual configurations called `horizontal`, `vertical` and `common`. They
183 automatically generate a configuration that incorporates all screens
184 connected to the computer. You can symlink `default` to one of these
185 names in your configuration directory to have autorandr use any of them
186 as the default configuration without you having to change the system-wide
187 configuration.
188
189 You can store default values for any option in an INI-file in
190 `~/.config/autorandr/settings.ini` in a section `config`. The most useful
191 candidate for doing that is `skip-options`, if you need it.
192
193 ## Advanced usage
194
195 ### Hook scripts
196
197 Three more scripts can be placed in the configuration directory (as 
198 (as defined by the [XDG spec](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html),
199 usually `~/.config/autorandr` or `~/.autorandr` if you have an old installation
200 for user configuration and `/etc/xdg/autorandr` for system wide configuration):
201
202 - `postswitch` is executed *after* a mode switch has taken place. This can be
203   used to notify window managers or other applications about the switch.
204 - `preswitch` is executed *before* a mode switch takes place.
205 - `postsave` is executed after a profile was stored or altered.
206 - `predetect` is executed before autorandr attempts to run xrandr. 
207
208 These scripts must be executable and can be placed directly in the configuration
209 directory, where they will always be executed, or in the profile subdirectories,
210 where they will only be executed on changes regarding that specific profile.
211
212 Instead (or in addition) to these scripts, you can also place as many executable
213 files as you like in subdirectories called `script_name.d` (e.g. `postswitch.d`).
214
215 If a script with the same name occurs multiple times, user configuration
216 takes precedence over system configuration (as specified by the
217 [XDG spec](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html))
218 and profile configuration over general configuration.
219
220 As a concrete example, suppose you have the files
221
222 - `/etc/xdg/autorandr/postswitch`
223 - `~/.config/autorandr/postswitch`
224 - `~/.config/autorandr/postswitch.d/notify-herbstluftwm`
225 - `~/.config/autorandr/docked/postswitch`
226
227 and switch from `mobile` to `docked`. Then
228 `~/.config/autorandr/docked/postswitch` is executed, since the profile specific
229 configuration takes precedence, and
230 `~/.config/autorandr/postswitch.d/notify-herbstluftwm` is executed, since
231 it has a unique name.
232
233 If you switch back from `docked` to `mobile`, `~/.config/autorandr/postswitch`
234 is executed instead of the `mobile` specific `postswitch`.
235
236 In these scripts, some of autorandr's state is exposed as environment variables
237 prefixed with `AUTORANDR_`, such as:
238 - `AUTORANDR_CURRENT_PROFILE`
239 - `AUTORANDR_CURRENT_PROFILES`
240 - `AUTORANDR_PROFILE_FOLDER`
241 - `AUTORANDR_MONITORS`
242
243 If you experience issues with xrandr being executed too early after connecting
244 a new monitor, then you can use a `predetect` script to delay the execution.
245 Write e.g. `sleep 1` into that file to make autorandr wait a second before
246 running `xrandr`.
247
248 ### Wildcard EDID matching
249
250 The EDID strings in the `~/.config/autorandr/*/setup` files may contain an
251 asterisk to enable wildcard matching: Such EDIDs are matched against connected
252 monitors using the usual file name globbing rules. This can be used to create
253 profiles matching multiple (or any) monitors.
254
255 ## Changelog
256
257 **autorandr 1.8.1**
258
259 * *2019-03-18* Removed mandb call from Makefile
260
261 **autorandr 1.8**
262
263 * *2019-02-17* Add an X11 daemon that runs autorandr when a display connects (by @rliou92, #127)
264 * *2019-02-17* Replace width=0 check with disconnected to detect disconnected monitors (by @joseph-jones, #139)
265 * *2019-02-17* Fix handling of empty padding (by @jschwab, #138)
266 * *2019-02-17* Add a man page (by @somers-all-the-time, #133)
267
268 **autorandr 1.7**
269
270 * *2018-09-25* Fix FB size computation with rotated screens (by @Janno, #117)
271
272 **autorandr 1.6**
273
274 * *2018-04-19* Bugfix: Do not load default profile unless --change is set
275 * *2018-04-30* Added a `AUTORANDR_MONITORS` variable to hooks (by @bricewge, #106)
276 * *2018-06-29* Fix detection of current configuration if extra monitors are active
277 * *2018-07-11* Bugfix in the latest change: Correctly handle "off" minitors when comparing
278 * *2018-07-19* Do not kill spawned user processes from systemd unit
279 * *2018-07-20* Correctly handle "off" monitors when comparing -- fixup for another bug.
280
281 **autorandr 1.5**
282
283 * *2018-01-03* Add --version
284 * *2018-01-04* Fixed vertical/horizontal/clone-largest virtual profiles
285 * *2018-03-07* Output all non-error messages to stdout instead of stderr
286 * *2018-03-25* Add --detected and --current to filter the profile list output
287 * *2018-03-25* Allow wildcard matching in EDIDs
288
289 **autorandr 1.4**
290
291 * *2017-12-22* Fixed broken virtual profile support
292 * *2017-12-14* Added support for a settings file
293 * *2017-12-14* Added a virtual profile `off`, which disables all screens
294
295 **autorandr 1.3**
296
297 * *2017-11-13* Add a short form for `--load`
298 * *2017-11-21* Fix environment stealing in `--batch` mode (See #87)
299
300 **autorandr 1.2**
301
302 * *2017-07-16* Skip `--panning` unless it is required (See #72)
303 * *2017-10-13* Add `clone-largest` virtual profile
304
305 **autorandr 1.1**
306
307 * *2017-06-07* Call systemctl with `--no-block` from udev rule (See #61)
308 * *2017-01-20* New script hook, `predetect`
309 * *2017-01-18* Accept comments (lines starting with `#`) in config/setup files
310
311 **autorandr 1.0**
312
313 * *2016-12-07* Tag the current code as version 1.0.0; see github issue #54
314 * *2016-10-03* Install a desktop file to `/etc/xdg/autostart` by default
315
316
317 %prep
318 %setup -n %{name}-%{version} -n %{name}-%{version}
319 %if %{py_ver} == 3
320 pathfix.py -pni "%{__python3} %{py3_shbang_opts}" ./autorandr.py
321 %else
322 pathfix.py -pni "%{__python2} %{py2_shbang_opts}" ./autorandr.py
323 %endif
324
325 %install
326 make DESTDIR="%{buildroot}" PREFIX=/usr install
327 install -vDm 644 README.md -t "%{buildroot}/usr/share/doc/%{name}/"
328
329 %files
330 %defattr(-,root,root,-)
331 %attr(0644,root,root) %{_unitdir}/autorandr.service
332 %license gpl-3.0.txt 
333 %doc README.md
334 %config(noreplace) %{_sysconfdir}/*
335 %{_bindir}/*
336 %{_mandir}
337 %{_datarootdir}/bash-completion/completions/autorandr
338 %{_udevrulesdir}/40-monitor-hotplug.rules
339 %changelog
340 * Wed May 22 2019 Maciej Sitarz <macieksitarz@wp.pl> - 1.8.1-1
341 - Updated to stable 1.8.1
342 * Fri Sep 28 2018 Maciej Sitarz <macieksitarz@wp.pl> - 1.7-1
343 - Updated to stable 1.7
344 * Thu Jul 19 2018 Maciej Sitarz <macieksitarz@wp.pl> - 1.5-1
345 - Updated to stable 1.5
346 - Changed dest path for systemd service file
347 * Sun Oct 01 2017 Jerzy Drozdz <rpmbuilder@jdsieci.pl> - 1.1-2
348 - Added conditionals for pm-utils, compability with Fedora26+
349 - Removed bash-completion from requisites
350 - Removed udev from requisites
351 * Sun Sep 03 2017 Jerzy Drozdz <rpmbuilder@jdsieci.pl> - 1.1-1
352 - Update to stable 1.1
353 * Fri Feb 17 2017 Jerzy Drozdz <rpmbuilder@jdsieci.pl> - 20170217git-1
354 - Update to master
355 * Wed Jul 6 2016 Jerzy Drozdz <rpmbuilder@jdsieci.pl> - 20160706git-1
356 - Set default value of $XDG_CONFIG_DIRS to fulfill the standard
357 * Fri Jul 1 2016 Jerzy Drozdz <rpmbuilder@jdsieci.pl> - 20160701git-1.1
358 - fixed running udevadm in post
359 * Fri Jul 1 2016 Jerzy Drozdz <rpmbuilder@jdsieci.pl> - 20160701git-1
360 - initial build