# set key variables
set $mod Mod4
set $alt Mod1

# set desktop information
exec dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP="sway:KDE"

# set display scaling

output DP-3 {
  scale 1.35
  mode 2560x1440@75Hz
}

# set font

font pango: Ubuntu Regular 14

input type:keyboard {
  # enable numlock
  xkb_numlock enable

  # remap capslock to esc & ralt to compose
  xkb_options "caps:escape,compose:ralt"
}

# start waybar
bar { 
  swaybar_command waybar
}

exec /usr/lib/xdg-desktop-portal -r &
exec /usr/lib/xdg-desktop-portal-kde
exec /usr/lib/xdg-desktop-portal-wlr

exec /usr/lib/polkit-kde-authentication-agent-1

exec wl-paste -t text --watch clipman store
exec wl-paste -p -t text --watch clipman store -P --histpath="$XDG_DATA_HOME/clipman-primary.json"

exec pipewire &
exec mako

exec swayflashy
exec autotiling-rs

# swayidle timeout 30 "makoctl set-mode away" resume "makoctl set-mode default"

exec eval (ssh-agent -c)

# set wallpaper
exec swaybg -i $XDG_PICTURES_DIR/wallpapers/73085922_p0.jpg

# set pactl to adjust volume in pipewire-pulse
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +1%
bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -1%
bindsym XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle

# Media player controls
bindsym XF86AudioPlay exec playerctl play-pause
bindsym XF86AudioPause exec playerctl play-pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous

# screenshot with grim
bindsym $mod+Print mode "screenshot"; exec killall swayflashy

mode "screenshot" {
  bindsym s exec grimshot save screen
  bindsym Shift+s exec grimshot save area
  bindsym $alt+s exec grimshot save window

  bindsym c exec grimshot copy screen
  bindsym Shift+c exec grimshot copy area
  bindsym $alt+c exec grimshot copy window

  bindsym Escape mode "default"; exec swayflashy
}

bindsym $mod+i mode "language"

# language selection mode

mode "language" {
  bindsym t exec ibus engine table:tokipona; mode "default"
  bindsym e exec ibus engine xkb:us::eng; mode "default"
  bindsym Return exec ibus engine xkb:us::eng; mode "default"
  bindsym Escape mode "default"
}

# window actions

floating_modifier $alt

bindsym $mod+x kill
bindsym $mod+f fullscreen toggle

# floating mode toggle and focus
bindsym $mod+Shift+space floating toggle
bindsym $mod+space focus mode_toggle

# lock screen
bindsym --release $mod+escape exec swaylock --screenshots --effect-blur 7x7

# tools
bindsym $mod+t exec foot
bindsym $mod+d exec fuzzel 
bindsym $mod+w exec clipman pick --tool=CUSTOM --tool-args="fuzzel -d -w 60"

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

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

# workspaces

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"

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

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

# reload the configuration file
bindsym $mod+Shift+c reload

# restart inplace
bindsym $mod+Shift+r exec swaymsg restart

# resize window

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 Return mode "default"
  bindsym Escape mode "default"
  bindsym $mod+r mode "default"
}

bindsym $mod+r mode "resize"

# window borders and gaps

default_border none
default_floating_border none

gaps inner 5
gaps outer 5

corner_radius 15

# autostart applications

exec mpd
exec keepassxc
exec syncthing
exec sleep 120 && noisetorch -i
exec discord
exec ibus-daemon -rxR

# window rules

for_window [app_id="org.kde.polkit-kde-authentication-agent-1"] floating enable
for_window [app_id="org.freedesktop.impl.portal.desktop.kde"] floating enable
