# Font

# font pango: NotoSans Nerd Font 12
# font pango: NotoSansNerdFont 12

# Env
set $env:QT_QPA_PLATFORMTHEME qt5ct
set $env:CARGO_TARGET_DIR /tmp/cargo-target

set $env:SDL_VIDEODRIVER wayland,x11
set $env:_JAVA_AWT_WM_NONREPARENTING 1
set $env:QT_QPA_PLATFORM wayland
set $env:XDG_CURRENT_DESKTOP sway
set $env:XDG_SESSION_DESKTOP sway
set $env:XDG_SESSION_TYPE wayland
set $env:XCURSOR_THEME Adwaita
set $env:FREETYPE_PROPERTIES truetype:interpreter-version=40

seat seat0 xcursor_theme Adwaita 10

# install polkit-gnome
exec dbus-update-activation-environment --all
exec gnome-keyring-daemon --start --replace --components=pkcs11,secrets,ssh
exec --no-startup-id /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1

# mako stuff for notifications
exec --no-startup-id mako

# bluetooth applet
exec --no-startup-id blueman-applet

# Screenshot things
# for_window [app_id="flaqmeshot"] border pixel 0, floating enable, fullscreen disable, move absolute position 0 0
# exec --no-startup-id systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK
# exec --no-startup-id hash dbus-update-activation-environment 2>/dev/null && dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK
set $satty satty -f - --initial-tool=arrow --copy-command=/home/lgx/.local/bin/satty-copy --actions-on-escape="save-to-clipboard,exit" --brush-smooth-history-size=5 --disable-notifications --fullscreen

# bindsym Print exec swaymsg -t get_tree | jq -r '.. | select(.focused?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | grim -t ppm -g - - | $satty
bindsym Print exec grim -t ppm - | $satty
# Direct whole-screen PNG copy, useful when no annotation is needed.
bindsym Shift+Print exec grim -t png - | wl-copy --type image/png
bindsym XF86Launch2 exec grim -t ppm - | $satty
bindsym Sys_Req exec grim -t ppm - | $satty

set $printscreen_mode 'printscreen (r:region, f:full, w:window)'
mode $printscreen_mode {
    bindsym r exec swaymsg 'mode "default"' && grim -t ppm -g "$(slurp -d)" - | $satty
    bindsym f exec swaymsg 'mode "default"' && grim -t ppm - | $satty
    bindsym w exec swaymsg 'mode "default"' && swaymsg -t get_tree | jq -r '.. | select(.focused?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | grim -t ppm -g - - | $satty

    bindsym Return mode "default"
    bindsym Escape mode "default"
}
bindsym $mod+Shift+l mode $printscreen_mode

# albert exec
# exec --no-startup-id albert

# kunkun stuff
# for_window [app_id="kunkun"] floating enable
# for_window [app_id="kunkun"] move absolute position center
# bindsym $mod+K exec "kunkun toggle"

# raycast-clone stuff
# for_window [app_id="hot_dog"] floating enable
# for_window [app_id="hot_dog"] move absolute position center 
# bindsym $mod+J exec "~/projects/hot_dog/target/release/hot_dog toggle"
# for_window [app_id="hot_dog"] move absolute position center 300 500


# meatwar stuff
# for_window [title="Meatwar"] floating enable
# for_window [title="Meatwar"] move position 0 0
# for_window [title="Meatwar"] focus none
# for_window [title="meatwar: client"] floating enable, move position 0 0, move scratchpad
# bindsym $mod+r [title="meatwar: client"] scratchpad show

# bindsym $mod+J exec "~/projects/hot_dog/target/release/hot_dog toggle"


# don't idle when audio is playing
# https://github.com/ErikReider/SwayAudioIdleInhibit
exec sway-audio-idle-inhibit
# # and another one
# exec_always --no-startup-id /usr/local/bin/swaddle &

# Inhibit idle for Stremio when fullscreen or focused
for_window [app_id="com.stremio.stremio"] inhibit_idle fullscreen
for_window [class="stremio"] inhibit_idle fullscreen

# Autolaunch applications
# exec /usr/bin/nextcloud --background

# waystt
bindsym $mod+r exec sh -c "pgrep -x waystt >/dev/null && pkill --signal SIGUSR1 waystt || (waystt --pipe-to ydotool type --key-delay 0 --key-hold 0 --file - &)"

# Clipboard manager
# Two watchers on purpose: an untyped `wl-paste --watch` only fires for text
# selections, so screenshots never reach the history without the image one.
exec --no-startup-id wl-paste --type text --watch cliphist store
exec --no-startup-id wl-paste --type image --watch cliphist store
bindsym $mod+c exec cliphist list | wofi --dmenu | cliphist decode | wl-copy

# Testing Gauntlet
bindsym $mod+m exec gauntlet

# Power menu
bindsym $mod+Shift+e exec ~/.config/sway/scripts/power-menu.sh

# Power profile menu
bindsym $mod+Shift+p exec ~/.config/sway/scripts/power-profile-menu.sh

# borders
default_border none
default_floating_border none
titlebar_padding 1
titlebar_border_thickness 0
workspace_layout tabbed
hide_edge_borders --i3 smart

# Changing audio
bindsym XF86AudioRaiseVolume exec wpctl set-volume @DEFAULT_SINK@ 5%+ --limit 1
bindsym XF86AudioLowerVolume exec wpctl set-volume @DEFAULT_SINK@ 5%- --limit 1
bindsym XF86AudioMute exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
bindsym XF86AudioMicMute exec wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle
bindsym XF86AudioPlay exec playerctl play-pause
bindsym XF86AudioPause exec playerctl pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous

# Changing brightness
bindsym XF86MonBrightnessUp exec /home/lgx/.config/sway/scripts/brightness.sh up
bindsym XF86MonBrightnessDown exec /home/lgx/.config/sway/scripts/brightness.sh down

# Shortcuts
bindsym $mod+e exec wofi-emoji
bindsym $mod+w exec firefox
# Change audio channel
bindsym $mod+p exec ~/.config/sway/scripts/new-audio-switch.sh
# lock screen  # let's be friendly for the oled screen
bindsym $mod+o exec 'swaylock -f --color 000000'

exec_always nm-applet 


# output "DP-1" allow_tearing yes
output "Dell Inc. DELL P2720DC 8D4SK53" subpixel rgb

#protonvpn
# exec_always "protonvpn-app"
# for_window [app_id="protonvpn-app"] move scratchpad
# bindsym $mod+v [app_id="protonvpn-app"] scratchpad show




# nicer touchpad settings
input type:touchpad {
    tap enabled
    natural_scroll disabled
    middle_emulation enabled
    drag_lock disabled
}

# laptop lid stuff
set $laptop eDP-1
bindswitch --locked lid:on output $laptop disable
bindswitch --locked lid:off output $laptop enable
exec_always ~/.config/sway/scripts/clamshellmode.sh

# toggle internal display
bindsym $mod+i exec ~/.config/sway/scripts/toggle-internal-display.sh


#work stuff? not needed anymore
# exec_always {
#     # if at work and either monitor is connected
#     if swaymsg -t get_outputs | grep -q 'DP-1'; then
#             swaymsg output DP-1 pos 0 0 res 1920x1080@120Hz
#     fi
#     if swaymsg -t get_outputs | grep -q 'HDMI-A-1'; then
#         swaymsg output HDMI-A-1 pos 1920 0 res 1920x1080@120Hz
#     fi
# }


# scroll speed
input type:pointer {
    scroll_factor 1
    accel_profile "flat" # disable mouse acceleration (enabled by default; to set it manually, use "adaptive" instead of "flat")
    pointer_accel 0.5 # set mouse sensitivity (between -1 and 1)
}

# we no do background
swaybg_command -

## if not an the bottom, it doesn't work}
# generate sway config file
exec_always --no-startup-id ~/.config/sway/generate-extra-config.sh
# and include it
include ~/.config/sway/generated-extra-config
