0

I'm trying to get a script to run after gdm3 starts but before a user logs in. Reason is the script needs an active monitor, but if there's a power outage, I want the system to boot back to functional when power is restored.

I've tried various iterations based on other answers, but none of them seem to be performing the way I need it to. I'm also trying to contain this in my custom systemd service definition and not touch any other service definitions, if possible. Here's my current (not working) iteration:

[Unit]
Description=Testing
After=network.target network-online.target gdm3.service

[Service]
Type=oneshot
User=root
Group=root

GuessMainPID=no
ExecStart=/bin/bash /home/user/test.sh
Restart=never

[Install]
WantedBy=multi-user.target

Reboot -> Nothing. After I login -> Nothing. I can manually start it and it is enabled. I reloaded the daemon after any edits and still nothing.

1
  • Have you checked the logs? Feb 15, 2021 at 23:56

1 Answer 1

0

The logs were confusing because it looked like the script was triggering but nothing actually happened. I figured it out based on the logs and quite a bit of Googling.

Looks like gdm has 2 X sessions; 1 pre-login and another post-login. When I set my DISPLAY in the lines of the script along with Xauthority, I had the DISPLAY correct, but the Xauthority was the one that was post-login. I just needed to SSH in before loging in, do ps a | grep X to find the proper Xauthority (which is the only one at this point since I haven't logged in through gdm), change the script with the correct Xauthority, reboot, and seems to be good now.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .