#include /home/oh/.config/sway/basic_key_bindings
#include /home/oh/.config/sway/windows_rules
#include /home/oh/.config/sway/input_config
#include /home/oh/.config/sway/colors
#include /home/oh/.config/sway/workspaces_rules
#include /home/oh/.config/sway/app_assignment
#include /home/oh/.config/sway/layout
# include /home/oh/.config/sway/utilities


### Variables
bindgesture swipe:up workspace prev
bindgesture swipe:down workspace next

# Logo key. Use Mod1 for Alt.
set $mod Mod4
set $mod1 Alt
# Home row direction keys, like vim
set $left k
set $down l
set $up o
set $right m

# screens
set $laptop eDP-1
set $external HDMI-A-1

## Preferred apps
set $term foot
set $menu wofi --show drun
set $file nautilus
set $browser flatpak run app.zen_browser.zen

include /etc/sway/config-vars.d/*
# autoload when start wm
exec waybar
exec /usr/libexec/polkit-mate-authentication-agent-1
exec wlsunset
exec wl-paste --watch cliphist store
exec swaync

### Output configuration

# using "swaybg" just put file path as below and end with 'fill'
output * background ~/.config/sway/wallpapers/frieren.png fill
#

output HDMI-A-1 resolution 1920x1080 position 1920,0


#exec swayidle -w \
#          timeout 300 'swaylock -f -c 000000' \
 #         timeout 600 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
  #        before-sleep 'swaylock -f -c 000000'

# 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


input "2:14:ETPS/2_Elantech_Touchpad" {
       dwt enabled
       dwtp enabled
       tap_button_map lrm
       tap enabled
       natural_scroll enabled
       middle_emulation enabled
}

input type:keyboard {
    xkb_options caps:escape
    xkb_layout fr
    repeat_delay 300
    repeat_rate 50
}

input "6058:20564:ThinkPad_Extra_Buttons" {
    
}


# window gaps
smart_borders on
default_border pixel 2
default_floating_border pixel 3
gaps inner 1
gaps outer 1


# Window borders
# Colors:               border   background  text      indicator  child_border
client.focused          #9932cc  #285577     #ffffff   #2e9ef4    #2e9ef4
client.focused_inactive #333333  #5f676a     #ffffff   #484e50    #5f676a
client.unfocused        #333333  #222222     #888888   #292d2e    #222222
client.urgent           #2f343a  #900000     #ffffff   #900000    #900000
client.placeholder      #000000  #0c0c0c     #ffffff   #000000    #0c0c0c

# Background color for inactive tabs in tabbed/stacked layout
client.background       #000000

# thème du curseur de souris
seat seat0 xcursor_theme Bibata-Modern-Ice


# faire disparaître le titlebar
font pango:monospace 0.001
titlebar_border_thickness 1                                                     


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

    # Kill focused window
    bindsym $mod+q kill

    # Start your launcher
    bindsym $mod+space exec $menu
    bindsym $mod+shift+d exec wofi --show run

    # Start a file manager
    bindsym $mod+e exec $file
    
    # Start browser
    bindsym $mod+a exec $browser
    
    # 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

    # clipboard manager
    bindsym $mod+w exec cliphist list | wofi | cliphist decode | wl-copy

    # notification center
    bindsym $mod+Shift+n exec swaync-client -t -sw

    # Reload the configuration file
    bindsym $mod+Shift+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
    # Or use $mod+[up|down|left|right]
    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
    # Ditto, with arrow 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
#
# Workspaces:
#
    # Switch to workspace
    bindsym $mod+ampersand workspace 01
    bindsym $mod+eacute workspace 02
    bindsym $mod+quotedbl workspace 03
    bindsym $mod+apostrophe workspace 04
    bindsym $mod+parenleft workspace 05
    bindsym $mod+minus workspace 06
    bindsym $mod+egrave workspace 07
    bindsym $mod+underscore workspace 08
    bindsym $mod+ccedilla workspace 09
    bindsym $mod+agrave workspace 010
    # Move focused container to workspace
    bindsym $mod+Shift+ampersand move container to workspace 01
    bindsym $mod+Shift+eacute move container to workspace 02
    bindsym $mod+Shift+quotedbl move container to workspace 03
    bindsym $mod+Shift+apostrophe move container to workspace 04
    bindsym $mod+Shift+parenleft move container to workspace 05
    bindsym $mod+Shift+minus move container to workspace 06
    bindsym $mod+Shift+egrave move container to workspace 07
    bindsym $mod+Shift+underscore move container to workspace 08
    bindsym $mod+Shift+ccedilla move container to workspace 09
    bindsym $mod+Shift+agrave move container to workspace 010

    bindsym $mod+tab workspace next
    bindsym $mod1+tab workspace prev


# external screen

#   on laptop monitor
    workspace 1 output $laptop
    workspace 2 output $laptop
    workspace 3 output $laptop
    workspace 4 output $laptop
    workspace 5 output $laptop
    workspace 6 output $laptop
    workspace 7 output $laptop
    workspace 8 output $laptop
    workspace 9 output $laptop
    workspace 10 output $laptop
    
#   on external monitor
    workspace 01 output $external
    workspace 02 output $external
    workspace 03 output $external
    workspace 04 output $external
    workspace 05 output $external
    workspace 06 output $external
    workspace 07 output $external
    workspace 08 output $external
    workspace 09 output $external
    workspace 010 output $external


# assignment
for_window [app_id=.*] focus
 assign [app_id="foot"] 01
assign [app_id="foot"] 1
assign [app_id="zen"] 02
assign [app_id="zen"] 2
assign [app_id="anki"] 02
assign [app_id="anytype"] 3
assign [app_id="libreoffice"] 3
assign [app_id="signal"] 4
assign [app_id="thunderbird"] 04 
assign [app_id="thunderbird"] 4 
assign [app_id="mpv"] 05
assign [app_id="mpv"] 5
assign [app_id="vlc"] 05
assign [app_id="vlc"] 5
assign [app_id="steam"] 06
assign [app_id="steam"] 6
assign [app_id="kde-connect"] 7
assign [app_id="nextcloud"] 7

#
# 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+s 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+u 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+$mod1+r mode "resize"

#
# Utilities:
#
    # Special keys to adjust volume via PulseAudio
    bindsym --locked XF86AudioMute exec amixer sset Master toggle
    bindsym --locked XF86AudioLowerVolume exec amixer sset Master 5%-
    bindsym --locked XF86AudioRaiseVolume exec amixer sset Master 5%+
    bindsym --locked XF86AudioMicMute exec pactl set-source-mute \@DEFAULT_SOURCE@ toggle
    # Special keys to adjust brightness via brightnessctl
    bindsym --locked XF86MonBrightnessDown exec brightnessctl set 5%-
    bindsym --locked XF86MonBrightnessUp exec brightnessctl set 5%+
    # Special key to take a screenshot with grim
    bindsym Print exec grim
    bindsym $mod+Print exec grim -g "$(slurp)"

    #power
    bindsym $mod+Escape exec wlogout
    bindsym $mod+Shift+x exec swaylock
#
# Status Bar disable because of use waybar instead if you not use waybar just uncomment those below:
#
# 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 %X'; do sleep 1; done

#    colors {
#        statusline #ffffff
#        background #323232
#        inactive_workspace #32323200 #32323200 #5c5c5c
#    }
#}


include /etc/sway/config.d/*
