# Hyprland config, aligned with the Sway desktop profile.

$mod = SUPER
$terminal = alacritty
$browser = firefox

monitor = ,preferred,auto,1

env = XCURSOR_THEME,Yaru
env = XCURSOR_SIZE,24

input {
  kb_layout = us
  kb_variant = intl
  follow_mouse = 0
}

cursor {
  no_hardware_cursors = false
}

general {
  gaps_in = 5
  gaps_out = 20
  border_size = 3
  col.active_border = rgba(54d6ffff) rgba(1478ffff) 180deg
  col.inactive_border = rgba(f5e6b899) rgba(8a8f9acc) 180deg
  layout = master
}

decoration {
  rounding = 8

  blur {
    enabled = true
    size = 5
    passes = 1
  }

  shadow {
    enabled = true
  }

  dim_inactive = true
  dim_strength = 0.1
}

animations {
  enabled = true
  bezier = easeOutQuint,0.23,1,0.32,1
  animation = windows,1,2,easeOutQuint,popin 85%
  animation = border,1,2,easeOutQuint
  animation = fade,1,2,easeOutQuint
  animation = workspaces,1,2,easeOutQuint,slide
  animation = layers,1,2,easeOutQuint,fade
}

master {
  new_status = slave
  orientation = left
}

misc {
  disable_hyprland_logo = true
  disable_splash_rendering = true
  force_default_wallpaper = 0
  focus_on_activate = false
}

xwayland {
  enabled = true
}

# Per-host overrides (terminal wrapper, env, monitors, workspace rules, etc.).
source = ~/.config/hypr/host.conf

# Window rules
windowrule = float on, match:class (?i)(polkit)
windowrule = float on, match:title ^Authentication Required$
windowrule = float on, match:title ^Open File$
windowrule = float on, match:title ^Save File$
windowrule = float on, match:class (?i)(blueman-manager)
windowrule = float on, match:class (?i)(nm-connection-editor)
windowrule = float on, match:class (?i)(pinentry)
windowrule = float on, match:class (?i)(firefox), match:title ^Library$
windowrule = float on, match:class (?i)(firefox), match:title ^About Mozilla Firefox$
windowrule = float on, match:class org.freedesktop.impl.portal.desktop.gtk
windowrule = idle_inhibit fullscreen, match:fullscreen true
windowrule = idle_inhibit focus, match:content 2

# Autostart — XDG and session services
exec-once = dbus-update-activation-environment DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP XDG_SESSION_TYPE XDG_SESSION_DESKTOP
exec-once = env UPDATE_TURNSTILE_RESTART_EMACS=1 ~/.local/bin/update-turnstile-env
exec-once = dex --autostart --environment Hyprland
exec-once = gnome-keyring-daemon --start --components=secrets
exec-once = ~/.local/bin/setup-gtk-theme
exec-once = /usr/libexec/xdg-desktop-portal
exec-once = /usr/libexec/xdg-desktop-portal-hyprland
exec-once = /usr/libexec/xdg-desktop-portal-gtk

# Audio/session services
exec-once = pipewire
exec-once = pipewire-pulse
exec-once = wireplumber

# Desktop services
exec-once = hyprctl setcursor Yaru 24
exec-once = hyprpaper
exec-once = waybar -c ~/.config/waybar/hyprland.jsonc -s ~/.config/waybar/hyprland-style.css
exec-once = swayosd-server
exec-once = dunst
exec-once = hyprpolkitagent
exec-once = nm-applet
exec-once = blueman-applet
exec-once = udiskie
exec-once = hypridle

# Clipboard manager
exec-once = wl-paste --type text --watch cliphist store
exec-once = wl-paste --type image --watch cliphist store

# Applications
bind = $mod, Return, exec, $terminal
bind = $mod SHIFT, Return, exec, foot
bind = $mod SHIFT, E, exec, emacsclient -c -n
bind = $mod, D, exec, rofi -show drun -theme ~/.config/rofi/config.rasi
bind = $mod, C, exec, cliphist list | rofi -dmenu -theme ~/.config/rofi/config.rasi | cliphist decode | wl-copy
bind = $mod SHIFT, V, exec, pavucontrol
bind = $mod SHIFT, F, exec, thunar
bind = $mod SHIFT, D, exec, dunstctl set-paused toggle
bind = $mod SHIFT, X, exec, ~/.config/hypr/scripts/lock-and-dpms
bind = $mod SHIFT, Q, killactive

# Screenshots (Hyprland-native: grim/slurp/wl-copy; Flameshot is unstable here)
bind = , Print, exec, ~/.config/hypr/scripts/screenshot region
bind = SHIFT, Print, exec, ~/.config/hypr/scripts/screenshot full
bind = ALT, Print, exec, ~/.config/hypr/scripts/screenshot output

# Focus
bind = $mod, H, movefocus, l
bind = $mod, J, movefocus, d
bind = $mod, K, movefocus, u
bind = $mod, L, movefocus, r
bind = $mod, left, movefocus, l
bind = $mod, down, movefocus, d
bind = $mod, up, movefocus, u
bind = $mod, right, movefocus, r

# Move windows
bind = $mod SHIFT, H, movewindow, l
bind = $mod SHIFT, J, movewindow, d
bind = $mod SHIFT, K, movewindow, u
bind = $mod SHIFT, L, movewindow, r
bind = $mod SHIFT, left, movewindow, l
bind = $mod SHIFT, down, movewindow, d
bind = $mod SHIFT, up, movewindow, u
bind = $mod SHIFT, right, movewindow, r

# Layouts / floating
bind = $mod, F, fullscreen
bind = $mod SHIFT, Space, togglefloating
bind = $mod, Space, cyclenext
bind = $mod, A, layoutmsg, swapwithmaster
bindm = $mod, mouse:272, movewindow
bindm = $mod, mouse:273, resizewindow

# Scratchpad-like special workspace
bind = $mod SHIFT, minus, movetoworkspace, special
bind = $mod, minus, togglespecialworkspace

# Volume / brightness / media
bind = , XF86AudioRaiseVolume, exec, swayosd-client --output-volume raise
bind = , XF86AudioLowerVolume, exec, swayosd-client --output-volume lower
bind = , XF86AudioMute, exec, swayosd-client --output-volume mute-toggle
bind = , XF86AudioMicMute, exec, swayosd-client --input-volume mute-toggle
bind = , XF86MonBrightnessUp, exec, swayosd-client --brightness raise
bind = , XF86MonBrightnessDown, exec, swayosd-client --brightness lower
bind = , XF86AudioPlay, exec, playerctl play-pause
bind = , XF86AudioNext, exec, playerctl next
bind = , XF86AudioPrev, exec, playerctl previous

# Workspaces
bind = $mod, 1, workspace, 1
bind = $mod, 2, workspace, 2
bind = $mod, 3, workspace, 3
bind = $mod, 4, workspace, 4
bind = $mod, 5, workspace, 5
bind = $mod, 6, workspace, 6
bind = $mod, 7, workspace, 7
bind = $mod, 8, workspace, 8
bind = $mod, 9, workspace, 9
bind = $mod, 0, workspace, 10
bind = $mod, comma, exec, ~/.config/hypr/scripts/workspace-cycle prev
bind = $mod, period, exec, ~/.config/hypr/scripts/workspace-cycle next

bind = $mod SHIFT, 1, movetoworkspace, 1
bind = $mod SHIFT, 2, movetoworkspace, 2
bind = $mod SHIFT, 3, movetoworkspace, 3
bind = $mod SHIFT, 4, movetoworkspace, 4
bind = $mod SHIFT, 5, movetoworkspace, 5
bind = $mod SHIFT, 6, movetoworkspace, 6
bind = $mod SHIFT, 7, movetoworkspace, 7
bind = $mod SHIFT, 8, movetoworkspace, 8
bind = $mod SHIFT, 9, movetoworkspace, 9
bind = $mod SHIFT, 0, movetoworkspace, 10

# Reload / exit
bind = $mod SHIFT, C, exec, hyprctl reload
bind = $mod SHIFT, R, exec, hyprctl reload
bind = $mod SHIFT, BackSpace, exit
bind = $mod SHIFT, Escape, exec, ~/.config/hypr/scripts/powermenu.sh

# Resize submap
bind = $mod, R, submap, resize
submap = resize
bind = , H, resizeactive, -10 0
bind = , J, resizeactive, 0 10
bind = , K, resizeactive, 0 -10
bind = , L, resizeactive, 10 0
bind = , left, resizeactive, -10 0
bind = , down, resizeactive, 0 10
bind = , up, resizeactive, 0 -10
bind = , right, resizeactive, 10 0
bind = , Return, submap, reset
bind = , Escape, submap, reset
bind = $mod, R, submap, reset
submap = reset
