# Default config for sway
#
# Copy this to ~/.config/sway/config and edit it to your liking.
#
# 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

set $font Cascadia Code PL 13
font pango:Cascadia Code PL 11

#set $font Fantasque Sans Mono 15
#font pango:Fantasque Sans Mono 13

set $wallpaper /home/von/.wallpaper

default_border pixel
default_floating_border pixel

seat seat0 xcursor_theme Vanilla-DMZ

### Output configuration
#
# Default wallpaper (more resolutions are available in /usr/share/backgrounds/sway/)
output * bg $wallpaper fill

### Dynamic display configuration
exec kanshi
exec_always pkill kanshi; exec kanshi
#output eDP-1 position 0,0 scale 1
#output DP-1 scale 1.5
#
# 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
#
# Example configuration:
#
exec swayidle -w \
         timeout 300 'swaylock -f -i '$wallpaper \
         timeout 600 'swaymsg "output * dpms off"' \
         resume 'swaymsg "output * dpms on"' \
         before-sleep 'swaylock -f -i '$wallpaper
bindsym --to-code $mod+z exec 'swaylock -f -i '$wallpaper
#
# This will lock your screen after 300 seconds of inactivity, then turn off
# your displays after another 300 seconds, and turn your screens back on when
# resumed. It will also lock your screen before your computer goes to sleep.

### Input configuration
#
# Example configuration:
#
#   input "2:14:SynPS/2_Synaptics_TouchPad" {
#       dwt enabled
#       tap enabled
#       natural_scroll enabled
#       middle_emulation enabled
#   }
#
# 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.

### Key bindings
#
# Basics:
#
    # Start a terminal
    bindsym --to-code $mod+x exec default-terminal-emulator

    # Kill focused window
    bindsym --to-code $mod+Shift+c kill

    # Start your launcher
    bindsym --to-code $mod+d exec bemenu-run -i --fn "$font" --no-exec | xargs swaymsg exec --
    bindsym --to-code $mod+u exec bemenu-pass -i --fn "$font"

    # 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 --to-code $mod+Shift+r reload

    # Exit sway (logs you out of your Wayland session)
    bindsym --to-code $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'

    # Screenshot
    bindsym --to-code $mod+Shift+s exec screenshot-tool
#
# Moving around:
#
    # Move your focus around
    bindsym --to-code $mod+$left focus left
    bindsym --to-code $mod+$down focus down
    bindsym --to-code $mod+$up focus up
    bindsym --to-code $mod+$right focus right
    # Or use $mod+[up|down|left|right]
    bindsym --to-code $mod+Left focus left
    bindsym --to-code $mod+Down focus down
    bindsym --to-code $mod+Up focus up
    bindsym --to-code $mod+Right focus right

    # Move the focused window with the same, but add Shift
    bindsym --to-code $mod+Shift+$left move left
    bindsym --to-code $mod+Shift+$down move down
    bindsym --to-code $mod+Shift+$up move up
    bindsym --to-code $mod+Shift+$right move right
    # Ditto, with arrow keys
    bindsym --to-code $mod+Shift+Left move left
    bindsym --to-code $mod+Shift+Down move down
    bindsym --to-code $mod+Shift+Up move up
    bindsym --to-code $mod+Shift+Right move right
#
# Workspaces:
#
    # move to another screen
    bindsym --to-code $mod+Shift+o move workspace to output left
    # switch between recent workspaces
    bindsym --to-code $mod+o workspace back_and_forth
    # Switch to workspace
    bindsym --to-code $mod+1 workspace 1
    bindsym --to-code $mod+2 workspace 2
    bindsym --to-code $mod+3 workspace 3
    bindsym --to-code $mod+4 workspace 4
    bindsym --to-code $mod+5 workspace 5
    bindsym --to-code $mod+6 workspace 6
    bindsym --to-code $mod+7 workspace 7
    bindsym --to-code $mod+8 workspace 8
    bindsym --to-code $mod+9 workspace 9
    bindsym --to-code $mod+0 workspace 10
    # Move focused container to workspace
    bindsym --to-code $mod+Shift+1 move container to workspace 1
    bindsym --to-code $mod+Shift+2 move container to workspace 2
    bindsym --to-code $mod+Shift+3 move container to workspace 3
    bindsym --to-code $mod+Shift+4 move container to workspace 4
    bindsym --to-code $mod+Shift+5 move container to workspace 5
    bindsym --to-code $mod+Shift+6 move container to workspace 6
    bindsym --to-code $mod+Shift+7 move container to workspace 7
    bindsym --to-code $mod+Shift+8 move container to workspace 8
    bindsym --to-code $mod+Shift+9 move container to workspace 9
    bindsym --to-code $mod+Shift+0 move container to workspace 10
    # Note: workspaces can have any name you want, not just numbers.
    # We just use 1-10 as the default.
#
# Layout stuff:
#
    # You can "split" the current object of your focus with
    # $mod+b or $mod+v, for horizontal and vertical splits
    # respectively.
    bindsym --to-code $mod+b splith
    bindsym --to-code $mod+v splitv

    # Switch the current container between different layout styles
    bindsym --to-code $mod+s layout stacking
    bindsym --to-code $mod+w layout tabbed
    bindsym --to-code $mod+e layout toggle split

    # Make the current focus fullscreen
    bindsym --to-code $mod+f fullscreen

    # Toggle the current focus between tiling and floating mode
    bindsym --to-code $mod+Shift+Return floating toggle

    # Swap focus between the tiling area and the floating area
    bindsym --to-code $mod+Return focus mode_toggle

    # Move focus to the parent container
    bindsym --to-code $mod+a focus parent
#
# Scratchpad:
#
    # Sway has a "scratchpad", which is a bag of holding for windows.
    # You can send windows there and get them back later.

    # Move the currently focused window to the scratchpad
    bindsym --to-code $mod+Shift+minus move scratchpad

    # Show the next scratchpad window or hide the focused scratchpad window.
    # If there are multiple scratchpad windows, this command cycles through them.
    bindsym --to-code $mod+minus scratchpad show
#
# Resizing containers:
#
mode "resize" {
    # left will shrink the containers width
    # right will grow the containers width
    # up will shrink the containers height
    # down will grow the containers height
    bindsym --to-code $left resize shrink width 10px
    bindsym --to-code $down resize grow height 10px
    bindsym --to-code $up resize shrink height 10px
    bindsym --to-code $right resize grow width 10px

    # Ditto, with arrow keys
    bindsym --to-code Left resize shrink width 10px
    bindsym --to-code Down resize grow height 10px
    bindsym --to-code Up resize shrink height 10px
    bindsym --to-code Right resize grow width 10px

    # Return to default mode
    bindsym --to-code Return mode "default"
    bindsym --to-code Escape mode "default"
}
bindsym --to-code $mod+r mode "resize"

bindsym --to-code XF86AudioRaiseVolume exec "pactl set-sink-volume 0 +5%"
bindsym --to-code XF86AudioLowerVolume exec "pactl set-sink-volume 0 -5%"
bindsym --to-code XF86AudioMute exec "pactl set-sink-volume 0 0%"

#
# Status Bar:
#
# Read `man 5 sway-bar` for more information about this section.
bar {
    position top

    # When the status_command prints a new line to stdout, swaybar updates.
    # The default just shows the current date and time.
    #status_command while date +'%Y-%m-%d %l:%M:%S %p'; do sleep 1; done
    status_command "i3status-rs"

    colors {
        separator #6d0080
        background #2c2c2c
        statusline #ffffff
    #    focused_workspace #6d0080 #6d0080 #ffffff
    #    active_workspace #6d0080 #6d0080 #ffffff
    #    inactive_workspace #2c2c2c #2c2c2c #ffffff
    #    urgent_workspace #e68b00 #e68b00 #ffffff
    }
}

input "type:keyboard" {
    xkb_layout "us,ru"
    xkb_variant "altgr-intl,typewriter"
    xkb_options "grp:win_space_toggle,compose:menu,ctrl:nocaps"
}

input "type:touchpad" {
    dwt disabled
    tap disabled
    natural_scroll disabled
    click_method clickfinger
}

# rules
for_window [app_id="nmtui"] floating enable
for_window [app_id="pavucontrol"] floating enable
for_window [class="xfreerdp"] floating enable
for_window [app_id="zoom"] floating enable
for_window [class="^sun-awt"] floating enable
for_window [class="java-lang-Thread"] floating enable

# scratchpad
for_window [app_id="keepassxc"] move scratchpad, scratchpad show
bindsym --to-code $mod+i [app_id="keepassxc"] scratchpad show

# other settings
workspace_auto_back_and_forth yes
focus_wrapping yes

# autostart
exec mako

include /etc/sway/config.d/*