# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!

set $alt Mod1
set $mod Mod4
font pango:Monaspace Argon, pango:Noto Color Emoji, pango:Symbols Nerd Font 16

################################################################################
## Custom Utility ##############################################################
################################################################################

set $UTILS exec --no-startup-id $DOTWRYN/config/bin/i3-utils

# Audio
bindsym XF86AudioRewind      $UTILS previous
bindsym XF86AudioPrev        $UTILS previous
bindsym XF86AudioForward     $UTILS next
bindsym XF86AudioNext        $UTILS next
bindsym XF86AudioPlay        $UTILS play-pause
bindsym XF86AudioRaiseVolume $UTILS volumeup
bindsym XF86AudioLowerVolume $UTILS volumedown
bindsym XF86AudioMute        $UTILS volumemute
bindsym XF86AudioMicMute     $UTILS micmute

# Screen brightness
bindsym XF86MonBrightnessUp   $UTILS backlightup
bindsym XF86MonBrightnessDown $UTILS backlightdown

# Quick applications
bindsym $mod+Shift+m $UTILS launch messages
bindsym $mod+Shift+d $UTILS launch discord
bindsym $mod+c       $UTILS launch voice
bindsym $mod+m       $UTILS launch ytmusic
bindsym $mod+Shift+s $UTILS launch spotify
bindsym $mod+a       $UTILS launch pavuctrl
bindsym $mod+Shift+p $UTILS launch scrcpy
bindsym $mod+Shift+o $UTILS launch obs

# Terminal
bindsym $mod+Return exec --no-startup-id i3-sensible-terminal

# Other
bindsym $mod+p $UTILS bgrandomize

bindsym $mod+Shift+minus $UTILS lock

bindsym $mod+space exec --no-startup-id dmenu_run -c -l 5 -fn 'DejaVuSansMono Nerd Font-25'

bindsym $mod+backslash $UTILS screenshot

################################################################################
## Window Management and Navigation ############################################
################################################################################

bindsym $mod+q kill

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+b split h
bindsym $mod+v split v

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

bindsym $mod+f fullscreen toggle
bindsym $mod+Shift+f focus parent; fullscreen; focus child

bindsym $mod+BackSpace open

bindsym $mod+1 workspace number "1"; exec --no-startup-id polybar-msg cmd show
bindsym $mod+2 workspace number "2"; exec --no-startup-id polybar-msg cmd hide
bindsym $mod+3 workspace number "3"; exec --no-startup-id polybar-msg cmd show
bindsym $mod+4 workspace number "4"; exec --no-startup-id polybar-msg cmd hide
bindsym $mod+5 workspace number "5"; exec --no-startup-id polybar-msg cmd show
bindsym $mod+6 workspace number "6"; exec --no-startup-id polybar-msg cmd hide
bindsym $mod+7 workspace number "7"; exec --no-startup-id polybar-msg cmd show
bindsym $mod+8 workspace number "8"; exec --no-startup-id polybar-msg cmd hide
bindsym $mod+9 workspace number "9"; exec --no-startup-id polybar-msg cmd show
bindsym $mod+0 workspace number "0"; exec --no-startup-id polybar-msg cmd hide
bindsym $mod+g workspace "🎮"; exec --no-startup-id polybar-msg cmd hide

bindsym $mod+Shift+1 move container to workspace number "1"
bindsym $mod+Shift+2 move container to workspace number "2"
bindsym $mod+Shift+3 move container to workspace number "3"
bindsym $mod+Shift+4 move container to workspace number "4"
bindsym $mod+Shift+5 move container to workspace number "5"
bindsym $mod+Shift+6 move container to workspace number "6"
bindsym $mod+Shift+7 move container to workspace number "7"
bindsym $mod+Shift+8 move container to workspace number "8"
bindsym $mod+Shift+9 move container to workspace number "9"
bindsym $mod+Shift+0 move container to workspace number "0"
bindsym $mod+Shift+g move container to workspace "🎮"

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

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

bindsym $mod+r mode "resize"

# floating window / scratchpad
bindsym $mod+Shift+space floating toggle
bindsym $mod+d focus mode_toggle
floating_modifier $mod

bindsym $mod+Shift+Tab move scratchpad
bindsym $mod+Tab scratchpad show

set $GAMES_CLIENT_CLASSES ^(steam)|(dolphin-emu)|(Visualboyadvance-m)|(steam_app_.*)$
bindsym $mod+Shift+x [class=$GAMES_CLIENT_CLASSES] scratchpad show

set $TERMINAL_EMULATOR_CLASSES ^(Alacritty)$
bindsym $mod+x [class=$TERMINAL_EMULATOR_CLASSES] scratchpad show

# floating window / notification compatibility
for_window [window_role="About"] floating enable
for_window [window_role="Organizer"] floating enable
for_window [window_role="Preferences"] floating enable
for_window [window_role="bubble"] floating enable
for_window [window_role="page-info"] floating enable
for_window [window_role="pop-up"] floating enable
for_window [window_role="task_dialog"] floating enable
for_window [window_role="toolbox"] floating enable
for_window [window_role="webconsole"] floating enable
for_window [window_type="dialog"] floating enable
for_window [window_type="menu"] floating enable
for_window [class="[xX]fce4-notifyd"] border pixel 0

# gaming stuff
for_window [class="^steam_app_"] move container to workspace "🎮"

################################################################################
## i3 Settings #################################################################
################################################################################

bindsym $mod+Shift+e exec $UTILS logout
bindsym Control+$alt+Delete exit
bindsym $mod+Shift+r restart
bindsym $mod+Shift+c reload


# i3-gaps settings
for_window [class="^.*"] border pixel 4
gaps inner 0
gaps outer 0


bindsym $mod+z       gaps outer current plus  2; gaps inner current plus  2;
bindsym $mod+shift+z gaps outer current minus 2; gaps inner current minus 2;

################################################################################
## Miscellaneous ###############################################################
################################################################################

exec --no-startup-id compton
exec --no-startup-id 1password --silent
exec --no-startup-id scwrypts omni tmux -- --background

# color settings
set $FOCUSED_BORDER       #006942
set $FOCUSED_BACKGROUND   #006942
set $FOCUSED_TEXT         #CCDDFF
set $FOCUSED_INDICATOR    #42AA69
set $FOCUSED_CHILD_BORDER #006942

set $INACTIVE_BORDER       #004269
set $INACTIVE_BACKGROUND   #004269
set $INACTIVE_TEXT         #CCDDFF
set $INACTIVE_INDICATOR    #4269AA
set $INACTIVE_CHILD_BORDER #004269

set $UNFOCUSED_BORDER       #420069
set $UNFOCUSED_BACKGROUND   #420069
set $UNFOCUSED_TEXT         #CCDDFF
set $UNFOCUSED_INDICATOR    #6942AA
set $UNFOCUSED_CHILD_BORDER #420069

set $URGENT_BORDER       #690042
set $URGENT_BACKGROUND   #690042
set $URGENT_TEXT         #CCDDFF
set $URGENT_INDICATOR    #AA4269
set $URGENT_CHILD_BORDER #690042

set $PLACEHOLDER_BORDER       #694200
set $PLACEHOLDER_BACKGROUND   #694200
set $PLACEHOLDER_TEXT         #CCDDFF
set $PLACEHOLDER_INDICATOR    #AA6942
set $PLACEHOLDER_CHILD_BORDER #694200

client.focused $FOCUSED_BORDER $FOCUSED_BACKGROUND $FOCUSED_TEXT $FOCUSED_INDICATOR $FOCUSED_CHILD_BORDER
client.focused_inactive $INACTIVE_BORDER $INACTIVE_BACKGROUND $INACTIVE_TEXT $INACTIVE_INDICATOR $INACTIVE_CHILD_BORDER
client.unfocused $UNFOCUSED_BORDER $UNFOCUSED_BACKGROUND $UNFOCUSED_TEXT $UNFOCUSED_INDICATOR $UNFOCUSED_CHILD_BORDER
client.urgent $URGENT_BORDER $URGENT_BACKGROUND $URGENT_TEXT $URGENT_INDICATOR $URGENT_CHILD_BORDER
client.placeholder $PLACEHOLDER_BORDER $PLACEHOLDER_BACKGROUND $PLACEHOLDER_TEXT $PLACEHOLDER_INDICATOR $PLACEHOLDER_CHILD_BORDER

#####################################################################
### Legacy Defaults #################################################
#####################################################################

# These settings are system-specific and are removed by
# 'scwrypts generate i3 config' I've left them in place so my
# defaults are in place on machines which still use the symlinked
# version of this config file rather than the generated one.

# for use after any command which should refresh the statusbar
set $refresh_statusbar killall -SIGUSR1 i3status
bar {
        status_command i3status
}