#### sway configuration

include /etc/sway/config.d/50-systemd-user.conf
include ./monitors

set $Alt   Mod1
set $Super Mod4
set $mod   Mod4

# Define names for default workspaces for which we configure key bindings later on.
# We use variables to avoid repeating the names in multiple places.
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"

# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

# move tiling windows via drag & drop by left-clicking into the title bar,
# or left-clicking anywhere into the window while holding the floating modifier.
tiling_drag modifier


### starting auxiliary applications

# start waybar
bar {
    swaybar_command waybar
    mode invisible
}

# start screen locker
exec swayidle -w \
    timeout 300 'swaylock -f -e -i ~/dotfiles/images/city_skyline.png' \
    timeout 330 'swaymsg "output * power off"; systemctl suspend' \
    resume 'swaymsg "output * power on"' \
    before-sleep 'swaylock -f -e -i ~/dotfiles/images/city_skyline.png'

exec sway-audio-idle-inhibit
for_window [class="steam_app.*"] inhibit_idle open

# NetworkManager is the most popular way to manage wireless networks on Linux,
# and nm-applet is a desktop environment-independent system tray GUI for it.
exec nm-applet

### configuring input
input type:keyboard {
    xkb_layout "us,us(intl),ch"
}
input type:pointer accel_profile flat
input type:pointer pointer_accel 0.53


### configuring keybindings

# reload the configuration file
bindsym $mod+Shift+c reload
# lock screen
bindsym $mod+Escape exec systemctl suspend
# kill focused window
bindsym $mod+Shift+q kill

# start programm launcher
bindsym $mod+d exec fuzzel

# start a terminal
bindsym $mod+Return exec foot

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

# alternatively, you can use the cursor keys:
bindsym $mod+Left  focus left
bindsym $mod+Down  focus down
bindsym $mod+Up    focus up
bindsym $mod+Right 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

# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left  move left
bindsym $mod+Shift+Down  move down
bindsym $mod+Shift+Up    move up
bindsym $mod+Shift+Right move right

# set splitting strategy
bindsym $mod+n layout splith
bindsym $mod+v layout splitv

# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle

# switch to workspace
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

# move focused container to workspace
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

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

# switch workspace
bindsym $mod+Shift+Tab workspace prev
bindsym $Alt+Shift+Tab workspace prev
bindsym $mod+Tab workspace next
bindsym $Alt+Tab workspace next

# move focused workspace to output
bindsym $mod+u move workspace to output left
bindsym $mod+i move workspace to output down
bindsym $mod+o move workspace to output up
bindsym $mod+p move workspace to output right

# switch keyboard layout
bindsym --locked $mod+Shift+n exec swaymsg input type:keyboard xkb_switch_layout next
bindsym --locked $mod+Shift+m exec bash sway-kb-layout-switcher.sh

# take screenshots
set $screenshot_directory "$HOME/Pictures/screenshots/"
exec_always mkdir -p $screenshot_directory
bindsym $mod+s       exec slurp | grim -g - - | wl-copy
bindsym $mod+Shift+s exec slurp | grim -g - "$screenshot_directory/$(date '+%Y%m%d_%H%M%S')_screenshot.png"

# use pactl for media keys
set $refresh_i3status killall -SIGUSR1 i3status
bindsym --locked XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5% && $refresh_i3status
bindsym --locked XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5% && $refresh_i3status
bindsym --locked XF86AudioMute        exec pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status
bindsym --locked XF86AudioMicMute     exec pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status
bindsym --locked XF86AudioPlay        exec playerctl play-pause
bindsym --locked XF86AudioPrev        exec playerctl previous
bindsym --locked XF86AudioNext        exec playerctl next
bindsym --locked XF86AudioStop        exec playerctl stop
bindsym $mod+a                        exec bash audio-sink-switcher.sh


### configuring behaviour

focus_follows_mouse no
mouse_warping none

### configuring presentation

# window border style
default_border pixel 1
default_floating_border pixel 0
for_window [class=".*"]  border pixel 1
for_window [app_id=".*"] border pixel 1

# gaps between windows and screen border
gaps inner 12px

# fonts
font pango:JetBrainsMonoNerdFont SemiBold 14

# defining colors
set $cyan       #15D7E5
set $magenta    #E02482
set $l_magenta  #FBADDD
set $d_blue     #001D42
set $indc_focus #A0A0FF
set $back_focus #FFFFFF
set $text_focus #000000
set $transp     #00000000

# class                 border   backgr.      text         indicator  child_border
client.focused          $cyan    $back_focus  $text_focus  $cyan      $cyan
client.focused_inactive $transp  $back_focus  $text_focus  $transp    $transp
client.unfocused        $transp  $back_focus  $text_focus  $transp    $transp
client.urgent           $transp  $back_focus  $text_focus  $transp    $transp
client.placeholder      $transp  $back_focus  $text_focus  $transp    $transp

# transparent windows
for_window [app_id="foot"] opacity 0.88
for_window [app_id="com.mitchellh.ghostty"] opacity 0.88
for_window [class="Alacritty"] opacity 0.88
for_window [class="SpeedCrunch"] opacity 0.93

