##################################
# zegonix hyprland configuration #
##################################


# monitors setup
## this is separated into its own file in order to
## be able to maintain multiple configurations
source = ~/.config/hypr/monitors.conf

workspace = 1, monitor:$main_display
workspace = 2, monitor:$secondary_display
exec-once = hyprctl dispatch workspace 1


# programs
$screenlocker = hyprlock
$terminal = foot
$menu = fuzzel


# setup environment
env = XCURSOR_SIZE,24
env = HYPRCURSOR_SIZE,24

exec-once = tmux setenv -g HYPRLAND_INSTANCE_SIGNATURE "$HYPRLAND_INSTANCE_SIGNATURE"
exec-once = hyprpaper
exec-once = hypridle
exec-once = waybar


# keybindings
$Mod = SUPER
bind = $Mod, Escape, exec, $screenlocker
bind = $Mod, Return, exec, $terminal
bind = $Mod, t, exec, $terminal tmux attach
bind = $Mod, d, exec, $menu
bind = $Mod, q, killactive,
bind = $Mod SHIFT, q, forcekillactive
bind = $Mod, a, exec, audio-sink-switcher.sh
bind = $Mod, m, exec, hyprland-kb-layout-switcher.sh
bind = $Mod SHIFT, m, exec, hyprctl switchxkblayout all next

## move 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 focused window
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

## switch to numbered workspace
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

## move active window to numbered workspace
bind = $Mod SHIFT, 1, movetoworkspacesilent, 1
bind = $Mod SHIFT, 2, movetoworkspacesilent, 2
bind = $Mod SHIFT, 3, movetoworkspacesilent, 3
bind = $Mod SHIFT, 4, movetoworkspacesilent, 4
bind = $Mod SHIFT, 5, movetoworkspacesilent, 5
bind = $Mod SHIFT, 6, movetoworkspacesilent, 6
bind = $Mod SHIFT, 7, movetoworkspacesilent, 7
bind = $Mod SHIFT, 8, movetoworkspacesilent, 8
bind = $Mod SHIFT, 9, movetoworkspacesilent, 9
bind = $Mod SHIFT, 0, movetoworkspacesilent, 10

## move active window and switch to workspace
bind = $Mod ALT, 1, movetoworkspace, 1
bind = $Mod ALT, 2, movetoworkspace, 2
bind = $Mod ALT, 3, movetoworkspace, 3
bind = $Mod ALT, 4, movetoworkspace, 4
bind = $Mod ALT, 5, movetoworkspace, 5
bind = $Mod ALT, 6, movetoworkspace, 6
bind = $Mod ALT, 7, movetoworkspace, 7
bind = $Mod ALT, 8, movetoworkspace, 8
bind = $Mod ALT, 9, movetoworkspace, 9
bind = $Mod ALT, 0, movetoworkspace, 10

# .. alt + tab ..
bind = ALT SHIFT, Tab, workspace, e-1
bind = ALT,       Tab, workspace, e+1

# move focused workspace to output
bind = $Mod, u, movecurrentworkspacetomonitor, l
bind = $Mod, i, movecurrentworkspacetomonitor, d
bind = $Mod, o, movecurrentworkspacetomonitor, u
bind = $Mod, p, movecurrentworkspacetomonitor, r

## make window fullscreen
bind = $Mod, f, fullscreen

## mouse integration for moving and resizing windows
bindm = $Mod, mouse:272, movewindow
bindm = $Mod, mouse:273, resizewindow

## volume control
bindel = ,XF86AudioRaiseVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+
bindel = ,XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-
bindel = ,XF86AudioMute,        exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
bindel = ,XF86AudioMicMute,     exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle

## play/pause events
bindl = , XF86AudioNext,  exec, playerctl next
bindl = , XF86AudioPause, exec, playerctl play-pause
bindl = , XF86AudioPlay,  exec, playerctl play-pause
bindl = , XF86AudioPrev,  exec, playerctl previous
bindl = , XF86AudioStop,  exec, playerctl stop

# screenshot utility
$screenshot_directory = $HOME/Pictures/screenshots/
exec = mkdir -p $screenshot_directory
bind = $Mod, s, exec, slurp | grim -g - - | wl-copy
bind = $Mod SHIFT, s, exec, slurp | grim -g - "$screenshot_directory/$(date '+%Y%m%d_%H%M%S')_screenshot.png"

#FIX:############
### AUTOSTART ###
#################

# Autostart necessary processes (like notifications daemons, status bars, etc.)
# Or execute your favorite apps at launch like this:

# exec-once = $terminal
# exec-once = nm-applet &
# exec-once = waybar & hyprpaper & firefox


###################
### PERMISSIONS ###
###################

# See https://wiki.hyprland.org/Configuring/Permissions/
# Please note permission changes here require a Hyprland restart and are not applied on-the-fly
# for security reasons

# ecosystem {
#   enforce_permissions = 1
# }

# permission = /usr/(bin|local/bin)/grim, screencopy, allow
# permission = /usr/(lib|libexec|lib64)/xdg-desktop-portal-hyprland, screencopy, allow
# permission = /usr/(bin|local/bin)/hyprpm, plugin, allow

input {
    # keyboard
    kb_layout = us, us, ch
    kb_variant = basic, intl, basic

    # mouse
    sensitivity = 0.5
    accel_profile = flat

    # cursor
    follow_mouse = 2
    float_switch_override_focus = 0
}

cursor {
    no_hardware_cursors = true
}

# general settings
general {
    # layout
    layout = master

    # borders
    border_size = 1
    gaps_in = 6
    gaps_out = 12
    col.inactive_border = rgba(00000000)
    col.active_border = rgba(15D7E5FF)
    col.nogroup_border = rgba(00000000)
    col.nogroup_border_active = rgba(15D7E5FF)

    # behaviour
    no_focus_fallback = false
    resize_on_border = true
    extend_border_grab_area = 8
    hover_icon_on_border = true
    resize_corner = 0

    # tearing
    # potentially exclude games from buffering?
    allow_tearing = false
}

# layout settings
master {
    mfact = 0.5
    new_status = slave
    new_on_active = after
    orientation = left
}

# visual settings
decoration {
    # corners
    rounding = 0
    rounding_power = 2

    # transparency
    active_opacity = 1.0
    inactive_opacity = 1.0
    fullscreen_opacity = 1.0

    # misc
    dim_inactive = false
    border_part_of_window = true
    shadow:enabled = false
    blur:enabled = false
}

# this and that
misc {
    disable_hyprland_logo = true
    font_family = JetBrainsMonoNerdFont
    splash_font_family = JetBrainsMonoNerdFont
    mouse_move_focuses_monitor = false
    mouse_move_enables_dpms = false
    key_press_enables_dpms = true
    focus_on_activate = false
    allow_session_lock_restore = true
    background_color = rgba(202020FF)
    middle_click_paste = false
}

# bääh
animations:enabled = false

# window rules
windowrule = match:class steam_app.*, idle_inhibit always
windowrule = match:title Steam, tile true
windowrule = match:title Friends List, tile true

windowrule = match:class foot, opacity 0.9
windowrule = match:class com.mitchellh.ghostty, opacity 0.9
windowrule = match:class SpeedCrunch, opacity 0.93


# ..
exec-once=dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
