set $mod Mod4

font pango:Maple Mono NL NF 11

title_align center
focus_wrapping no

# Use pactl to adjust volume in PulseAudio.
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5% && $refresh_i3status
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5% && $refresh_i3status
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status

floating_modifier $mod

tiling_drag modifier titlebar

bindsym $mod+Return exec ghostty

bindsym $mod+Shift+q kill

# start dmenu (a program launcher)
bindsym $mod+d exec --no-startup-id exec ~/dotfiles/gui/scripts/launcher.sh
bindsym $mod+Shift+x exec --no-startup-id exec ~/dotfiles/gui/scripts/power-menu.sh

bindsym $mod+h focus left
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l focus right

bindsym $mod+Shift+h move left
bindsym $mod+Shift+j move down
bindsym $mod+Shift+k move up
bindsym $mod+Shift+l move right

bindsym $mod+v split h
bindsym $mod+x split v

bindsym $mod+f fullscreen toggle

# bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

bindsym $mod+Shift+space floating toggle
bindsym $mod+space focus mode_toggle

bindsym $mod+Shift+minus move scratchpad
bindsym $mod+minus exec "~/dotfiles/gui/scripts/restore-scratchpad.sh"

bindsym $mod+a focus parent

set $ws1 "1"
set $ws2 "2"
set $ws3 "3"
set $ws4 "4"
set $ws5 "5"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws10 "10"

workspace $ws1 output DisplayPort-0
workspace $ws2 output HDMI-A-0
workspace $ws3 output DisplayPort-2
workspace $ws4 output DisplayPort-2
workspace $ws1 output DisplayPort-5
workspace $ws1 output DisplayPort-6

bindsym $mod+1 workspace $ws1
bindsym $mod+2 workspace $ws2
bindsym $mod+3 workspace $ws3
bindsym $mod+4 workspace $ws4
bindsym $mod+5 workspace $ws5
bindsym $mod+6 workspace $ws6
bindsym $mod+7 workspace $ws7
bindsym $mod+8 workspace $ws8
bindsym $mod+9 workspace $ws9
bindsym $mod+0 workspace $ws10

bindsym $mod+Shift+1 move container to workspace $ws1
bindsym $mod+Shift+2 move container to workspace $ws2
bindsym $mod+Shift+3 move container to workspace $ws3
bindsym $mod+Shift+4 move container to workspace $ws4
bindsym $mod+Shift+5 move container to workspace $ws5
bindsym $mod+Shift+6 move container to workspace $ws6
bindsym $mod+Shift+7 move container to workspace $ws7
bindsym $mod+Shift+8 move container to workspace $ws8
bindsym $mod+Shift+9 move container to workspace $ws9
bindsym $mod+Shift+0 move container to workspace $ws10

bindsym $mod+m exec "~/dotfiles/gui/scripts/swap-workspaces.sh"
bindsym $mod+Shift+m move workspace to output left

bindsym $mod+g exec "~/dotfiles/gui/scripts/screenshot.sh"
bindsym $mod+Shift+g exec "scrot -f -s -e 'mv $f ~/media/pictures/screenshots && cat ~/media/pictures/screenshots/$f | xclip -sel clip -t image/png -i'"

bindsym $mod+Shift+c reload
bindsym $mod+Shift+r restart

mode "resize" {
        bindsym h resize shrink width 5 px or 5 ppt
        bindsym j resize grow height 5 px or 5 ppt
        bindsym k resize shrink height 5 px or 5 ppt
        bindsym l resize grow width 5 px or 5 ppt

        bindsym Return mode "default"
        bindsym Escape mode "default"
        bindsym $mod+r mode "default"
        bindsym $mod+c mode "default"
}

bindsym $mod+r mode "resize"

for_window [window_role="pop-up"] floating enable
for_window [window_role="task_dialog"] floating enable
for_window [class="Lutris"] floating enable

for_window [instance="vol"] floating enable, resize set 800 500, move to scratchpad
for_window [instance="ttrm|sys"] floating enable, resize set 1000 680, move to scratchpad
for_window [class="scrcpy"] floating enable, move to scratchpad
for_window [class="Proton Pass"] floating enable, resize set 900 680, move position center
for_window [class="Protonvpn-app"] floating enable, resize set 400 700, move position center

for_window [class="iwgtk"] floating enable, position center
for_window [class="Gpick"] floating enable, move position center

assign [class="Spotify"] $ws4
assign [class="discord"] $ws3
assign [class="TelegramDesktop"] $ws3

gaps inner 12
gaps outer 0

default_border pixel
default_border pixel 3
default_floating_border pixel
default_floating_border pixel 3

hide_edge_borders none

popup_during_fullscreen smart

for_window [all] title_window_icon yes
for_window [all] title_window_icon padding 5

# Gruvbox Material Dark Hard Theme
set $clear       #00000000
set $bg_dark     #1d2021
set $bg_soft     #282828
set $bg_med      #3c3836
set $fg_main     #d4be98
set $fg_sub      #928374

# Accent Colors
set $red         #ea6962
set $orange      #e78a4e
set $yellow      #d8a657
set $green       #a9b665
set $aqua        #89b482
set $blue        #7daea3
set $purple      #d3869b

#                       Border    Background    Text        Indicator   Child Border
client.focused          $clear    $bg_soft      $fg_main    $blue       $blue
client.focused_inactive $clear    $bg_soft      $fg_main    $bg_med     $bg_med
client.unfocused        $clear    $bg_med       $fg_sub     $bg_med     $bg_med
client.urgent           $clear    $red          $fg_main    $red        $red   
client.background       $clear

exec --no-startup-id dex --autostart --environment i3

# exec --no-startup-id dbus-update-activation-environment --all
# exec --no-startup-id gnome-keyring-daemon --start --components=secrets

exec --no-startup-id ~/dotfiles/gui/scripts/picom.sh
exec --no-startup-id nm-applet

exec_always --no-startup-id "nitrogen --restore"

exec_always --no-startup-id ~/dotfiles/gui/scripts/polybar.sh

bindsym $mod+t exec "~/dotfiles/gui/scripts/launch-scratchpad.sh '/usr/bin/ghostty --gtk-single-instance=false --x11-instance-name=ttrm' 'ttrm'"
bindsym $mod+p exec "~/dotfiles/gui/scripts/launch-scratchpad.sh '/usr/bin/ghostty --gtk-single-instance=false --x11-instance-name=vol -e pulsemixer' 'vol'"
bindsym $mod+o exec "~/dotfiles/gui/scripts/launch-scratchpad.sh '/usr/bin/ghostty --gtk-single-instance=false --x11-instance-name=sys -e btop' 'sys'"
bindsym $mod+u exec "~/dotfiles/gui/scripts/launch-scratchpad.sh 'scrcpy -m 2048 -S -t' 'scrcpy'"
