The main issue preventing lule from running in systemd/background was the TTY detection logic that blocked execution when not connected to a terminal. The fixes include:
- Removed TTY blocking logic in
create.rsanddaemon.rs - Fixed relative path issues for the logo file in
main.rs - Added TTY checks for output only to prevent unnecessary logging when running as daemon
cargo build --release
sudo cp target/release/lule /usr/local/bin/mkdir -p ~/.wallpaper
mkdir -p ~/.config/lule
mkdir -p ~/.cache/luleCopy and customize the example script:
cp scripts/apply_colors.sh ~/.config/lule/apply_colors.sh
chmod +x ~/.config/lule/apply_colors.shImportant: Edit ~/.config/lule/apply_colors.sh and replace hardcoded paths:
- Replace
/home/bresilla/with$HOME/or your actual home directory - Example: Change line 55 from:
to:
sed -i "s/fill=\"#\([^\"]*\)\"/fill=\"$col1\"/" /home/bresilla/.config/bresilla.svgsed -i "s/fill=\"#\([^\"]*\)\"/fill=\"$col1\"/" $HOME/.config/bresilla.svg
Create the service file:
mkdir -p ~/.config/systemd/user/
cat > ~/.config/systemd/user/lule.service << 'EOF'
[Unit]
Description=Lule Color Daemon
After=graphical-session.target
[Service]
Type=simple
WorkingDirectory=%h
# Environment variables
Environment="LULE_W=%h/.wallpaper"
Environment="LULE_S=%h/.config/lule/apply_colors.sh"
Environment="LULE_A=%h/.cache/lule"
# Command
ExecStart=/usr/local/bin/lule daemon start
# Logging
StandardOutput=journal
StandardError=journal
# Restart on failure
Restart=on-failure
RestartSec=5
[Install]
WantedBy=default.target
EOF# Reload systemd
systemctl --user daemon-reload
# Enable to start on boot
systemctl --user enable lule.service
# Start now
systemctl --user start lule.service
# Check status
systemctl --user status lule.service# Follow logs in real-time
journalctl --user -u lule.service -f
# View recent logs
journalctl --user -u lule.service -n 50lule daemon nextsystemctl --user stop lule.service
# or
lule daemon stopYou can also run lule in the background using the detach mode:
export LULE_W="$HOME/.wallpaper"
export LULE_S="$HOME/.config/lule/apply_colors.sh"
lule daemon detachThis will:
- Daemonize the process
- Write logs to
/tmp/daemon.outand/tmp/daemon.err - Create PID file in
/tmp/lule.pid
- Check logs:
journalctl --user -u lule.service -n 50 - Verify environment variables are set correctly
- Ensure directories exist:
~/.wallpaper,~/.cache/lule - Make sure script is executable:
chmod +x ~/.config/lule/apply_colors.sh
- Put wallpaper images in
~/.wallpaper/ - Or set
LULE_Wto your wallpaper directory
- Check script permissions:
ls -l ~/.config/lule/apply_colors.sh - Test script manually:
bash ~/.config/lule/apply_colors.sh - Verify
LULE_Senvironment variable is set correctly
When running as a daemon without active TTY sessions, the /dev/pts/* writing won't work. You may need to:
- Source the colors in your shell's rc file (
.bashrc,.zshrc) - Use a display manager hook to apply colors on login
- Configure individual applications to read from
~/.cache/wal/directory
-
TTY Detection Blocking (main issue):
- Old code:
if atty::isnt(atty::Stream::Stdout) { /* skip logic */ } - New code: Removed the blocking condition, only use TTY detection for output
- Old code:
-
Relative Path Issues:
- Logo file now tries multiple paths including executable directory
- Falls back gracefully when file not found
-
Output Noise:
- Print statements only execute when connected to TTY
- Reduces log spam when running as daemon
- The
apply_colors.shscript writes to/dev/pts/*which requires active terminal sessions - Some color changes may not apply to already-running terminal emulators
- Hardcoded user paths in script need manual adjustment