#!/bin/zsh

bspc config border_width        0
bspc config window_gap         10

bspc config split_ratio         0.4
bspc config borderless_monocle  true
bspc config gapless_monocle     true
bspc config focus_by_distance   true
bspc config initial_polarity first_child

bspc config remove_unplugged_monitors true
bspc config ignore_ewmh_focus true

bspc config click_to_focus any
bspc config pointer_modifier mod4
bspc config pointer_action1 move
bspc config pointer_action2 resize_corner

bspc config presel_feedback_color "#FFFFFF"

echo 1 > /tmp/lastdesk
if [ "$HOST" = "laptop" ];then
  bspc monitor eDP1 -d    1
elif [ "$HOST" = "hegp" ];then
  bspc monitor HDMI1 -d    1
  bspc monitor VGA1 -d I II
elif [ "$HOST" = "home" ];then
  bspc monitor HDMI2 -d  1
fi

bspc rule -a Slack desktop=
bspc rule -a TelegramDesktop desktop=
bspc rule -a Skype desktop= state=tiled
bspc rule -a Thunderbird desktop=
bspc rule -a qutebrowser desktop=
bspc rule -a Galculator state=floating
bspc rule -a Arandr state=floating
bspc rule -a Zathura state=tiled
bspc rule -a Pinentry state=floating
bspc rule -a Soffice state=tiled

# Figures and PDFs on second monitor
if [ "$HOST" = "hegp" ];then
  bspc rule -a R_x11 monitor=^2
  bspc rule -a Zathura monitor=^2
fi

# Popup CLI apps
if [ "$HOST" = "laptop" ];then
  bspc rule -a kitty:Ranger sticky=on state=floating rectangle=1820x900+0+0 center=on
  bspc rule -a kitty:Music_playlist sticky=on state=floating rectangle=430x470+30+64
  bspc rule -a kitty:Music_media sticky=on state=floating rectangle=430x476+30+574
  bspc rule -a kitty:Music_playlist_home sticky=on state=floating rectangle=430x470+30+64
  bspc rule -a kitty:Music_media_home sticky=on state=floating rectangle=430x476+30+574
  bspc rule -a kitty:Wiki sticky=on state=floating rectangle=840x986+490+64
  bspc rule -a kitty:Volume sticky=on state=floating rectangle=530x270+1360+64
  bspc rule -a kitty:Torrent sticky=on state=floating rectangle=530x676+1360+374
elif [ "$HOST" = "hegp" ];then
  bspc rule -a kitty:Volume monitor=^1 sticky=on state=floating rectangle=490x300+1170+30
  bspc rule -a kitty:Wiki monitor=^1 sticky=on state=floating rectangle=1000x1000+350+30
  bspc rule -a kitty:Ranger monitor=^1 sticky=on state=floating rectangle=1550x900+0+0 center=on locked=on
  bspc rule -a kitty:Music_playlist sticky=on state=floating rectangle=430x470+30+64
  bspc rule -a kitty:Music_media sticky=on state=floating rectangle=430x476+30+574
elif [ "$HOST" = "home" ];then
  bspc rule -a kitty:Ranger sticky=on state=floating rectangle=1820x900+0+0 center=on
  bspc rule -a kitty:Music_playlist sticky=on state=floating rectangle=945x1036+10+34
  bspc rule -a kitty:Music_media sticky=on state=floating rectangle=945x1036+965+34
  bspc rule -a kitty:Volume sticky=on state=floating rectangle=600x400+1310+34
fi
bspc rule -a kitty:Meteo monitor=^1 sticky=on state=floating rectangle=880x580+500+625
bspc rule -a kitty:evimwhere state=floating rectangle=920x580+500+250

mpd
greenclip daemon &
udiskie -s &

wmname compiz
dunst &
redshift &
compton -b
xsetroot -cursor_name left_ptr
if [ "$HOST" = "hegp" ];then
  hsetroot -fill .config/bspwm/cat_sitting.png
else
  hsetroot -tile .config/bspwm/cat.png
fi
conky -d -c .config/conky/conkyrc &
panel &
popup Ranger ranger &

sleep 1

if [ "$HOST" = "home" ];then
  synergyc laptop
else
  tray &
  thunderbird &
  unclutter &
  telegram-desktop &
  slack &
fi

meteo
qutebrowser &
popup Ranger

if [ "$HOST" = "laptop" ];then
  nm-applet --sm-disable &
  synergys &
fi

bspc config top_padding 14
