#! /bin/sh

# -----------------------------------------------------------------------------
# AUTOSTART
# -----------------------------------------------------------------------------
pgrep -x sxhkd >/dev/null || sxhkd &

# xrandr --output DP-0 --off --output DP-1 --off --output DP-2 --off --output HDMI-0 --primary --mode 2560x1080 --pos 0x0 --rotate normal --output DP-3 --mode 1920x1080 --pos 2560x0 --rotate normal --output DP-4 --off

killall -q polybar

# FIX CURSOR.
xsetroot -cursor_name left_ptr

# RUN NOTIFICATION DAEMON.
dunst --config $HOME/.config/dunst/dunstrc &

# SYSTRAY
# nm-applet &
# volctl &
# volumeicon &
# xbacklight -set 50
# sleep 3 && sbxkb &
# sleep 4 && udiskie --automount --notify --tray &

dunst &
unclutter &
# picom -m &
# picom --backend glx --vsync &
# picom &
numlockx &

# Lang Toggle
# setxkbmap "us,ru" ",winkeys" "grp:alt_shift_toggle"
# setxkbmap -layout us,ru -option grp:caps_toggle
setxkbmap -layout us,ru -option grp:alt_space_toggle

# BAR POLYBAR
polybar &
# ~/.config/polybar/./launch.sh --shapes &

# [[ -f ~/.Xresources ]] && xrdb -merge -I$HOME ~/.Xresources

# -----------------------------------------------------------------------------
# WALLPAPERS
# -----------------------------------------------------------------------------
# feh --bg-fill ~/Wallpapers/archkali.png &
feh --bg-scale ~/Pictures/wallpapers/1.webp &
# feh --randomize --bg-scale ~/Pictures/wallpapers &

# -----------------------------------------------------------------------------
# BSPWM
# -----------------------------------------------------------------------------

# bspc monitor -d I II III IV V VI VII VIII IX X
# bspc monitor -d '1:' '2:' '3:󰟞' '4:󰍩' '5:󰠮' '6:󰎄' '7:󱉟' '8:󰈫' '9:󰣠'
bspc monitor -d '1:' '2:' '3:󰟞' '4:󰍩' '5:󰠮' '6:󰒍' '7:󱉟' '8:󰈫' '9:󰣠' 

# TWO MONITORS XRANDR Laptop right
# bspc monitor HDMI-0 -d '1:' '2:' '3:󰟞' 
# bspc monitor DP-3 -d '4:󰍩' '5:󰠮' '6:󰒍' '7:󱉟' '8:󰈫' '9:󰣠'

# TWO MONITORS XRANDR Laptop left
# bspc monitor HDMI-0 -d '1:' '2:' '3:󰟞' 
# bspc monitor DP-3 -d '4:󰍩' '5:󰠮' '6:󰒍' '7:󱉟' '8:󰈫' '9:󰣠'

bspc config border_width 3
bspc config window_gap 4

# bspc config split_ratio 0.6
bspc config split_ratio 0.5
bspc config borderless_monocle true
bspc config gapless_monocle true

# bspc config focused_border_color "#de935f"
# bspc config focused_border_color "#FF0000"
bspc config focused_border_color "#FF4500"
bspc config normal_border_color "#373b41"
bspc config presel_feedback_color '#81a2be'

bspc rule -a firefox desktop='^2' follow=on focus=on
bspc rule -a TelegramDesktop desktop='^4' follow=on focus=on
bspc rule -a Element desktop='^4' follow=on focus=on

bspc rule -a calibre desktop='^7' follow=on focus=on

bspc rule -a obs desktop='^8' follow=on focus=on
bspc rule -a kdenlive desktop='^8' follow=on focus=on
bspc rule -a MuseScore4 desktop="^8" follow=on focus=on

bspc rule -a obsidian desktop='^5' focus=on follow=on
bspc rule -a qBittorrent desktop='^9' focus=on follow=on

bspc rule -a mpv state=floating focus=on follow=on
bspc rule -a KeePassXC state=floating focus=on follow=on rectangle=1600x900+160+90
bspc rule -a Galculator state=floating focus=on follow=on rectangle=400x200+0+0

# bspc rule -a Gimp desktop='^8' state=floating follow=on
# bspc rule -a Chromium desktop='^2'
# bspc rule -a mplayer2 state=floating
# bspc rule -a Kupfer.py focus=on
# bspc rule -a Screenkey manage=off

# -----------------------------------------------------------------------------
# SCRATCHPADS
# -----------------------------------------------------------------------------

# bspc rule -a keepassxc sticky=on state=floating rectangle=1600x900+160+90

bspc rule -a fterm sticky=on state=floating rectangle=1600x900+160+90
bspc rule -a cmus sticky=on state=floating rectangle=1600x900+160+90
bspc rule -a yazi sticky=on state=floating rectangle=1600x900+160+90
bspc rule -a ranger sticky=on state=floating rectangle=1600x900+160+90
bspc rule -a htop sticky=on state=floating rectangle=1600x900+160+90

# -----------------------------------------------------------------------------
# POST LOADING BSPWM
# -----------------------------------------------------------------------------
