# vim: filetype=swayconfig

set $mod Mod4
set $altmod Mod4+Mod5
set $altmod2 Mod4+Shift
set $kbmod Alt_R
set $fwd m
set $left n
set $down e
set $up i
set $right o
set $bwd quotedbl

################ styles ####################
default_border pixel 1
smart_borders on
title_align center
font pango:{{ .theme.font.name_regular }} {{ math.Sub .theme.font.size_base_pt .theme.font.size_step_pt }}
output * bg #{{ .theme.color.bg }} solid_color
client.focused #{{ .theme.color.bg_accent_light }} #{{ .theme.color.bg_accent_light }} #{{ .theme.color.fg }} #{{ .theme.color.fg_accent }} #{{ .theme.color.bg_accent_light }}
client.focused_tab_title #{{ .theme.color.bg_accent_light }}{{ math.Mul .theme.opacity.med 255 | conv.ToInt64 | printf "%02X" }} #{{ .theme.color.bg_accent_light }}{{ math.Mul .theme.opacity.med 255 | conv.ToInt64 | printf "%02X" }} #{{ .theme.color.fg_dark }} #{{ .theme.color.fg_accent }} #{{ .theme.color.bg_accent_light }}{{ math.Mul .theme.opacity.low 255 | conv.ToInt64 | printf "%02X" }}
client.focused_inactive #{{ .theme.color.bg_accent_light }}{{ math.Mul .theme.opacity.med 255 | conv.ToInt64 | printf "%02X" }} #{{ .theme.color.bg_accent_light }}{{ math.Mul .theme.opacity.med 255 | conv.ToInt64 | printf "%02X" }} #{{ .theme.color.fg_dark }} #{{ .theme.color.fg_accent }} #{{ .theme.color.bg_accent_light }}{{ math.Mul .theme.opacity.low 255 | conv.ToInt64 | printf "%02X" }}
client.unfocused #{{ .theme.color.bg_accent_dark }} #{{ .theme.color.bg_accent_dark }} #{{ .theme.color.fg_dark }} #{{ .theme.color.fg_accent }} #{{ .theme.color.bg_accent_light }}{{ math.Mul .theme.opacity.low 255 | conv.ToInt64 | printf "%02X" }}
client.urgent #{{ .theme.color.fg_accent }} #{{ .theme.color.fg_accent }} #{{ .theme.color.fg }} #{{ .theme.color.fg_accent }} #{{ .theme.color.fg_accent }}
bar {
	position top
	font pango:{{ .theme.font.name_regular }} {{ .theme.font.size_base_pt }}
	status_command i3blocks
	strip_workspace_numbers yes
	separator_symbol |
	workspace_min_width 28
	tray_output none
	colors {
		statusline #{{ .theme.color.fg }}
		background #{{ .theme.color.bg }}
		separator #{{ .theme.color.fg_dark }}
		focused_workspace #{{ .theme.color.bg_accent_light }} #{{ .theme.color.bg_accent_light }} #{{ .theme.color.fg }}
		inactive_workspace #{{ .theme.color.bg_accent_dark }} #{{ .theme.color.bg_accent_dark }} #{{ .theme.color.fg }}
		urgent_workspace #{{ .theme.color.fg_accent }} #{{ .theme.color.fg_accent }} #{{ .theme.color.fg }}
		binding_mode #{{ .theme.color.fg_accent }} #{{ .theme.color.fg_accent }} #{{ .theme.color.fg }}
	}
}
###########################################

################ inputs ####################
input "type:keyboard" {
	xkb_layout us(yurmak),ru(yurmak)
	repeat_rate 50
}
bindsym --to-code $kbmod input "type:keyboard" xkb_switch_layout next; exec pkill -SIGRTMIN+1 i3blocks
input "type:touchpad" {
	tap enabled
	natural_scroll enabled
}
############################################

############### workspaces #################
bindsym --to-code {
	$mod+a workspace 1:A
	$mod+r workspace 2:R
	$mod+s workspace 3:S
	$mod+t workspace 4:T
	$mod+g workspace 5:G
	$altmod+a move container to workspace 1:A; workspace 1:A
	$altmod+r move container to workspace 2:R; workspace 2:R
	$altmod+s move container to workspace 3:S; workspace 3:S
	$altmod+t move container to workspace 4:T; workspace 4:T
	$altmod+g move container to workspace 5:G; workspace 5:G
}
bindgesture swipe:right workspace prev
bindgesture swipe:left workspace next
############################################

############### containers #################
# top row - layouts
bindsym --to-code {
	$mod+p layout splith
	$altmod+p split h
	$mod+l layout splitv
	$altmod+l split v
	$mod+f fullscreen
	$mod+w layout tabbed
	$altmod+w split v; layout tabbed
	$mod+u split none
	$mod+y layout stacking
	$altmod+y split h; layout stacking
}
# mid row - focus, movement
bindsym --to-code {
	$mod+$fwd focus child
	$mod+$left focus left
	$mod+$up focus up
	$mod+$down focus down
	$mod+$right focus right
	$mod+$bwd focus parent
	$altmod+$left move left 40px
	$altmod+$up move up 40px
	$altmod+$down move down 40px
	$altmod+$right move right 40px
	$altmod2+$left resize shrink width 2ppt or 40px
	$altmod2+$up resize shrink height 4ppt or 40px
	$altmod2+$down resize grow height 4ppt or 40px
	$altmod2+$right resize grow width 2ppt or 40px
}
# bottom row - 3d
bindsym --to-code {
	$mod+d scratchpad show
	$altmod+x sticky enable; move scratchpad
	$mod+z focus tiling
	$altmod+z focus floating; floating disable; sticky disable
	$mod+h focus floating
	$altmod+h floating enable; sticky enable
	$mod+k focus prev sibling
	$mod+Comma opacity minus 0.05
	$mod+Period opacity plus 0.05
	$mod+slash focus next sibling
	$mod+x exec wtype -M ctrl x -m ctrl
	$mod+c exec wtype -M ctrl c -m ctrl
	$mod+v exec wtype -M ctrl v -m ctrl
}
floating_modifier $mod normal
############################################

################## actions ####################
bindsym --to-code {
	# generic
	$mod+Escape kill
	# media
	XF86MonBrightnessDown exec ~/.local/bin/sway/brightness-set-and-notify.sh 5%-
	XF86MonBrightnessUp exec ~/.local/bin/sway/brightness-set-and-notify.sh 5%+
	XF86AudioMute exec pactl set-sink-mute \@DEFAULT_SINK@ toggle && pkill -SIGRTMIN+2 i3blocks
	XF86AudioLowerVolume exec pactl set-sink-volume \@DEFAULT_SINK@ -5% && pkill -SIGRTMIN+2 i3blocks
	XF86AudioRaiseVolume exec pactl set-sink-volume \@DEFAULT_SINK@ +5% && pkill -SIGRTMIN+2 i3blocks
	XF86AudioMicMute exec pactl set-source-mute \@DEFAULT_SOURCE@ toggle && pkill -SIGRTMIN+2 i3blocks
	# basic scripts
	$mod+Colon exec ~/.local/bin/sway/command-mode.sh
	$mod+Return exec footclient
	$mod+Space exec run.sh
}
##############################################

################# daemons ####################
exec foot -s
exec mako
exec swayidle
##############################################

############## app-specific ##################
for_window [app_id="_float"] floating enable, resize set 960 540
##############################################