I’m trying to make a script to update the Zellij configuration file whenever I toggle the dark mode on Gnome. It works as expected if I run it myself, however as a systemd unit despite the service appear to be running and I can see the process on htop it just doesn’t work.
script:
#!/bin/bash
gsettings monitor org.gnome.desktop.interface color-scheme | sed -E -u \
-e “s/.+‘(\w±)?(\w+)’/\2/” \
-e “s/default/light/” | \
while read mode; do
sed -i -E “/^theme .+/s/\w+"$/$mode"/” $HOME/.config/zellij/config.kdl
done
Unit file:
[Unit]
Description=Monitors gsettings change to color-scheme and updates the color-scheme on other programs
[Service]
Type=simple
ExecStart=/bin/bash /path/to/script
User=me
[Install]
WantedBy=multi-user.target
As the script refers to $HOME, it should be run in a user context, that is, the unit file should be installed in /etc/systemd/user directory. The “WantedBy=” should be “default.target” as “multi-user.target” is only defined in the “system” context.