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

    # Kill focused window
    bindsym $mod+Shift+q kill

    # Start your launcher
    bindsym $mod+d exec $menu

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

    # logout
    bindsym $mod+Shift+e exec swaynag -t warning -m 'Do you really want to log out?' -b 'Yes, exit sway' 'swaymsg exit'

    # lock screen - alt+l and super+l
    bindsym --no-repeat Mod1+l exec ${HOME}/.config/sway/scripts/locker.py
    bindsym --no-repeat Mod4+l exec ${HOME}/.config/sway/scripts/locker.py
#
# Moving around:
#
    # Move focus around
    bindsym $mod+$left focus left
    bindsym $mod+$down focus down
    bindsym $mod+$up focus up
    bindsym $mod+$right focus right
    # Move windows around
    bindsym $mod+Shift+$left move left
    bindsym $mod+Shift+$down move down
    bindsym $mod+Shift+$up move up
    bindsym $mod+Shift+$right move right
    # Cycle between workspaces
    bindsym $mod+control+Right workspace next
    bindsym $mod+control+Left workspace prev

#
# Workspaces:
#
    # Switch to workspace
    bindsym $mod+1 workspace 1
    bindsym $mod+2 workspace 2
    bindsym $mod+3 workspace 3
    bindsym $mod+4 workspace 4
    bindsym $mod+5 workspace 5
    bindsym $mod+6 workspace 6
    bindsym $mod+7 workspace 7
    bindsym $mod+8 workspace 8
    bindsym $mod+9 workspace 9
    bindsym $mod+0 workspace 10
    # Move focused container to workspace
    bindsym $mod+Shift+1 move container to workspace 1
    bindsym $mod+Shift+2 move container to workspace 2
    bindsym $mod+Shift+3 move container to workspace 3
    bindsym $mod+Shift+4 move container to workspace 4
    bindsym $mod+Shift+5 move container to workspace 5
    bindsym $mod+Shift+6 move container to workspace 6
    bindsym $mod+Shift+7 move container to workspace 7
    bindsym $mod+Shift+8 move container to workspace 8
    bindsym $mod+Shift+9 move container to workspace 9
    bindsym $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 $mod+b splith
    bindsym $mod+v splitv

    # Switch the current container between different layout styles
    bindsym $mod+s 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

    # 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
#
# 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 $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 $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 $left resize shrink width 20px
    bindsym $down resize grow height 20px
    bindsym $up resize shrink height 20px
    bindsym $right resize grow width 20px

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

#
# Screenshots:
#
    bindsym --no-repeat Print exec "~/.config/sway/scripts/screenshot.py region"
    bindsym --no-repeat Shift+Print exec "~/.config/sway/scripts/screenshot.py window"

#
# Media Control:
# note: only coverage for the two media keys and knob on the Das 5QS keyboard
# for the rest, see:
#   https://wiki.archlinux.org/title/Sway#Custom_keybindings
#   first, set up some aliases for brevity
#   ... expect title/body to follow as two more strings
    set $media-notify exec notify-send --urgency normal --expire-time 1000 --transient
    bindsym --locked XF86AudioPlay $media-notify --icon /usr/share/icons/breeze-dark/status/22/media-playback-playing.svg 'Media Playback' 'Play state toggled'; exec playerctl play-pause
    bindsym --locked XF86AudioNext $media-notify --icon /usr/share/icons/breeze-dark/actions/32/go-next.svg 'Media Playback' 'Skipped to the next track'; exec playerctl next
#    bindsym --locked XF86AudioRaiseVolume exec ~/.config/sway/scripts/volume.py raise 1
#    bindsym --locked XF86AudioLowerVolume exec ~/.config/sway/scripts/volume.py lower 1
# weird problem with knobs on the DAC and keyboard competing for this keybind, even though the DAC should only manage itself...
# instead, bind them to exec echo to prevent '438u' spam 
    bindsym XF86AudioRaiseVolume nop
    bindsym XF86AudioLowerVolume nop
    bindsym --locked XF86AudioMute $media-notify --icon /usr/share/icons/breeze-dark/status/22/audio-volume-muted.svg 'Volume adjustment' 'Mute toggled'; exec pactl set-sink-mute @DEFAULT_SINK@ toggle