You are not logged in.

#1 2017-02-09 22:29:50

blkb0
Member
Registered: 2017-02-09
Posts: 2

systemd xrandr service autostart failing

So I want to create a service to autostart a small shell script to change my resolution and position of my screen, but it fails every time.
The script runs fine on its own.
Here is the systemctl status output:

  219rez.service - 21:9 resolution fix
   Loaded: loaded (/etc/systemd/system/219rez.service; disabled; vendor preset: 
   Active: failed (Result: exit-code) since Fri 2017-02-10 00:26:04 EET; 4s ago
  Process: 684 ExecStart=/usr/bin/xrandr219 (code=exited, status=1/FAILURE)

Feb 10 00:26:04 desktop systemd[1]: Starting 21:9 resolution fix...
Feb 10 00:26:04 desktop xrandr219[684]: Can't open display
Feb 10 00:26:04 desktop xrandr219[684]: Can't open display
Feb 10 00:26:04 desktop xrandr219[684]: Can't open display
Feb 10 00:26:04 desktop xrandr219[684]: Can't open display
Feb 10 00:26:04 desktop systemd[1]: 219rez.service: Control process exited, code
Feb 10 00:26:04 desktop systemd[1]: Failed to start 21:9 resolution fix.
Feb 10 00:26:04 desktop systemd[1]: 219rez.service: Unit entered failed state.
Feb 10 00:26:04 desktop systemd[1]: 219rez.service: Failed with result 'exit-cod

Here is the script

#!/bin/sh -
xrandr --newmode "2160x912_60.00"  162.50  2160 2288 2512 2864  912 915 925 947$
xrandr --addmode HDMI-0 2160x912_60.00
xrandr --output DVI-1 --auto --output HDMI-0 --auto --right-of DVI-1
xrandr --output HDMI-0 --mode 2160x912_60.00

And here is the service file

[Unit]
Description=21:9 resolution fix

[Service]
ExecStart=/usr/bin/xrandr219
Requires=lightdm.service
Type=forking

[Install]
WantedBy=multi-user.target

Any help would be appreciated.

Offline

#2 2017-02-09 22:36:06

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: systemd xrandr service autostart failing


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2017-02-09 22:47:09

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: systemd xrandr service autostart failing

Where is this script forking?

Anyway, as this is for lightdm, you could probably let lightdm run it by setting display-setup-script in the config. But, then again, why not go with https://wiki.archlinux.org/index.php/Mu … _xorg.conf

Offline

#4 2017-02-09 23:19:07

blkb0
Member
Registered: 2017-02-09
Posts: 2

Re: systemd xrandr service autostart failing

Thank you both, that worked a lot better.

Offline

Board footer

Powered by FluxBB