#!/usr/bin/env bash

p='picom sxhkd polybar dunst'
for i in $p; do pkill "$i"; done

sxhkd &
dunst &

monitors=$(xrandr | grep -swc 'connected')

# I currently have a laptop and a desktop with 2 monitors
# This checks the number of monitors and then sets desktops
if [ "$monitors" -gt 1 ]; then
	bspc monitor HDMI-A-0 -d 1 2 3 4 5
	bspc monitor DisplayPort-0 -d 6 7 8 9 0
else
	bspc monitor -d 1 2 3 4 5 6 7 8 9 0
fi

bspc config border_width 2
bspc config window_gap 4
bspc config focus_follows_pointer true

bspc config split_ratio 0.52
bspc config borderless_monocle true
bspc config gapless_monocle true

bspc rule -a Android_Studio state=tiled
bspc rule -a Gimp state=floating follow=on
bspc rule -a Zathura state=tiled
bspc rule -a feh state=floating

# https://wiki.archlinux.org/index.php/Bspwm#Problems_with_Java_applications
wmname LG3D

# Set background
feh --bg-fill ~/Pictures/Wallpapers/laughingman.jpg &

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

# Compositor to prevent screen tearing
picom --config ~/.config/compton.conf -b

# Switch to a lefty mouse if mouse detected
if xinput list | grep -qi 'mouse'; then
	xmodmap -e "pointer = 3 2 1 " # swap mouse buttons
fi
