# Default config for sway
# vim: ft=i3
#
# Read `man 5 sway` for a complete reference.
#

### Variables
#
# Logo key. Use Mod1 for Alt.
set $mod Mod4
# Home row direction keys, like vim
set $left h
set $down j
set $up k
set $right l
# Your preferred terminal emulator
set $term termite
set $background $HOME/Cloud/xkonni/Pictures/wallpaper/5k_bavarian_forest_bw.jpg
set $lock_cmd $HOME/.config/sway/bin/sway_lock
set $brightness_cmd $HOME/.config/sway/bin/sway_brightness
set $output_cmd $HOME/.config/sway/bin/sway_output
set $suspend_cmd $HOME/.config/sway/bin/sway_suspend
set $volume_cmd $HOME/.config/sway/bin/sway_volume
set $move_cmd $HOME/.config/sway/bin/sway_move
set $font Cascadia Code PL Regular 10

# Your preferred application launcher
set $menu wofi --show drun --prompt applications
set $search_cmd $HOME/.config/sway/bin/sway_search


#
# Host Specific
#
include $HOME/.config/sway/hosts.d/$(hostname).conf

#
# General Options
#
focus_wrapping no
mouse_warping container
# floating_maximum_size 1600 x 900
font pango:$font
hide_edge_borders --i3 smart
smart_gaps off
default_border pixel 4
#
# Gaps
#
gaps inner 5
gaps outer 0
gaps left 0
gaps right 0


### Output configuration
output * bg $background fill
# Example configuration:
#   output HDMI-A-1 resolution 1920x1080 position 1920,0
# You can get the names of your outputs by running: swaymsg -t get_outputs

### Idle configuration
#   10 min    screen off
#   15 min    lock
#   30 min    suspend on battery
#  120 min    suspend
exec swayidle -w \
       timeout 600 '$lock_cmd off' \
           resume '$lock_cmd on' \
       timeout 900 '$lock_cmd lockonly' \
       timeout 1800 '$suspend_cmd suspend' \
       timeout 7200 '$suspend_cmd force' \
       before-sleep '$lock_cmd lock'
bindsym $mod+Ctrl+Escape exec '$lock_cmd lock'

### Input configuration
# You can get the names of your inputs by running: swaymsg -t get_inputs
# Read `man 5 sway-input` for more information about this section.
input type:keyboard {
  xkb_layout "eu"
}

### Key bindings
#
# Basics:
#
# Start a terminal
bindsym $mod+Return exec $term

# Kill focused window
bindsym $mod+Shift+q kill
bindsym --release button3 kill

# Start your launcher
bindsym $mod+r exec $menu
bindsym $mod+Shift+r exec $search_cmd

# Drag floating windows by holding down $mod and left mouse button.
# Resize them with right mouse button + $mod.
# Despite the name, also works for non-floating windows.
# Change normal to inverse to use left mouse button for resizing and right
# mouse button for dragging.
floating_modifier $mod normal

# Reload the configuration file
bindsym $mod+Ctrl+r reload

# Exit sway (logs you out of your Wayland session)
bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit'
#
# Moving around:
#
# Move your focus around
bindsym $mod+$left focus left
bindsym $mod+$down focus down
bindsym $mod+$up focus up
bindsym $mod+$right focus right
# Move the focused window with the same, but add Shift
bindsym $mod+Shift+$left move left
bindsym $mod+Shift+$down move down
bindsym $mod+Shift+$up move up
bindsym $mod+Shift+$right move right
#
# Resize
#
bindsym $mod+Ctrl+$left resize shrink width 50px
bindsym $mod+Ctrl+$down resize grow height 50px
bindsym $mod+Ctrl+$up resize shrink height 50px
bindsym $mod+Ctrl+$right resize grow width 50px
#
# Workspaces:
#
# 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+Escape workspace back_and_forth
# Move focused container to workspace
bindsym $mod+Shift+1 move container to workspace number 1
bindsym $mod+Shift+2 move container to workspace number 2
bindsym $mod+Shift+3 move container to workspace number 3
bindsym $mod+Shift+4 move container to workspace number 4
bindsym $mod+Shift+5 move container to workspace number 5
bindsym $mod+Shift+6 move container to workspace number 6
bindsym $mod+Shift+7 move container to workspace number 7
bindsym $mod+Shift+8 move container to workspace number 8
bindsym $mod+Shift+9 move container to workspace number 9
bindsym $mod+Shift+0 move container to workspace number 10
# Note: workspaces can have any name you want, not just numbers.
# We just use 1-10 as the default.
#
# Urgent
#
bindsym $mod+u [urgent=latest] focus
#
# Layout stuff:
#
# You can "split" the current object of your focus with
# $mod+b or $mod+v, for horizontal and vertical splits
# respectively.
bindsym $mod+b splith
bindsym $mod+v splitv

# Switch the current container between different layout styles
bindsym $mod+q layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

# Make the current focus fullscreen
bindsym $mod+f fullscreen

# Toggle the current focus between tiling and floating mode
bindsym $mod+Shift+space floating toggle
bindsym $mod+Shift+b border toggle

# Swap focus between the tiling area and the floating area
bindsym $mod+space focus mode_toggle

# Move focus to the parent container
bindsym $mod+a focus parent

#
## Volume
#
bindsym XF86AudioRaiseVolume exec $volume_cmd increase
bindsym XF86AudioLowerVolume exec $volume_cmd decrease
bindsym XF86AudioMute exec $volume_cmd mute
bindsym XF86MonBrightnessUp exec $brightness_cmd increase
bindsym XF86MonBrightnessDown exec $brightness_cmd decrease
#
#
## Screenshot
#
# copy selection to clipboard
bindsym Print exec grim -g "$(slurp)" - | wl-copy
# copy selection to swappy
bindsym Shift+Print exec grim -g "$(slurp)" - | swappy -f -
# save selection
bindsym $mod+Print exec grim -g "$(slurp)" \
    $(xdg-user-dir PICTURES)/screenshot_$(date +'%Y%m%d_%H%M%S').png
#
## Output
#
bindsym $mod+p exec "$term -t float -e $output_cmd"

#
# Gaps
#
gaps inner 5
gaps outer 0
gaps left 0
gaps right 0

#
# Scratchpad:
#
# Move the currently focused window to the scratchpad
bindsym $mod+Shift+s mark s; move scratchpad
bindsym $mod+Shift+z mark z; floating enable; resize set width 1200; resize set height 700; move scratchpad
bindsym $mod+Shift+x mark x; floating enable; resize set width 1200; resize set height 700; move scratchpad
bindsym $mod+Shift+c mark c; floating enable; resize set width 1200; resize set height 700; move scratchpad
bindsym $mod+s [con_mark="s"] scratchpad show
bindsym $mod+z [con_mark="z"] scratchpad show
bindsym $mod+x [con_mark="x"] scratchpad show
bindsym $mod+c [con_mark="c"] scratchpad show

#
# Notifications
#
bindsym $mod+comma exec dunstctl close
bindsym $mod+Shift+comma exec dunstctl close-all
bindsym $mod+period exec dunstctl history-pop
bindsym $mod+Shift+period exec dunstctl set-paused toggle

#
# Modes
#
mode "move" {
    bindsym $left move left 25px
    bindsym $down move down 25px
    bindsym $up move up 25px
    bindsym $right move right 25px
    # move more
    bindsym Shift+$left move left 100px
    bindsym Shift+$down move down 100px
    bindsym Shift+$up move up 100px
    bindsym Shift+$right move right 100px
    # edges
    bindsym q exec $move_cmd top-left
    bindsym w exec $move_cmd top-center
    bindsym e exec $move_cmd top-right
    bindsym a exec $move_cmd center-left
    bindsym s exec $move_cmd center-center
    bindsym d exec $move_cmd center-right
    bindsym z exec $move_cmd bottom-left
    bindsym x exec $move_cmd bottom-center
    bindsym c exec $move_cmd bottom-right
    # Return to default mode
    bindsym Return mode "default"
    bindsym Escape mode "default"
}
bindsym $mod+m mode "move"

#
# Window Rules:
#
for_window [title="nmtui"] floating enable
for_window [title="float*"] floating enable
for_window [app_id="pavucontrol"] floating enable
for_window [app_id="com.nextcloud.desktopclient.nextcloud"] floating enable
for_window [app_id="imv"] floating enable
for_window [app_id=".*"] title_format '<span font_weight="bold">%title</span> <span>(%app_id)</span>'
for_window [class=".*"] title_format '<span font_weight="bold">%title</span> <span>(%class:%instance)</span>'
for_window [app_id="firefox" title="Firefox — Sharing Indicator"] floating enable
for_window [app_id="firefox" title="Picture-in-Picture"] floating enable
for_window [title="bluetoothctl"] floating enable
for_window [title="fzf"] floating enable
# scratchpad rules
for_window [class="Plexamp" window_type="normal"] exec sh -c "sleep 1"; mark s; floating enable; resize set width 1200; resize set height 700; move scratchpad
for_window [class="Ferdi" window_type="normal"] exec sh -c "sleep 1"; mark x; floating enable; resize set width 1200; resize set height 700; move scratchpad
for_window [class="Signal" window_type="normal"] exec sh -c "sleep 1"; mark c; floating enable; resize set width 1200; resize set height 700; move scratchpad

#
# Status Bar:
#
# Read `man 5 sway-bar` for more information about this section.
bar {
    position top
    gaps 3 5
    status_command i3status-rs $HOME/.config/sway/i3status.d/$(hostname).toml
    font $font
    colors {
        separator #666666
        background #222222
        statusline #dddddd
        focused_workspace #0088CC #0088CC #ffffff
        active_workspace #333333 #333333 #ffffff
        inactive_workspace #333333 #333333 #888888
        urgent_workspace #2f343a #900000 #ffffff
    }
}

#
# Autostart
#
exec --no-startup-id nextcloud --background
exec --no-startup-id persway -w -o 0.8
exec --no-startup-id dunst

include /etc/sway/config.d/*
