You are not logged in.

#1 2012-08-01 17:55:46

anti-destin
Member
Registered: 2009-02-14
Posts: 234

[solved] writing systemd service file to run script

i have completely migrated to systemd. now, i am trying to write a service file to run a startup script (~/.startup.sh). one of the functions of the script is to set the brightness of the screen:

echo "95" > /sys/class/backlight/intel_backlight/brightness

i created /etc/systemd/system/startup.service:

[Unit]
Description=Run startup script

[Service]
Type=oneshot
ExecStart=~/.startup.sh

[Install]
WantedBy=multi-user.target

but i get the following error:

Failed to issue method call: Unit startup.service failed to load: Invalid argument. See system logs and 'systemctl status startup.service' for details.

i have two questions:

1. what am i missing?

2. how can i avoid permission issues associated with modifying the brightness file (e.g., permission denied errors, the need to put in the password, etc.)?

thanks.

Last edited by anti-destin (2012-08-01 22:26:04)

Offline

#2 2012-08-01 18:14:10

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

Re: [solved] writing systemd service file to run script

This is probably because the file could not be found. You are using a relative path, which is the likely cause. You can read more detailed error information using journalctl.

Offline

#3 2012-08-01 18:17:27

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: [solved] writing systemd service file to run script

if all you do is echo a value into a file, don't do this with a service file, use a tmpfile instead (see systemd wiki).
and yes, the problem is the relative path, it must be absolute.

Offline

#4 2012-08-01 22:25:51

anti-destin
Member
Registered: 2009-02-14
Posts: 234

Re: [solved] writing systemd service file to run script

thanks for the replies.

just a note: using an absolute path didn't fix the issue.

but i went ahead and created the file /etc/tmpfiles.d/backlight.conf:

w /sys/class/backlight/intel_backlight/brightness - - - - 95

and that worked.

is there a reason for recommending using a tmpfile rather than a service?

in any case, i'm marking this as solved.

Offline

#5 2012-08-02 07:15:29

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: [solved] writing systemd service file to run script

anti-destin wrote:

is there a reason for recommending using a tmpfile rather than a service?

https://bbs.archlinux.org/viewtopic.php … 7#p1115517

Offline

#6 2012-08-02 07:47:09

anti-destin
Member
Registered: 2009-02-14
Posts: 234

Re: [solved] writing systemd service file to run script

thanks for the clarification.

Offline

Board footer

Powered by FluxBB