# EndeavourOS sway autostart configuration
# everything to be automatically started with the session

# Import DISPLAY, WAYLAND_DISPLAY, SWAYSOCK into user/systemd session
# so GUI apps started via systemctl or DBus use the correct Wayland display.
exec systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK
exec hash dbus-update-activation-environment 2>/dev/null && \
     dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK

# Enable swayidle to send idle hints (1 = active) for better idle handling
exec swayidle idlehint 1

# Sway Notification Center (swaync)
exec swaync

# set default display (to set screen for notifications to showup)
# use:
# swaymsg -t get_outputs | jq -r ' sort_by(.rect.x) | .[].name'
# to get current connected display names (replace DP-3 with the one you want default)

# exec swaync-client --change-noti-monitor DP-3

# screen locker
exec_always swayidle -w \
  timeout 280 '$HOME/.config/sway/scripts/gtklock_config' \
  timeout 300 'swaymsg "output * dpms off"' \
  resume 'swaymsg "output * dpms on"' \
  before-sleep '$HOME/.config/sway/scripts/gtklock_config'

# osd für volume (swayosd)
exec swayosd-server -s ~/.config/swayosd/style.css
#On setups with multiple monitors, if you only want to show the osd on the focused monitor
#swayosd-client --monitor "$(swaymsg -t get_outputs | jq -r '.[] | select(.focused == true).name')" --output-volume raise

#exec swayidle -w timeout 300 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' &
#exec_always swayidle -w before-sleep "gtklock -d"

# bars/panels (waybar)
exec waybar -c $HOME/.config/waybar/config.jsonc -s $HOME/.config/waybar/style.css


# Autotiling
exec autotiling

# Keep clipboard history updated for text and images
# by watching the clipboard and storing changes in 'cliphist'.
exec wl-paste --type text --watch cliphist store
exec wl-paste --type image --watch cliphist store

# autostarting apps (comment with # to stop autostarting)
exec firefox https://github.com/endeavouros-team/endeavouros-sway-setup/blob/main/force-knowledge.md
#exec  sleep 5 && telegram-desktop

exec sleep 3 && blueman-applet

## tools/helper

# Start the Polkit authentication agent for GUI privilege prompts
# so apps can request admin rights in the Sway session.
exec  /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 &

# saving a backup of installed packages as a list
exec  sh ~/.config/sway/scripts/packagelist.sh

# dex execute .desktop files
# see here: https://man.archlinux.org/man/extra/dex/dex.1.en
exec  dex --autostart --environment sway

# osd (on screen display) für volume
exec swayosd-server -s ~/.config/swayosd/style.css
exec swayosd-client --monitor "$(swaymsg -t get_outputs | jq -r '.[] | select(.focused == true).name')" --output-volume raise
