#!/bin/zsh

bspc config border_width        0
bspc config window_gap         10

bspc config borderless_monocle  true
bspc config gapless_monocle     true
bspc config focus_by_distance   true
bspc config initial_polarity second_child
bspc config split_ratio         0.6

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

# Monitors
case $HOST in
    laptop|hegp-laptop)
        bspc monitor eDP1 -d   1
        ;;
    home)
        bspc monitor HDMI2 -d     1
        bspc config single_monocle true
        bspc config top_monocle_padding 10
        ;;
    hegp)
        bspc monitor DP-0 -d    1
        ;;
esac

# Rules
bspc rule -a Slack desktop=
bspc rule -a TelegramDesktop desktop=
bspc rule -a qutebrowser desktop=
bspc rule -a Arandr state=floating
bspc rule -a Zathura state=tiled
bspc rule -a Pinentry state=floating
bspc rule -a Soffice state=tiled
bspc rule -a Emacs state=tiled
bspc rule -a kitty:Meteo monitor=^1 sticky=on state=floating rectangle=880x580+500+70

# Popup CLI apps
case $HOST in
    laptop)
        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
        ;;
    home)
        bspc rule -a kitty:Ranger sticky=on state=floating rectangle=1820x900+0+0 center=on
        bspc rule -a kitty:Music_playlist desktop=
        bspc rule -a kitty:Music_media desktop=
        bspc rule -a kitty:Volume sticky=on state=floating rectangle=600x400+1310+34
        bspc rule -a steam desktop=
        bspc rule -a emulationstation desktop= state=tiled
        ;;
    hegp)
        bspc rule -a "VirtualBox Machine" desktop=
        bspc rule -a kitty:Ranger sticky=on state=floating rectangle=3540x1500+0+0 center=on
        bspc rule -a kitty:Volume sticky=on state=floating rectangle=530x270+3100+64
        bspc rule -a kitty:Wiki sticky=on state=floating rectangle=840x986+490+64
        bspc rule -a kitty:Music_playlist sticky=on state=floating rectangle=500x700+30+64
        bspc rule -a kitty:Music_media sticky=on state=floating rectangle=500x700+30+804
        ;;
    hegp-laptop)
        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:Volume sticky=on state=floating rectangle=530x270+1360+64
        ;;
esac

qutebrowser &
mpd

# Desktop misc utils
greenclip daemon &
udiskie -s &
wmname compiz
dunst &
redshift &
picom --experimental-backends -b

# Wallpaper
case $HOST in
    hegp)
        hsetroot -fill .config/bspwm/cat_sitting_hegp.png
        ;;
    *)
        hsetroot -tile .config/bspwm/cat.png
        ;;
esac

xsetroot -cursor_name left_ptr
conky -d -c .config/conky/conkyrc &
panel &

# Applications
case $HOST in
    home)
        synergyc laptop
        steam &
        emulationstation --windowed &
        kitty --name Music_media ncmpcpp -s media_library &
        kitty --name Music_playlist ncmpcpp -s playlist &
        ;;
    laptop)
        nm-applet --sm-disable &
        synergys &
        ;;
    hegp-laptop)
        xsetwacom set "Wacom HID 48CA Pen stylus" "Button" "2" "button +3"
        nm-applet --sm-disable &
        autorotate &
        gnome-pie &
        onboard &
        libinput-gestures &
        ;;
    hegp)
        davmail &
        VBoxManage startvm win7 &
        ;;
esac

case $HOST in
    laptop|hegp-laptop)
        unclutter &
        telegram-desktop &
        slack &
        bspc config top_padding 14
        unison Sync &
        sleep 1
        tray &
        ;;
    hegp)
        unclutter &
        telegram-desktop &
        slack &
        bspc config top_padding 20
        unison Sync &
        sleep 1
        tray &
        ;;
    home)
        bspc config top_padding 34
        ;;
esac
