# TODO:
#
# + Super+r should rotate the selected group of windows.
# + Super+Control+{1-9} should control the size of the preselect space.
# + Super+Shift+b should balance the size of all selected nodes.

set $mod Mod4

xwayland enable
focus_wrapping no
smart_borders on
default_border pixel 2
focus_follows_mouse no
mouse_warping none
popup_during_fullscreen smart

input type:touchscreen {
	events disabled
}

input type:keyboard {
	repeat_delay 200
	repeat_rate 60
	# I have a keyboard that takes care of this on my workstation, so we only enable
	# this on laptops
	# xkb_options ctrl:nocaps
}

input type:pointer {
	accel_profile flat
	pointer_accel 0
}

input type:touchpad {
	dwt disabled
	tap enabled
	natural_scroll enabled
	middle_emulation enabled
	# pointer_accel 
}

bindsym $mod+control+space exec makoctl dismiss
bindsym $mod+shift+space exec makoctl invoke
bindsym $mod+return exec kitty --single-instance
bindsym $mod+shift+return exec floating-term
bindsym $mod+shift+alt+return exec kitty
bindsym $mod+c kill
bindsym $mod+shift+c kill # TODO: kill -9?
# bindsym $mod+shift+space exec wofi --show drun
bindsym $mod+space exec wofi --show drun
bindsym $mod+shift+s exec clipshot
bindsym $mod+e exec thunar
bindsym $mod+shift+r reload
bindsym $mod+control+Escape exit
bindsym $mod+shift+e exit
bindsym $mod+shift+p exec pass-chooser
bindsym $mod+control+j split v
bindsym $mod+control+l split h
bindsym $mod+control+f focus mode_toggle

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

bindsym $mod+left focus left
bindsym $mod+down focus down
bindsym $mod+up focus up
bindsym $mod+right 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+shift+left move left
bindsym $mod+shift+down move down
bindsym $mod+shift+up move up
bindsym $mod+shift+right move right

floating_modifier $mod normal

bindsym $mod+1 workspace 1
bindsym $mod+2 workspace 2
bindsym $mod+3 workspace 3
bindsym $mod+4 workspace 4
bindsym $mod+5 workspace 5
bindsym $mod+6 workspace 6
bindsym $mod+7 workspace 7
bindsym $mod+8 workspace 8
bindsym $mod+9 workspace 9
bindsym $mod+0 workspace 10

bindsym $mod+shift+1 move container to workspace 1
bindsym $mod+shift+2 move container to workspace 2
bindsym $mod+shift+3 move container to workspace 3
bindsym $mod+shift+4 move container to workspace 4
bindsym $mod+shift+5 move container to workspace 5
bindsym $mod+shift+6 move container to workspace 6
bindsym $mod+shift+7 move container to workspace 7
bindsym $mod+shift+8 move container to workspace 8
bindsym $mod+shift+9 move container to workspace 9
bindsym $mod+shift+0 move container to workspace 10

bindsym $mod+b splith
bindsym $mod+v splitv

bindsym $mod+shift+f fullscreen toggle
bindsym $mod+f floating toggle
bindsym $mod+s floating disable
bindsym $mod+alt+f focus mode_toggle
bindsym $mod+p focus parent
bindsym $mod+period focus child
bindsym $mod+comma focus child
bindsym $mod+tab workspace back_and_forth

bindsym $mod+minus gaps inner current minus 5
bindsym $mod+plus gaps inner current plus 5
bindsym $mod+control+alt+h gaps horizontal current minus 5
bindsym $mod+control+alt+l gaps horizontal current plus 5
bindsym $mod+control+alt+j gaps vertical current minus 5
bindsym $mod+control+alt+k gaps vertical current plus 5
# TODO: this should also reset the horizontal and vertical gaps?
bindsym $mod+control+equal gaps inner current set 0

bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5%
bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5%
bindsym control+XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +1%
bindsym control+XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -1%
bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle
bindsym XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle
bindsym XF86MonBrightnessDown exec brightnessctl set 10%-
bindsym XF86MonBrightnessUp exec brightnessctl set +10%
bindsym shift+XF86MonBrightnessDown exec brightnessctl set 1%
bindsym shift+XF86MonBrightnessUp exec brightnessctl set 100%
bindsym control+XF86MonBrightnessDown exec brightnessctl set 1%-
bindsym control+XF86MonBrightnessUp exec brightnessctl set +1%
bindsym XF86AudioPlay exec playerctl play-pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous
bindsym $mod+shift+v exec pactl set-source-mute @DEFAULT_SOURCE@ toggle

bindsym $mod+control+shift+l exec swaylock
# TODO: toggle-able swayidle?
# TODO: one-time swayidle/monitor-off
# bindsym $mod+Control+Shift+s exec lock-and-disable-monitors

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

	bindsym left resize shrink width 10 px or 10 ppt
	bindsym down resize grow height 10 px or 10 ppt
	bindsym up resize shrink height 10 px or 10 ppt
	bindsym right resize grow width 10 px or 10 ppt

	bindsym return mode "default"
	bindsym escape mode "default"
}

bar {
	swaybar_command waybar
}

set $tilers "(wezterm.*|kitty.*|firefox.*|slack.*|Slack.*|thunar.*|Alacritty.*|alacritty.*|Discord.*|discord.*)"
for_window [title=".*"] floating enable
for_window [app_id=$tilers] floating disable
bindsym $mod+shift+alt+f for_window [class=$tilers] floating toggle

# for_window [title=".*"] opacity $opacity

include /etc/sway/config.d/*
include $XDG_CONFIG_HOME/lytedev-env/*/sway/config

client.focused          #74c7ec #74c7ec #74c7ec #74c7ec #74c7ec
client.focused_inactive #100814 #100814 #9b9ebf #100814 #100814
client.unfocused        #100814 #100814 #9b9ebf #100814 #100814

# exec /usr/share/sway/scripts/inactive-windows-transparency.py --opacity 0.95

exec mako
# exec gammastep -t 6500:3500 -l 39.0:-94.5
# exec /usr/lib/kdeconnectd

exec kitty --single-instance
exec /usr/lib/polkit-kde-authentication-agent-1

exec swayidle -w \
	timeout 540 'notify-send "Idling in 90 seconds"' \
	timeout 570 'notify-send "Idling in 60 seconds"' \
	timeout 600 'notify-send "Idling in 30 seconds..."' \
	timeout 630 'swaylock -f' \
	timeout 660 'swaymsg "output * dpms off"' \
	resume 'swaymsg "output * dpms on" & maybe-good-morning &' \
	before-sleep 'swaylock -f'

# exec_always notify-send -a "sway" -i ~/.wallpaper "sway configuration loaded"

# prevent all windows from stealing focus
no_focus [class=".*"]

output * background $HOME/.wallpaper fill