#!/bin/sh

# Restrict execution to standalone labwc session
case "$XDG_CURRENT_DESKTOP" in
    labwc:wlroots)
        ;;
    *)
        exit 0
        ;;
esac

# Display configuration: https://sr.ht/~emersion/kanshi/
[ -x /usr/bin/kanshi ] && kanshi >/dev/null 2>&1 &

# Set background: https://github.com/swaywm/swaybg
[ -x /usr/bin/swaybg ] && swaybg -m fill -i /usr/share/wallpapers/aptosid-nemesis-wide.png >/dev/null 2>&1 &

# Thunar in daemon mode: faster windows and thunar-volman removable media.
[ -x /usr/bin/thunar ] && thunar --daemon >/dev/null 2>&1 &

# waybar, the polkit agent and mako are not started here: under the uwsm
# session they come up via their systemd user units (waybar.service,
# mako.service) or XDG autostart entries (nm-applet, polkit-mate).

# Screenlock via loginctl lock-session; swayidle's lock handler is the single
# locker (gtklock) and is skipped for the passwordless live user, who cannot
# unlock it. Homed and installed users get it. wlopm turns the screen off on
# the second timeout.
[ -x /usr/bin/swayidle ] && swayidle -w \
        lock '[ -e /run/fll/passwordless ] || gtklock -i' \
        timeout 300 'loginctl lock-session' \
        timeout 600 'wlopm --off \*' \
        resume 'wlopm --on \*' \
        before-sleep 'loginctl lock-session' >/dev/null 2>&1 &
