# Duck config for sway
#
# Ansible managed
#
# Read `man 5 sway` for a complete reference.

### Variables
#
set $mod Mod4
# Home row direction keys, like vim
set $left h
set $down j
set $up k
set $right l
set $term x-terminal-emulator
set $menu wofi --term=$term
# options are defined in ~/.config/swaylock/config
set $locker swaylock -f
# why is pactl get-sink-volume missing???
set $pulsegetvol amixer -M -D pulse get Master | grep -o -E [[:digit:]]+% | head -n 1 | tr -d '%'

### Output configuration

output * bg ~/stuffCloud/Backgrounds/skygateautumn13440.jpg 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

exec swayidle -w \
         timeout 1740 'swaymsg "output * dpms off"' \
               resume 'swaymsg "output * dpms on"' \
         timeout 1800 '$locker' \
         before-sleep '$locker' \
         lock '$locker'

### 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 * {
    xkb_numlock enabled
    # same as /etc/default/keyboard
    xkb_model pc105
    xkb_layout us
    xkb_variant altgr-intl
    xkb_options compose:menu,grp:win_space_toggle
    #,level3:ralt_switch
    # xkbcommon: ERROR: Unrecognized RMLVO option "level3:ralt_switch" was ignored
}

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

    # kill focused window
    bindsym $mod+Shift+d kill

    # 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+Control+r reload

    # exit sway (logs you out of your Wayland session)
    bindsym $mod+Control+Shift+q 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
    bindsym $mod+Left workspace prev_on_output
    bindsym $mod+Right workspace next_on_output

    # Move the focused window
    bindsym $mod+Shift+$left move left
    bindsym $mod+Shift+$down move down
    bindsym $mod+Shift+$up move up
    bindsym $mod+Shift+$right move right
    bindsym $mod+Shift+Left move container to workspace prev_on_output
    bindsym $mod+Shift+Right move container to workspace next_on_output

    # Move to different output
    bindsym $mod+Control+Left move to output left
    bindsym $mod+Control+Right move to output right
    bindsym $mod+Control+Up move to output up
    bindsym $mod+Control+Down move to output down

    # Move the whole workspace
    bindsym $mod+Alt+Left move workspace to output left
    bindsym $mod+Alt+Right move workspace to output right
    bindsym $mod+Alt+Up move workspace to output up
    bindsym $mod+Alt+Down move workspace to output down

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

        # ditto, with arrow keys
        bindsym Left resize shrink width 10px
        bindsym Down resize grow height 10px
        bindsym Up resize shrink height 10px
        bindsym Right resize grow width 10px

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

#
# Custom Bindings:
#
    # Tools
    bindsym $mod+F2 exec $menu
    bindsym $mod+F3 exec nemo
    bindsym $mod+F4 exec pavucontrol
    bindsym $mod+F5 exec grim -o $$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') ~/Skrinshots/$$(date +'%Y%m%d-%H%M%S_screenshot.png')
    bindsym $mod+F12 exec loginctl lock-session
    bindsym $mod+Control+F12 exec systemctl suspend

    # Audio volume
    bindsym --locked XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle
    bindsym --locked XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5% && $pulsegetvol > $SWAYSOCK.wob
    bindsym --locked XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5% && $pulsegetvol > $SWAYSOCK.wob

    # Screen brightness
    bindsym XF86MonBrightnessUp exec light -A 5 && light -G | cut -d'.' -f1 > $SWAYSOCK.wob
    bindsym XF86MonBrightnessDown exec light -U 5 && light -G | cut -d'.' -f1 > $SWAYSOCK.wob


### Status Bar

# Read `man 5 sway-bar` for more information about this section.
bar {
    position top
    font pango:DejaVu Sans Mono 10
    strip_workspace_numbers yes
    status_command i3status

    colors {
        statusline #ffffff
        background #323232
    }
}

### Behavior

focus_follows_mouse yes

### Decoration

font pango:DejaVu Sans Mono 9
default_border pixel 3
smart_gaps on
gaps outer 0
gaps inner 10

### Workspaces

workspace 1 🦆
exec $term
exec signal-desktop

# tried different ways to get workspace 1 tabbed but to no avail
for_window [class="Signal"] layout splith
for_window [class="Firefox"] move container to workspace 2 🌐

### Background Apps

# Session
exec mate-polkit

# XWayland settings
# (without force xmodmap call silently does not work)
xwayland force
exec xmodmap -e 'keycode 135 = Multi_key'
# fcitx UI is not displayed when started by the X session (despite completion working), probably started too soon
exec fcitx -r

# overlay progressbar
exec mkfifo $SWAYSOCK.wob && cat 0<> $SWAYSOCK.wob | wob
exec mako
exec nextcloud --background
exec pasystray



### Local Customization
include ~/.config/sway/Annael

