#!/bin/bash

# autostart
bash $HOME/.config/bspwm/scripts/autostart.sh

# use 1 to use the scripts/monitor.sh file (configure it file editing it!)
MONITOR_SUPPORT=0

function setopt () {
  bspc config "$1" "$2"
}

# borders and gaps
setopt border_width 1
setopt window_gap 12

setopt normal_border_color "#162026"
setopt focused_border_color "#484e5b"

# behaviour stuff
setopt split_ratio 0.52
setopt borderless_monocle false
setopt gapless_monocle false
setopt single_monocle false

# pointer
setopt focus_follows_pointer true
setopt pointer_follows_focus true
setopt pointer_follows_monitor true

# fullscreen
bspc subscribe node_state | while read -r _ _ _ _ state flag; do
  if [ "$state" != "fullscreen" ]; then
    continue
  fi
  if [ "$flag" == on ]; then
    setopt top_padding 0
    pkill polybar
  else
    setopt top_padding 35
    bash $HOME/.config/polybar/launch.sh
  fi
done &

# plank compatibility
bspc rule -a Plank layer=above manage=on border=off

# monitor
if [[ $MONITOR_SUPPORT == 1 ]]; then
  bash $HOME/.config/bspwm/scripts/monitor.sh
else
  bspc monitor primary -d I II III IV V VI
fi
