### Variables

# Set logo key as main modifier
set $mod Mod4

# Colors
set $foreground #c0caf5
set $highlight #bb9af7
set $wallpaper ~/.config/wallpapers/taylor-bw.jpg
set $lock_cmd swaylock --daemonize --image $wallpaper
set $sleep_cmd systemctl suspend
set $launcher_cmd wofi --show drun --no-actions --insensitive --prompt 'Run' | xargs swaymsg exec --

# Set color for focused window
client.focused $highlight $highlight $foreground

### Outputs

# Set wallpaper
output * bg $wallpaper fill

### Idle

# Lock the screen after 300 seconds of inactivity, then turn off
# all displays after another 300 seconds, and turn the screens back on when
# resumed. It will also lock the screen before the computer goes to sleep.
exec swayidle -w \
    timeout 900 '$lock_cmd' \
    timeout 1200 'swaymsg "output * dpms off"' \
    resume 'swaymsg "output * dpms on"' \
    timeout 1800 '$sleep_cmd' \
    before-sleep 'playerctl pause' \
    before-sleep '$lock_cmd' \
    lock '$lock_cmd'

# Inhibit idle if a window is in fullscreen
for_window [shell=".*"] inhibit_idle fullscreen

# Prevent Brave from inhibiting shortcuts
for_window [app_id="^brave-.*-.*$"] shortcuts_inhibitor disable

### Status Bar

bar {
    swaybar_command waybar
}

### Windows

# Hide window title bars and borders
default_border pixel
hide_edge_borders smart

### Inputs

# Mouse
# Hide mouse cursor when not used
seat * hide_cursor 8000

# Touchpad
input type:touchpad {
    tap enabled
    natural_scroll enabled
}

# Keyboard
input type:keyboard {
    # Map caps lock to escape and use right alt as compose key to create umlauts
    # To actually create them, type the following keys in a sequence:
    # ralt + " + u --> ü
    xkb_options caps:escape,compose:ralt
}

### Key bindings

# App launcher
bindsym $mod+space exec $launcher_cmd

# Launch terminal
bindsym $mod+Return exec $TERMINAL

# Launch browser
bindsym $mod+w exec $BROWSER

# Take screenshots
bindsym Print exec grim "${HOME}/Downloads/screenshot-$(date +'%F-%H-%M-%S').png"
bindsym Print+$mod exec grim -g "$(slurp)" "${HOME}/Downloads/screenshot-$(date +'%F-%H-%M-%S').png"

# Lock screen
bindsym $mod+ctrl+q exec loginctl lock-session

# Media control
bindsym --locked XF86AudioRaiseVolume exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+
bindsym --locked XF86AudioLowerVolume exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-
bindsym --locked XF86AudioMute exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
bindsym --locked XF86AudioMicMute exec wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle
bindsym --locked XF86MonBrightnessDown exec brightnessctl set 5%-
bindsym --locked XF86MonBrightnessUp exec brightnessctl set +5%
bindsym --locked XF86AudioPlay exec playerctl play-pause
bindsym --locked XF86AudioNext exec playerctl next
bindsym --locked XF86AudioPrev exec playerctl previous
bindsym XF86Search exec $launcher_cmd

# Kill focused window
bindsym $mod+q kill

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

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

# Move the focused window with the same, but add Shift
bindsym $mod+Shift+h move left
bindsym $mod+Shift+j move down
bindsym $mod+Shift+k move up
bindsym $mod+Shift+l move right

# Switch to workspace
bindsym $mod+1 workspace number 1
bindsym $mod+2 workspace number 2
bindsym $mod+3 workspace number 3
bindsym $mod+4 workspace number 4
bindsym $mod+5 workspace number 5
bindsym $mod+6 workspace number 6
bindsym $mod+7 workspace number 7
bindsym $mod+8 workspace number 8
bindsym $mod+9 workspace number 9
bindsym $mod+0 workspace number 10
bindsym $mod+tab workspace back_and_forth

# Move focused container to workspace
bindsym $mod+Shift+1 move container to workspace number 1; workspace number 1
bindsym $mod+Shift+2 move container to workspace number 2; workspace number 2
bindsym $mod+Shift+3 move container to workspace number 3; workspace number 3
bindsym $mod+Shift+4 move container to workspace number 4; workspace number 4
bindsym $mod+Shift+5 move container to workspace number 5; workspace number 5
bindsym $mod+Shift+6 move container to workspace number 6; workspace number 6
bindsym $mod+Shift+7 move container to workspace number 7; workspace number 7
bindsym $mod+Shift+8 move container to workspace number 8; workspace number 8
bindsym $mod+Shift+9 move container to workspace number 9; workspace number 9
bindsym $mod+Shift+0 move container to workspace number 10

# Splitting direction
bindsym $mod+b split toggle

# Make current focus fullscreen
bindsym $mod+f fullscreen

# Resizing containers
bindsym $mod+r mode 'resize'
mode 'resize' {
    # Resizing keys
    bindsym h resize shrink width 10px
    bindsym j resize grow height 10px
    bindsym k resize shrink height 10px
    bindsym l resize grow width 10px

    # Return to default mode
    bindsym Escape mode 'default'
}

### Gesture bindings

# Swipe back and forth between workspaces
bindgesture swipe:3:left workspace prev_on_output
bindgesture swipe:3:right workspace next_on_output

### Processes

# Desktop notifications
exec mako

# Automatically manage outputs
exec kanshi

# Adjust color temperature to reduce eye strain
exec gammastep

# Autotiling
exec autotiling-rs

# Waybar Icons
exec_always --no-startup-id workstyle &> /tmp/workstyle.log

# Clipboard manager
exec wl-paste --type text --watch clipman store
bindsym $mod+v exec clipman pick --tool wofi

include /etc/sway/config.d/*
