#font 'JetBrainsMono NF' 9
#font 'JetBrainsMono Nerd Font Mono' 9
font 'JetBrainsMonoNFM-Regular' 9

### Variables
#set $mod Mod1
set $mod Mod4

set $term kitty 
#set $term foot
#set $term ghostty

set $menu wofi -S drun -GI

set $left h
set $down j
set $up k
set $right l


#env GDK_BACKEND=wayland
#env QT_QPA_PLATFORM=wayland

set $laptop eDP-1
include ~/.config/sway/config.d/*

### Output configuration
# You can get the names of your outputs by running: swaymsg -t get_outputs
# https://gitlab.com/w0lff/shikane for multitple display handling 
#output * bg /home/jozamudi/Documents/Wallpapers/windows-11-stock-official-colorful-3840x2160-5658.jpg fill
#output 'BNQ BenQ PD3200U S2N01233019' scale 1.5
# Baseline for the built-in panel so sway starts at the same geometry shikane
# will apply. Panel is CSOT MND508ZB1-1: 2880x1920 (3:2) with only 120Hz/60Hz
# modes available. Without this, sway defaults to scale 2.0 and the desktop
# visibly re-flows when shikane applies 1.5 a moment after login.
output $laptop mode 2880x1920@120Hz scale 1.75
#exec_always shikanectl reload

bindswitch --reload --locked lid:on output $laptop disable
bindswitch --reload --locked lid:off output $laptop enable
exec_always --no-startup-id '/home/work/.config/sway/scripts/clamshell-mode.sh'
# Re-apply shikane display profile after every sway reload;
# falls back to a service restart if the daemon deadlocked
exec_always --no-startup-id /home/work/.config/sway/scripts/shikane-recover-on-reload.sh

#input "1267:12792:ELAN067B:00_04F3:31F8_Touchpad" {
#    dwt enabled
#    tap enabled
#    middle_emulation enabled
#} 

### Idle configuration
#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'


seat seat0 xcursor_theme Adwaita 35

# Portal implementations are pinned in ~/.config/xdg-desktop-portal/portals.conf
# (default=gtk, ScreenCast/Screenshot=wlr, Inhibit=none, GlobalShortcuts=hyprland).
exec systemctl --user start xdg-desktop-portal-wlr.service
#exec pipewire
# swaync is started by its systemd user unit / D-Bus activation; starting it
# here too caused "already running" crash-loops (start-limit-hit).
#exec swaync
# NOTE: the command must be quoted -- sway splits unquoted ';' into separate
# sway commands and fails with "Unknown/invalid command 'waybar'"
exec_always --no-startup-id "pkill -x waybar; waybar -c ~/.config/sway/waybar/config.jsonc -s ~/.config/sway/waybar/style.css"
exec nm-applet
exec blueman-applet
exec hypridle
# hyprlock can outlive a sway session; a stale instance then makes hypridle's
# "pidof hyprlock || hyprlock" guard a permanent no-op. Clear leftovers at login.
exec --no-startup-id pkill -x hyprlock

# Polkit authentication agent.
# The original line was a typo ("hyperolkitagent"), so no agent ever started.
# hyprpolkitagent is installed but aborts on this machine: hyprtoolkit vendors
# aquamarine, which refuses to create a GBM allocator because the Intel Iris Xe
# iGPU has no PRIME export (drmGetCap DRM_CAP_PRIME -> unsupported) and then
# asserts "Couldn't open a gbm fd" instead of falling back -- 5/5 core dumps.
# Keep hyprpolkitagent.service disabled; polkit-gnome is used instead.
exec /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1
exec flatpak run com.github.wwmm.easyeffects -w
exec xrdb -merge ~/.Xresources

exec tlpctl power-saver

#exec gsettings set org.gnome.desktop.interface color-scheme "prefer-dark"

#exec mpd
#exec syncthing

# Auto start .desktop files using dex -- dex is not installed (and there is no
# ~/.config/autostart), so this was a no-op.
#exec dex -a

#exec wl-paste -t text --watch clipman store --no-persist
# There are two wl-paste watchers on purpose: one for the regular clipboard,
# one for the primary selection (clipman keeps a single shared history, the
# --primary flag on `pick` only decides where the picked item is served).
# Guarded with pkill because `exec` re-runs on every `swaymsg reload`: a stale
# `store --no-persist` instance from an older config survived three reloads and
# ran alongside the current pair.
# NOTE: `pkill -x` matches the process *name* only. Do NOT use `pkill -f` here --
# sway runs exec lines through `sh -c`, so the wrapper's own command line
# contains the pattern and pkill would kill the shell that is about to start
# the replacements (learned the hard way).
exec_always --no-startup-id "pkill -x wl-paste; sleep 0.3; \
    wl-paste -t text --watch clipman store & \
    wl-paste -p -t text --watch clipman store & \
    wait"
# The keybind to select a clipping
bindsym $mod+y           exec clipman --primary pick --tool wofi
# Clear all clippings
bindsym $mod+Shift+y     exec clipman clear -a
# Remove a selected clipping
bindsym $mod+Mod1+y      exec clipman clear --tool wofi
# Empty the current clipping
bindsym $mod+Ctrl+y      exec : | wl-copy -p

#better audio
#exec easyeffects -w -l Laptop 

default_border pixel 2
#default_floating_border pixel 2
exec systemctl --user import-environment XDG_SESSION_TYPE XDG_CURRENT_DESKTOP WAYLAND_DISPLAY SWAYSOCK
exec dbus-update-activation-environment --systemd WAYLAND_DISPLAY DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP=sway XDG_SESSION_DESKTOP=sway
# Activate graphical-session.target so xdg-desktop-portal (Requisite=graphical-session.target) can start
exec systemctl --user start sway-session.target
#exec --no-startup-id dbus-update-activation-environment --all

