#!/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.
# Add local bin to PATH for scripts
export PATH="$HOME/.local/bin:$HOME/.local/bin/statusbar:$PATH"
# Auto-detect device type and set DPI accordingly
DEVICE_TYPE_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/srice/device-type"
if [ -f "$DEVICE_TYPE_FILE" ] && [ "$(cat "$DEVICE_TYPE_FILE")" = "laptop" ]; then
xrandr --dpi 180 # Laptop HiDPI (M1 Pro 14" ~254ppi retina panel; raise/lower for taste)
export XCURSOR_SIZE=32
else
xrandr --dpi 128 # Desktop 1440p scaled
fi
~/.screenlayout/main.sh # Set up monitor layout
setxkbmap -option caps:super # Caps Lock acts as Super
xrdb -merge ${XDG_CONFIG_HOME:-$HOME/.config}/x11/xresources # Load base Xresources
# HiDPI: on laptops tell Xft apps (st, dmenu, dwm bar) the real DPI and scale
# the cursor. Merged after the base so it wins.
if [ -f "$DEVICE_TYPE_FILE" ] && [ "$(cat "$DEVICE_TYPE_FILE")" = "laptop" ]; then
printf 'Xft.dpi: 180\nXcursor.size: 32\n' | xrdb -merge
fi
xset s off -dpms s noblank # Disable DPMS/screensaver (freezes with dual-GPU + 4 monitors)
setbg -s -c "$HOME/.local/share/wallpapers/plan9theme.png" "$HOME/.local/share/wallpapers/plan9.png" # plan9 solid bg + plan9 winter colorscheme
setfan & # Set case fan RGB (ice blue)
# Start gnome-keyring-daemon with unlocked login keyring (needed for ProtonMail Bridge)
eval $(echo -n "kris" | gnome-keyring-daemon --replace --unlock --components=pkcs11,secrets,ssh)
export SSH_AUTH_SOCK
# Audio: on systemd distros (Fedora) PipeWire is socket-activated by the user
# manager -- hand-starting it steals /run/user/UID/pipewire-0 and makes
# pipewire.socket hit its start limit, killing audio. Only hand-start on
# non-systemd inits (e.g. Artix runit).
if [ -d /run/systemd/system ]; then
systemctl --user start pipewire.socket pipewire-pulse.socket wireplumber.service 2>/dev/null
else
for p in pipewire wireplumber; do pgrep -x "$p" >/dev/null 2>&1 || "$p" & done
fi
autostart="mpd picom dunst unclutter conky protonmail-bridge blueman-applet"
for program in $autostart; do
pgrep -x "$program" >/dev/null 2>&1 || "$program" &
done >/dev/null 2>&1
# dwmblocks is started by dwm autostart