### Vars
set $terminal alacritty

### Color configuration
set $color1 #383838
set $color2 #ebdbb2

# class                 border    backgr.   text     indicator   child_border
client.focused          $color2   $color2   $color1  $color1    $color2
client.focused_inactive $color1   $color1   $color2  $color1    $color1
client.unfocused        $color1   $color1   $color2  $color1    $color1
client.urgent           $color1   $color1   $color2  $color1    $color1
client.placeholder      $color1   $color1   $color2  $color1    $color1
client.background       $color1

# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
font pango:monospace 8

set $ws1 1
set $ws2 2
set $ws3 3
set $ws4 4
set $ws5 5
set $ws6 6
set $ws7 7
set $ws8 8
set $ws9 9
set $ws10 "TV"

# default workspace
workspace $ws2

# window title
#for_window [class="^.*"] border pixel 2 title_format " %title"
default_border pixel 2
for_window [floating] default_border pixel 1
smart_borders on

# Gaps
gaps inner 16
gaps outer -8
smart_gaps on

# Floating mod
for_window [app_id="pavucontrol"] floating enable
for_window [app_id="org.remmina.Remmina" title="Remmina Remote Desktop Client"] floating enable
for_window [app_id="desktopclient.nextcloud.com.nextcloud"] floating enable
for_window [class="TeamViewer"] floating enable
for_window [app_id="firefox" title="Firefox - Sharing Indicator"] floating enable

for_window [app_id="firefox" title="Picture-in-Picture"] {
    floating enable
    sticky enable
}

for_window [class="feh" title="Pinned screenshot"] {
    floating enable
    sticky enable
}

for_window [window_type="dialog"] floating enable
for_window [window_type="utility"] floating enable
for_window [window_type="toolbar"] floating enable
for_window [window_type="splash"] floating enable

# https://github.com/ValveSoftware/steam-for-linux/issues/1040
for_window [class="^Steam$" title="^Friends$"] floating enable
for_window [class="^Steam$" title="Steam - News"] floating enable
for_window [class="^Steam$" title=".* - Chat"] floating enable
for_window [class="^Steam$" title="^Settings$"] floating enable
for_window [class="^Steam$" title=".* - event started"] floating enable
for_window [class="^Steam$" title=".* CD key"] floating enable
for_window [class="^Steam$" title="^Steam - Self Updater$"] floating enable
for_window [class="^Steam$" title="^Screenshot Uploader$"] floating enable
for_window [class="^Steam$" title="^Steam Guard - Computer Authorization Required$"] floating enable
for_window [title="^Steam Keyboard$"] floating enable

# https://github.com/Alexays/Waybar/issues/63
for_window [app_id="waybar" floating] {
    move position cursor
    move down 120px # adjust if some menus still don't fit
}

# Inhibit idle if a window is fullscreen
for_window [class="^.*"] inhibit_idle fullscreen
for_window [app_id="^.*"] inhibit_idle fullscreen

### Output configuration
output "*" {
    background ~/.local/share/wallpaper fill
}

set $output1 "LG Electronics LG QHD 0x00051E95"
workspace $ws3 output $output1 VGA-1
workspace $ws4 output $output1 VGA-1
workspace $ws5 output $output1 VGA-1
workspace $ws6 output $output1 VGA-1
workspace $ws7 output $output1 VGA-1
workspace $ws8 output $output1 VGA-1
workspace $ws9 output $output1 VGA-1
workspace sunshine output $output1 VGA-1
output $output1 {
    position 0 270
    # we need to explicitly select the mode
    mode 2560x1440@144Hz
    adaptive_sync on
}

set $output2 "Ancor Communications Inc ASUS VH238 BALMIB547836"
workspace $ws1 output $output2 eDP-1
workspace $ws2 output $output2 eDP-1
output $output2 {
    position 2560 0
    transform 270
}

set $output3 "Sony SONY TV  *30 0x01010101"
workspace $ws10 output $output3
output $output3 {
    mode 3840x2160@120Hz
    adaptive_sync on
    disable
}

### Input configuration
# mod key
set $mod Mod4
# caps lock is rebinded to mod key

# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

# disable focus follow mouse
#focus_follows_mouse no

# Touchpad
input "1739:0:Synaptics_TM3053-003" {
    tap enabled
    tap_button_map lrm
    middle_emulation enabled
    scroll_method two_finger
    dwt enable
    drag enable
}

input "*" {
    # Keyboard
    xkb_layout us
    xkb_variant altgr-intl
    xkb_options caps:super

    # Mouse
    accel_profile flat
    pointer_accel -0.4
}

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

# thunar
bindsym $mod+Mod1+Return exec dolphin

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

# start rofi (a program launcher)
bindsym $mod+Control+Return exec rofi -combi drun -show drun -modi drun,window
# start rofi-pass for password autotype
bindsym $mod+Shift+Return exec rofi-pass

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

# alternatively, you can use the cursor keys:
#bindsym $mod+Left focus left
#bindsym $mod+Down focus down
#bindsym $mod+Up focus up
#bindsym $mod+Right focus right

# move focused window
bindsym $mod+Shift+h move left
bindsym $mod+Shift+j move down
bindsym $mod+Shift+k move up
bindsym $mod+Shift+l move right

# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right

# split in horizontal orientation
bindsym $mod+Shift+backslash split h # |
bindsym $mod+backslash split h

# split in vertical orientation
bindsym $mod+minus split v

# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle

# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

# toggle tiling / floating
bindsym $mod+Shift+space floating toggle

# toggle sticky
bindsym $mod+Ctrl+space sticky toggle

# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle

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

# focus the child container
bindsym $mod+d focus child

# switch to workspace
bindsym $mod+q workspace back_and_forth 
bindsym $mod+1 workspace $ws1
bindsym $mod+2 workspace $ws2
bindsym $mod+3 workspace $ws3
bindsym $mod+4 workspace $ws4
bindsym $mod+5 workspace $ws5
bindsym $mod+6 workspace $ws6
bindsym $mod+7 workspace $ws7
bindsym $mod+8 workspace $ws8
bindsym $mod+9 workspace $ws9
bindsym $mod+0 workspace $ws10

#bindsym $mod+Ctrl+Up workspace next
#bindsym $mod+Ctrl+Down workspace prev

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace $ws1
bindsym $mod+Shift+2 move container to workspace $ws2
bindsym $mod+Shift+3 move container to workspace $ws3
bindsym $mod+Shift+4 move container to workspace $ws4
bindsym $mod+Shift+5 move container to workspace $ws5
bindsym $mod+Shift+6 move container to workspace $ws6
bindsym $mod+Shift+7 move container to workspace $ws7
bindsym $mod+Shift+8 move container to workspace $ws8
bindsym $mod+Shift+9 move container to workspace $ws9
bindsym $mod+Shift+0 move container to workspace $ws10

# toggle TV
bindsym $mod+Alt+0 output $output3 toggle

# Assignation
assign [class="^[Ss]lack$"] $ws1
assign [class="^[Dd]iscord$"] $ws1
#assign [class="^looking-glass-client$"] $ws3

# screen
# workspace $ws1 output HDMI-A-2
# workspace $ws2 output HDMI-A-2
# workspace $ws3 output HDMI-A-1
# workspace $ws4 output HDMI-A-1
# workspace $ws5 output HDMI-A-1
# workspace $ws6 output HDMI-A-1
# workspace $ws7 output HDMI-A-1
# workspace $ws8 output HDMI-A-1
# workspace $ws9 output HDMI-A-1
# workspace $ws10 output HDMI-A-1

# reload the configuration file
bindsym $mod+Shift+r reload
# exit 
bindsym $mod+Shift+e exec "swaynag -t warning -m 'Do you really want to exit sway?' -b 'Yes, exit sway' 'swaymsg exit'"
# lock the screen
bindsym $mod+Pause exec lock
# suspend
bindsym $mod+Shift+Pause exec systemctl suspend

# function keys
bindsym XF86MonBrightnessUp exec brightness-control up
bindsym XF86MonBrightnessDown exec brightness-control down
bindsym XF86AudioMute exec volume-control mute
bindsym XF86AudioRaiseVolume exec volume-control up
bindsym XF86AudioLowerVolume exec volume-control down
bindsym Shift+print exec sshot --pin
bindsym Control+print exec sshot --partial
bindsym Alt+print exec sshot --window
bindsym print exec sshot

# resize window (you can also use the mouse for that)
mode "resize" {
    # These bindings trigger as soon as you enter the resize mode

    # Pressing left will shrink the window’s width.
    # Pressing right will grow the window’s width.
    # Pressing up will shrink the window’s height.
    # Pressing down will grow the window’s height.
    bindsym h resize shrink width 10 px or 10 ppt
    bindsym j resize grow height 10 px or 10 ppt
    bindsym k resize shrink height 10 px or 10 ppt
    bindsym l resize grow width 10 px or 10 ppt

    # same bindings, but for the arrow keys
    #bindsym Left resize shrink width 10 px or 10 ppt
    #bindsym Down resize grow height 10 px or 10 ppt
    #bindsym Up resize shrink height 10 px or 10 ppt
    #bindsym Right resize grow width 10 px or 10 ppt

    # back to normal: Enter or Escape
    bindsym Return mode "default"
    bindsym Escape mode "default"
}

bindsym $mod+r mode "resize"

### Startup
# reach systemd target
exec /bin/systemctl --user import-environment
exec /bin/systemctl --user start sway-session.target
exec hash dbus-update-activation-environment 2>/dev/null && \
     dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK

# autorun .desktop
exec /bin/dex -a

# run a terminal
exec $terminal

# setup outputs
exec_always ~/.local/bin/setup-outputs

bar {
    swaybar_command waybar
}
