Realized after posting this that I had a pretty simple workaround: just
check if the wrapperscript is being called by gdm and exit:

if [ "$(id -un)" = "gdm" ]; then
    echo "This command should not be run as the gdm user."
    exit 0
fi

Although it still feels wrong-ish that systemd enables this service for
gdm; would still be interested in how to disable that.

Thanks,
Ben


On Thu, Nov 13, 2025 at 12:10 PM Ben <[email protected]> wrote:

> Hello,
>
> Running on Fedora 43 with latest updates.  I created a systemd user
> service that is globally enabled (ie, sudo systemctl --global enable
> servicename.service) and configured to launch when any user logs in to the
> system (hopefully, only for graphical logins):
> ---
> [Unit]
> Description=Registration Reminder
> After=graphical-session.target
> PartOf=graphical-session.target
> After=polkit.service
>
> [Service]
> Type=forking
> ExecStart=/usr/share/Project/wrapperscript
> Restart=no
>
> [Install]
> WantedBy=default.target
> ---
> (I've modified some of the details since they are internal.)
>
> The wrapperscript launches a python gtk dialog with pkexec that requires a
> user to do some stuff and configures their system.  After a reboot, the
> service always fails to start the first time it is started. Sometimes, the
> attempt to initialize the pygtk env cores with "Can't create a
> GtkStyleContext without a display connection."
>
> After debugging this, I realized that systemd was trying to start this
> service for the gdm user.  (I guess the display environment that systemd
> starts for gdm doesn't stick around for too long, which is why sometimes it
> cores.)
>
> I don't want this service to run for the gdm user, and Google suggested
> this command:
>
> sudo systemctl --user -M gdm@ disable servicename.service
>
> Checked the systemd manpage, and it seems legit. However, whenever I try
> and run this command, it always fails:
>
> sudo systemctl --user -M gdm@ disable servicename.service
> Failed to connect to system scope bus via local transport: No such file or
> directory
> Failed to disable unit: Transport endpoint is not connected
>
> There is no /run/user/42/bus path for gdm like I have for my regular user.
>
> Anyone know how to disable a globally enabled systemd user service for gdm?
>
> Thanks,
> Ben
>
>
>
-- 
_______________________________________________
users mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/[email protected]
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue

Reply via email to