this post was submitted on 31 Jul 2023
23 points (100.0% liked)

General Programming Discussion

7844 readers
24 users here now

A general programming discussion community.

Rules:

  1. Be civil.
  2. Please start discussions that spark conversation

Other communities

Systems

Functional Programming

Also related

founded 5 years ago
MODERATORS
 

The goal is to have my screen rotate to normal and start Barrier (keyboard and mouse share software) on boot up.

So, i have a laptop laying on top of my desktop monitor that i use kinda like a second monitor. But it boots up with the display sideways and i have to login to be able to use mouse and keyboard from my desktop.

I have tried everything to get a systemd service to handle those problems. But no luck, i think the service isnt running properly on boot. Please help me out.

Let me know if there is a better community to post to or if additional info is needed. Thanks.

top 9 comments
sorted by: hot top controversial new old
[–] glibg10b@lemmy.ml 7 points 1 year ago* (last edited 1 year ago) (1 children)

Your service is starting, as is evident from the logged message "Started My Shell Script."

It's odd that you're using sudo in the script. The script is already run as root by the service. Also, sudo asks for a password, but you can't give it one because you're not running it from the terminal. Xrandr doesn't even need root

I believe the error message is happening because xrandr needs the DISPLAY environment variable, which is inherited by applications launched from the desktop (e.g. by the "startup applications" feature of your desktop environment, from .xinitrc, or when running it from a terminal window)

See https://wiki.archlinux.org/title/Xrandr#Configuration_using_arandr for something you could try

[–] mystuffdoesntwork@discuss.tchncs.de 1 points 1 year ago (2 children)

Its odd because i dont know what im doing, i sudo everything lol. So, i also tried what @dragnucs@lemmy.ml said. Changed the shellscript.service to use commands instead of a script and then checking status in terminal after a restart.

With xrandr it failed with "cant open display" which is what youre talking about. Is what youre saying is that i cant run xrandr before login?

With barrier it failed because "The Barrier GUI requires a display". So, same thing, it cant be done before login??

[–] glibg10b@lemmy.ml 2 points 1 year ago (1 children)

Is what youre saying is that i cant run xrandr before login?

So, same thing, it cant be done before login??

Yes and yes

Well damn. There goes my hopes and dreams. Thanks for your help.

[–] dragnucs@lemmy.ml 2 points 1 year ago

You can set your service to start after the graphical session starts by adding this line to the [unit] section:

After=graphical-session.target

You can also add a require with same target.

If you still need a value for an environment variable, you can set it with "Environment=".

Also as others said, you don't nedd sudo. Systems should manage all of that. Starting, stopping, reload, environment, dependencies and user context.

[–] dragnucs@lemmy.ml 3 points 1 year ago* (last edited 1 year ago) (1 children)

Instead of a script try the command directly in ExecStart. Systemd should take care of keeping the process running without you having to do nohop and disown.

If you insist on using a script you should use a full path to sh or bash with the path to your script as an argument like ExecStart=/usr/bin/bash /path/to/script.sh.

[–] glibg10b@lemmy.ml 0 points 1 year ago (1 children)

You might wanna proofread this, mate

[–] dragnucs@lemmy.ml 1 points 1 year ago

Any better?

[–] iknt@lemmy.ml 2 points 1 year ago* (last edited 1 year ago)

Your xrandr script is missing output monitor. Try this

COMMAND=/usr/bin/xrandr --ouput LVDS1 --rotate normal

If LVDS1 is incorrect. You can check the output by running xrandr.

https://wiki.archlinux.org/title/Xrandr#Scripts

load more comments
view more: next ›