You are not logged in.

#1 2024-02-23 19:29:49

Sulfate8466
Member
From: United States
Registered: 2023-12-10
Posts: 3

[Solved] Systemd unit not working as expected

I recently switched to hyprland and have been learning a lot of new things about customizing and really making my Arch install my own. One of the things I am having trouble with is my login manager. I'm currently using SDDM and it functions fine, I'm just having issues with the theme. For my background, I use variety to switch between different wallpapers. I wanted to create a systemd unit to read my current wallpaper on system shut down and set the the background of my SDDM theme to that current wallpaper.

I wrote a simple script below. This script when ran and tested with the sddm-greeter tool functions properly.

#!/usr/bin/env bash

#get the current background
bg=$(cat /home/tristin/.config/variety/wallpaper/wallpaper.jpg.txt)

#setup the SDDM theme
rm /usr/share/sddm/themes/archlinux-simplyblack/theme.conf
echo "[General]" >> /usr/share/sddm/themes/archlinux-simplyblack/theme.conf
echo "background=$bg" >> /usr/share/sddm/themes/archlinux-simplyblack/theme.conf

I then wrote a systemd unit called greeter.service, I'll put that below here as well.

[Unit]
Description=A simple unit that will update the SDDM background

[Service]
Type=oneshot
RemainAfterExit=true
ExecStop=/bin/bash /usr/sbin/greeter.sh

[Install]
WantedBy=multi-user.target

I expected this to delete the old conf for the selected theme, and update the background on system shutdown, however when I perform a reboot the background of SDDM is just a white screen. If i continue with the login and run the sddm-greeter test again, the themeing looks as it should, with the correct background, no white screen. I'm not sure why the first login doesn't look correct, if the test works after logging in. I'm new to writing systemd services/units and I'm not sure if I'm going about this in the right way. Any advice would be very welcome.

Last edited by Sulfate8466 (2024-02-24 07:53:25)

Offline

#2 2024-02-23 19:45:30

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,642

Re: [Solved] Systemd unit not working as expected

Are you enabling that with the --user switch?
You also should add directives to ensure it loads before sddm

Last edited by ewaller (2024-02-23 19:47:26)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#3 2024-02-23 20:30:11

Piri
Member
Registered: 2018-06-02
Posts: 70

Re: [Solved] Systemd unit not working as expected

What is the content of `/usr/share/sddm/themes/archlinux-simplyblack/theme.conf` directly after reboot? Does it look like this?

[General]
background=

My guess is that your home directory and especially `/home/tristin/.config/variety/wallpaper/wallpaper.jpg.txt` is unavailable at the time systemd calls ExecStop. Do you have a funky home partition, LVM or similar?

Sulfate8466 wrote:

If i continue with the login and run the sddm-greeter test again, the themeing looks as it should, with the correct background, no white screen.

Just to confirm, does running

# systemctl stop greeter.service

after login work as expected?

Offline

#4 2024-02-24 07:10:49

Sulfate8466
Member
From: United States
Registered: 2023-12-10
Posts: 3

Re: [Solved] Systemd unit not working as expected

ewaller wrote:

You also should add directives to ensure it loads before sddm

Thank you, I've added a directive to ensure that SDDM.service loads after and switched the execstop to an execstart to make it run on launch instead.

Piri wrote:

What is the content of `/usr/share/sddm/themes/archlinux-simplyblack/theme.conf` directly after reboot?

The theme.conf directly after reboot appears to be how it should.

 [General]
background=/home/tristin/.config/variety/Downloaded/wallhaven_national_park/wallhaven-4x8x8o.jpg 

This in theory should work as that's the correct directory for the background.

Piri wrote:

Just to confirm, does running...

I don't know how I missed this. I just disabled the greeter.service and It turns out that there is no issue with the systemd unit. After a reboot after disabling the unit, I'm still seeing a white screen instead of a background image. I've obviously messed up in setting up the theme correctly, I'll look into this and post an update when I figure out what I've done wrong.

Thanks for the help, I would've kept looking in the wrong place.

Offline

#5 2024-02-24 07:27:28

Sulfate8466
Member
From: United States
Registered: 2023-12-10
Posts: 3

Re: [Solved] Systemd unit not working as expected

Sure enough, I just needed to rethink my approach to the SDDM theme. I updated my greeter.sh (the script run by the systemd unit) to instead of creating a custom user theme, to instead overwrite the default background image.

#!/usr/bin/env bash

#get the current background
bg=$(cat /home/tristin/.config/variety/wallpaper/wallpaper.jpg.txt)

#setup the SDDM theme
rm /usr/share/sddm/themes/archlinux-simplyblack/background.png
cp $bg /usr/share/sddm/themes/archlinux-simplyblack/background.png

I think I was mistaken in how I was going about messing with the theme conf. Regardless, both the systemd unit and the SDDM are both working now on my system. Thanks again for the help!

Offline

#6 2024-02-24 08:10:00

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,030

Re: [Solved] Systemd unit not working as expected

The SDDM greeter likely runs as unprivileged users, try to use a wallpaper in some world readable location like /usr/share/wallpapers
You can also bind-mount your path in $HOME there and tune the permissions for that (just make sure that /home/tristin is mounted and not encrypted at the time)

Edit: F5 …

Last edited by seth (2024-02-24 08:10:26)

Offline

Board footer

Powered by FluxBB