# ┌───────────────────────────────────────────────────┐
# │ ██████╗ ███████╗████████╗███████╗██████╗ ███████╗ │
# │ ██╔══██╗██╔════╝╚══██╔══╝██╔════╝██╔══██╗██╔════╝ │
# │ ██████╔╝█████╗     ██║   █████╗  ██████╔╝███████╗ │
# │ ██╔═══╝ ██╔══╝     ██║   ██╔══╝  ██╔══██╗╚════██║ │
# │ ██║     ███████╗   ██║   ███████╗██║  ██║███████║ │
# │ ╚═╝     ╚══════╝   ╚═╝   ╚══════╝╚═╝  ╚═╝╚══════╝ │
# ├───────────────────────────────────────────────────┤
# │    depressing and totally messy sway config or    │
# ├───────────────────────────────────────────────────┤
# │          How windows are the only well            │
# │           managed aspect of my life.              │
# │---------------------------------------------------│
# │     https://gitlab.com/putridpete/dot-files       │
# └───────────────────────────────────────────────────┘
#
# 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

# Terminal emulator

set $term kitty

# Application launcher

set $menu exec wofi -I
set $nmtui exec foot -a launcher -e nmtui
set $htop exec foot -a launcher -e htop
set $nvtop exec foot -a launcher -e nvtop

# Output configuration

output eDP-1 {
   #options
   mode 1920x1080@60.020Hz scale 1.07777777
   position 0,0 
   bg ~/.wallpapers/castlevania.png fill 
}

# Brightness control

bindsym --locked XF86MonBrightnessUp exec brightnessctl s 10%+ 
bindsym --locked XF86MonBrightnessDown exec brightnessctl s 10%- 

# Volume control

bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle 
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +10% 
bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -10%
bindsym XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle


# Input

input "type:keyboard" {
    #options
    xkb_layout us(altgr-intl)
    xkb_variant ,nodeadkeys
    xkb_options caps:escape
}

input "type:touchpad" {
    dwt enabled
    tap enabled
    middle_emulation enabled
}

# Key Bindings | Note: You can get the names of your inputs by running: swaymsg -t get_inputs

    # Start a terminal
    bindsym $mod+Return exec $term

    # Kill focused window
    bindsym $mod+q kill
    # Screenshot
    bindsym Print exec grim -g "$(slurp)" - | swappy -f -
    # Toggle control center
    bindsym $mod+Shift+n exec swaync-client -t -sw
    # Start launcher
    #bindsym $mod+d exec "dmenu_run -nf '#F8F8F2' -nb '#282A36' -sb '#6272A4' -sf '#F8F8F2' -fn 'monospace-10' -p 'dmenu'"
    bindsym $mod+p exec $menu
    bindsym $mod+Alt+n exec $nmtui
    bindsym $mod+Alt+j exec $nvtop
    bindsym $mod+m exec feishin --enable-features=UseOzonePlatform --ozone-platform=wayland
    bindsym $mod+g exec galculator
    bindsym $mod+c exec gsimplecal
    bindsym $mod+Ctrl+p exec swaylock -f
    bindsym $mod+Alt+v for_window [app_id="mpv"] floating enable, move absolute position 1270 710

    # mouse button for dragging.
    floating_modifier $mod normal

    # Reload the configuration file
    bindsym $mod+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 $mod+Ctrl
    bindsym $mod+Ctrl+$left move left
    bindsym $mod+Ctrl+$down move down
    bindsym $mod+Ctrl+$up move up
    bindsym $mod+Ctrl+$right move right
    # Ditto, with arrow keys
    bindsym $mod+Ctrl+Left move left
    bindsym $mod+Ctrl+Down move down
    bindsym $mod+Ctrl+Up move up
    bindsym $mod+Ctrl+Right move right

# Workspaces:

    # Switch to workspace
    bindsym $mod+1 workspace number 1
    bindsym $mod+2 workspace number 2
    bindsym $mod+3 workspace number 3
    bindsym $mod+4 workspace number 4
    bindsym $mod+5 workspace number 5
    bindsym $mod+6 workspace number 6
    bindsym $mod+7 workspace number 7
    bindsym $mod+8 workspace number 8
    bindsym $mod+9 workspace number 9
    bindsym $mod+0 workspace number 10
    bindsym $mod+minus workspace number 11
    bindsym $mod+equal workspace number 12

    # Move focused container to workspace
    bindsym $mod+Ctrl+1 move container to workspace number 1
    bindsym $mod+Ctrl+2 move container to workspace number 2
    bindsym $mod+Ctrl+3 move container to workspace number 3
    bindsym $mod+Ctrl+4 move container to workspace number 4
    bindsym $mod+Ctrl+5 move container to workspace number 5
    bindsym $mod+Ctrl+6 move container to workspace number 6
    bindsym $mod+Ctrl+7 move container to workspace number 7
    bindsym $mod+Ctrl+8 move container to workspace number 8
    bindsym $mod+Ctrl+9 move container to workspace number 9
    bindsym $mod+Ctrl+0 move container to workspace number 10
    bindsym $mod+Ctrl+minus move container to workspace number 11
    bindsym $mod+Ctrl+equal move container to workspace number 12

# Switch to prev/next workspace on all outputs
    bindsym $mod+Alt+Right workspace next
    bindsym $mod+Alt+Left workspace prev
    bindsym $mod+Alt+l workspace next
    bindsym $mod+Alt+h workspace prev



# Layout stuff:
   

    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+Ctrl+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:

    # Move the currently focused window to the scratchpad
    bindsym $mod+grave 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+tab 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"
}

# GTK theme

set $gnome-schema org.gnome.desktop.interface

# Status Bar:

bar {
    #position top
    mode invisible
 
    # 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 +'%A, %d-%m-%Y %H:%M %j'; do sleep 1; done
    #
    status_command waybar
    workspace_buttons yes

    colors {
    background #282A36
    statusline #F8F8F2
    separator  #44475A

    focused_workspace  #44475A #44475A #F8F8F2
    active_workspace   #282A36 #44475A #F8F8F2
    inactive_workspace #282A36 #282A36 #BFBFBF
    urgent_workspace   #FF5555 #FF5555 #F8F8F2
    binding_mode       #FF5555 #FF5555 #F8F8F2
    }
}

include /etc/sway/config.d/*

# class                 border  bground text    indicator child_border
client.focused          #6272A4 #6272A4 #F8F8F2 #6272A4   #6272A4
client.focused_inactive #44475A #44475A #F8F8F2 #44475A   #44475A
client.unfocused        #282A36 #282A36 #BFBFBF #282A36   #282A36
client.urgent           #44475A #FF5555 #F8F8F2 #FF5555   #FF5555
client.placeholder      #282A36 #282A36 #F8F8F2 #282A36   #282A36

client.background       #F8F8F2

gaps inner 10
default_border pixel 2
default_floating_border pixel 2

# Workspaces

workspace 1 output eDP-1
workspace 2 output eDP-1
workspace 3 output eDP-1
workspace 4 output eDP-1
workspace 5 output eDP-1
workspace 6 output eDP-1
workspace 7 output eDP-1
workspace 8 output eDP-1
workspace 9 output eDP-1
workspace 10 output eDP-1
workspace 11 output eDP-1
workspace 12 output eDP-1

# Auto exec

### Variables
exec systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
exec --no-startup-id dbus-update-activation-environment --all

### Polkit Agent
exec /usr/lib/polkit-kde-authentication-agent-1

### Autotiling
exec autotiling-rs

### Notification Daemon
exec swaync

### Idle configuration
exec swayidle -w timeout 1800 'swaylock -f' timeout 1805 'swaymsg "output * power off"' resume 'swaymsg "output * power on"'

# Cursor
seat seat0 xcursor_theme Dracula-cursors

# Lock screen after closing lid

set $lock 'swaylock -f'
bindswitch --reload --locked lid:on exec $lock

### Dracula theme
exec_always {
    gsettings set $gnome-schema gtk-theme 'Dracula'
    gsettings set $gnome-schema icon-theme 'Papirus-Dark'
    gsettings set $gnome-schema cursor-theme 'Dracula-cursors'
}

### General
exec nextcloud
exec openrgb --startminimized
exec swaymsg "workspace 1; exec firefox"
exec steam-runtime
exec jellyfinmediaplayer
exec virt-manager
exec kdenlive
exec gimp
exec keepassxc
exec feishin --enable-features=UseOzonePlatform --ozone-platform=wayland 
exec heroic --ozone-platform=wayland
exec libreoffice --writer --norestore
exec signal-desktop --ozone-platform-hint=auto --enable-features=UseOzonePlatform,WaylandWindowDecorations
exec swaymsg "workspace 2; exec kitty --session ~/.config/kitty/session --listen-on=unix:@mykitty"

# Window managment 

focus_on_window_activation urgent
focus_follows_mouse yes
xwayland disable

assign [app_id="mpv"] output eDP-1
assign [app_id="org.jellyfin.jellyfinmediaplayer"] workspace number 3
assign [app_id="gimp"] workspace number 5
assign [app_id="libreoffice-writer"] workspace number 4
#assign [class="Signal"] workspace number 7
for_window [app_id="signal"] floating enable, resize set 1280 px 768 px, move scratchpad
for_window [app_id="nextcloud"] floating enable, resize set 600 px 800 px, move absolute position 1320 40
for_window [app_id="nm-connection-editor"] floating enable, move absolute position 670 40
for_window [app_id="gsimplecal"] floating enable, move absolute position 830 40
for_window [app_id="org.keepassxc.KeePassXC"] floating enable, floating enable, move scratchpad, scratchpad show
for_window [app_id="pavucontrol"] floating enable, move absolute position 1320 40, resize set 600 px 800 px
for_window [app_id="galculator"] floating enable, move scratchpad, scratchpad show
for_window [app_id="org.kde.polkit-kde-authentication-agent-1"] floating enable
#for_window [app_id="org.rncbc.qsynth"] floating enable, resize 1280 ppt 768 ppt
#for_window [app_id="signal"] resize set 633 px, move left, urgent deny 
#for_window [class="Signal"] resize set 633 px, move left, urgent deny 
for_window [app_id="feishin"] floating enable, resize set 1600 px 900 px, move scratchpad
for_window [class="steam"] floating enable 
for_window [title="Steam"] floating disable 
for_window [app_id="mpv"] floating enable, resize set 640 px 320 px, move absolute position 1270 710, move scratchpad, scratchpad show 
for_window [app_id="xdg-desktop-portal-gtk"] floating enable, resize set 800 px 600px 
for_window [app_id="^launcher$"] floating enable, sticky enable, resize set 46 ppt 60 ppt, border pixel 5
