#!/bin/sh

# configure monitors
xrandr --output DisplayPort-0 --mode 1920x1080 --rate 144 --primary --left-of HDMI-A-0 --output HDMI-A-0 --mode 1920x1080 --rate 60
# increase key repeat rate
xset r rate 300 50
# set the wallpaper
xwallpaper --zoom ${XDG_DATA_HOME:-HOME/.local/share}/bg.jpg
# load xresources
xrdb ${XDG_CONFIG_HOME:-$HOME/.config}/x11/xresources & xrdbpid=$!

# define and run autostart background programs
redshift -l $(curl -s "https://location.services.mozilla.com/v1/geolocate?key=geoclue" | awk 'OFS=":" {print $3,$5}' | tr -d ',}') &
autostart="pipewire pipewire-pulse wireplumber xcompmgr dwmblocks mpd redshiftcmd lxsession"
for program in $autostart; do
	pidof -s "$program" || "$program" &
done >/dev/null 2>&1

# Ensure that xrdb has finished running before moving on to start the WM/DE.
[ -n "$xrdbpid" ] && wait "$xrdbpid"
