# Systemd service to start DWL
# ----------------------------------------------------------
#
# Symlink this file in following directory as follows:
#
#  $ cd ~/.config/systemd/user
#  $ ln -s <snips>/dwl.service dwl@.service
#
# Be sure to link it as a named service with (@.service)
#
# Start this service with something like this:
#
#  #!/usr/bin/env bash
#
#  # Start DWL
#  RUNTIME_DIR=$(mktemp --directory --suffix=.${USER})
#
#  # Escape slashes in the path
#  SNAME=$(systemd-escape ${RUNTIME_DIR}.service)
#
#  # Start service blocking. Remove runtime directory upon completion.
#  # Be sure to import XDG session variables for graphical-session to work
#  systemctl --user import-environment XDG_SEAT && \
#  systemctl --user import-environment XDG_SESSION_TYPE && \
#  systemctl --user import-environment XDG_SESSION_CLASS && \
#  systemctl --user import-environment XDG_VTNR && \
#  systemctl --user import-environment XDG_SESSION_ID && \
#  systemctl --wait --user start dwl@${SNAME} && \
#  rm -rf ${RUNTIME_DIR}
[Unit]
Description=DWL session service
BindsTo=graphical-session.target
Wants=graphical-session-pre.target
After=graphical-session-pre.target

[Service]
Type=oneshot
Environment=XDG_RUNTIME_DIR=%I
Environment=DWL_TAGS_FILE=%I/dwl.tags
Environment=DWL_LOG_FILE=%I/dwl.log
Environment=DWLTAGS_FMT=DZEN
Environment=XDG_CURRENT_DESKTOP=DWL
Environment=PIPEWIRE_RUNTIME_DIR=/run/user/501
ExecStart=%h/bin/dwl.session
Restart=on-failure
RestartSec=1
TimeoutStopSec=10