#!/bin/sh

# This file runs when a DM logs you into a graphical session.
# If you use startx/xinit like a Chad, this file will also be sourced.

# Load environment variables from login profile
. "$HOME/.profile"

# Auto-detect device type and set DPI accordingly
DEVICE_TYPE_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/lazykris/device-type"
if [ -f "$DEVICE_TYPE_FILE" ] && [ "$(cat "$DEVICE_TYPE_FILE")" = "laptop" ]; then
	xrandr --dpi 150	# Laptop HiDPI
else
	xrandr --dpi 128	# Desktop 1440p scaled
fi
~/.screenlayout/main.sh	# Set up monitor layout
xrdb -merge ${XDG_CONFIG_HOME:-$HOME/.config}/x11/xresources	# Load base Xresources
setbg -s -c "$HOME/.local/share/wallpapers/cs-winter-1920x960.webp" "$HOME/.local/share/wallpapers/p9blue-2560x1440.png"	# solid bg + plan9 colorscheme

# Start gnome-keyring-daemon and export its environment variables
eval $(gnome-keyring-daemon --start --components=pkcs11,secrets,ssh)
export SSH_AUTH_SOCK

autostart="mpd picom dunst unclutter pipewire wireplumber conky"

for program in $autostart; do
	pgrep -x "$program" >/dev/null 2>&1 || "$program" &
done >/dev/null 2>&1

# dwmblocks is started by dwm's cool_autostart patch
