#! /bin/sh

# monitor setup
if [[ $(cat /etc/hostname) == "gojou" ]]; then
    bspc monitor DP-0 -d 1 2 3 4 5 101
    bspc monitor HDMI-0 -d 6 7 8 9 102
elif [[ $(cat /etc/hostname) == "uzui" ]]; then
    bspc monitor -d 1 2 3 4 5 6 7 8 9 101
else
    bspc monitor -d 1 101
fi

echo $(cat /etc/hostname) > "${XDG_CACHE_HOME}"/device_hostname

bspc wm -O DP-0 HDMI-0

echo "landscape" > "${XDG_CACHE_HOME}"/window_mode
WINDOW_MODE=$(cat "${XDG_CACHE_HOME}"/window_mode)
pkill actuator
actuator "${XDG_CONFIG_HOME}/actuator/$(cat /etc/hostname)/${WINDOW_MODE}.toml" &

# change window settings
bspc config border_width         2
bspc config window_gap          12

# change tiling settings
bspc config split_ratio          0.5
bspc config borderless_monocle   true
bspc config gapless_monocle      true


# sxhkd shortcut start
pgrep -x sxhkd > /dev/null || sxhkd &

# get env vars
. "${HOME}/.zshenv"

# set background
. "${FEH_HOME}/.fehbg"

# launch polybar
$HOME/.config/polybar/launch.sh


# source wal colors
. "${HOME}/.cache/theme/variables.sh"

# launch picom
picom -b

# fix intelliJ kekw
wmname LG3D

# change pointer config to super
bspc config pointer_modifier mod4

# pointer actions on untiled windows
bspc config pointer_action1 move
bspc config pointer_action2 resize_side

# change color of border to the bright red
bspc config normal_border_color "$color15"
bspc config active_border_color "$color02"
bspc config focused_border_color "$color01"
bspc config presel_feedback_color "$color04"

# set window rules
bspc rule -a feh state=floating
bspc rule -a mpv state=floating
bspc rule -a Zathura state=tiled
bspc rule -a discord desktop='8'
bspc rule -a Element desktop='8'
bspc rule -a helvum desktop='9' focus=on follow=on state=floating
bspc rule -a Pavucontrol desktop='9' focus=on follow=on state=floating
bspc rule -a obs desktop='9' focus=on follow=on
bspc rule -a Spotify desktop='7'

# spotify smh
bspc config external_rules_command "$XDG_CONFIG_HOME/bspwm/nprogs.sh"

# discord smh
betterdiscordctl reinstall

# starting programs
udiskie -n &
dunst &

# lock screen
xset s on
xset s 600
xss-lock -n /usr/lib/xsecurelock/dimmer -l -- xsec &

# set cursor on
xsetroot -cursor_name left_ptr &
