Autostart

Autostarting Noti using Systemd and D-Bus

This guide will help you configure autostart Noti using systemd user services and D-Bus activation.

WARNING: Specific configurations might vary slightly depending on your distribution and desktop setup.

Understanding Environment Variables

VariableDefault PathDescription
$XDG_DATA_HOME~/.local/shareUser-specific data directory
$XDG_CONFIG_HOME~/.configUser-specific configuration directory

Step 1: D-Bus Service Configuration

Create a D-Bus service to define how application should be launched:

mkdir -d $XDG_DATA_HOME/dbus-1/services
touch $XDG_DATA_HOME/dbus-1/services/org.freedesktop.Notifications.service

Add the following:

[D-Bus Service]
Name=org.freedesktop.Notifications
Exec=%h/.cargo/bin/noti run
SystemdService=noti.service

Step 2: Systemd User Service Configuration

Create a systemd unit to manage application's lifecycle:

mkdir -d $XDG_CONFIG_HOME/systemd/user
touch $XDG_CONFIG_HOME/systemd/user/noti.service

Add the following:

[Unit]
Description=Noti Application
PartOf=graphical-session.target
After=graphical-session.target

[Service]
Type=dbus
BusName=org.freedesktop.Notifications
Environment=XDG_CONFIG_HOME=%h/.config
Environment=NOTI_LOG=info
ExecStart=%h/.cargo/bin/noti run
Restart=always

[Install]
WantedBy=default.target

Unit Configuration Breakdown

ConfigurationPurpose
PartOf=graphical-session.targetEnsures the service is managed with the graphical session
Type=dbusEnables D-Bus activation
Restart=alwaysAutomatically restarts on failure
WantedBy=default.targetEnables autostart at user login

Step 3: Enable and Start the Service

# Reload systemd user configuration
systemctl --user daemon-reload

# Enable service to start on boot
systemctl --user enable noti.service

# Start service immediately
systemctl --user start noti.service

Troubleshooting

# View service status
systemctl --user status noti

# Follow live service logs
journalctl --user --unit noti --follow

Common Issues:

  • Ensure the executable path is correct
  • Check file permissions
  • Verify D-Bus and systemd configurations
  • Confirm environment variables are set correctly