#░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
#░   ░░░░   ░░░░░░░░░░░░░░░░░░░░░░░░░░░░   ░░░░░░░░░░░░░░░░░░░░░░░░░░░   ░░░░░░░░░░░░   ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░   ░░░░░░░░░░░░░░
#▒   ▒▒▒▒   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒   ▒▒▒▒▒▒▒▒▒   ▒▒▒   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  ▒▒▒▒▒▒  ▒▒▒▒▒▒▒▒▒
#▒   ▒▒▒▒   ▒   ▒▒▒   ▒  ▒   ▒▒▒  ▒    ▒   ▒▒▒▒   ▒▒▒▒▒   ▒   ▒▒▒▒▒▒▒▒   ▒▒▒▒▒▒▒▒   ▒▒▒▒▒▒▒▒▒▒▒   ▒▒▒▒▒   ▒   ▒▒▒    ▒  ▒▒▒▒▒▒▒     ▒▒
#▓          ▓▓   ▓   ▓▓  ▓▓   ▓▓▓   ▓▓▓▓   ▓▓   ▓▓   ▓▓▓   ▓▓   ▓▓   ▓   ▓▓▓▓▓▓▓▓   ▓▓▓▓▓▓▓▓▓   ▓▓   ▓▓▓   ▓▓   ▓▓▓   ▓▓▓▓   ▓   ▓▓   
#▓   ▓▓▓▓   ▓▓▓▓    ▓▓▓  ▓▓▓   ▓▓   ▓▓▓▓   ▓   ▓▓▓   ▓▓▓   ▓▓   ▓  ▓▓▓   ▓▓▓▓▓▓▓▓   ▓▓▓▓▓▓▓▓   ▓▓▓▓   ▓▓   ▓▓   ▓▓▓   ▓▓▓▓   ▓  ▓▓▓   
#▓   ▓▓▓▓   ▓▓▓▓▓   ▓▓▓   ▓   ▓▓▓   ▓▓▓▓   ▓   ▓▓▓   ▓▓▓   ▓▓   ▓  ▓▓▓   ▓▓▓▓▓▓▓▓▓   ▓▓▓   ▓▓   ▓▓   ▓▓▓   ▓▓   ▓▓▓   ▓▓▓▓   ▓    ▓   
#█   ████   ████   ████   ██████    ████   ███   █    █    ██   ██   █   ███████████     ██████   █████    ██   ███   ████   █████   █
#██████████████   █████   ██████████████████████████████████████████████████████████████████████████████████████████████████████    ██




#----------#
# MONITORS #
#----------#

monitor=eDP-1, 2880x1800@60, 0x0, 1.5
# monitor=,highres highrr, auto, 1


#-----------------------#
# LAUNCHING OF PROGRAMS #
#-----------------------#
exec-once = dunst
# exec-once = wl-clipboard-history -t
exec-once = ~/.config/hypr/xdg-portal-hyprland
exec-once = dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP XAUTHORITY DISPLAY
exec-once = systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
exec-once = /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1
exec-once = waybar
exec-once = hypridle

# exec-once = openrgb --startminimized
# exec-once = polychromatic-tray-applet
# exec-once = blueman-applet
exec-once = nm-applet
exec-once = nextcloud

exec = swaybg -m fill -i /home/janis/Pictures/arch-bg.png

exec = hyprctl setcursor oreo_spark_blue_cursors 36
env = QT_QPA_PLATFORM,wayland
env = QT_QPA_PLATFORM_THEME,qt6ct
# env = GDK_SCALE,2
# env = GDK_DPI_SCALE,0.75

env = HYPRCURSOR_THEME, Oreo_spark_blue_cursor
env = X_CURSOR_THEME, Oreo_spark_blue_cursor
env = XCURSOR_SIZE,24
# env = ELECTRON_OZONE_PLATFORM_HINT,wayland

#-------#
# INPUT #
#-------#
input {
    kb_layout = ch
    natural_scroll = true

    numlock_by_default = true

    follow_mouse = 2
    mouse_refocus = true

    touchpad {
        disable_while_typing = true
        natural_scroll = true
    }

    sensitivity = 0 # -1.0 - 1.0, 0 means no modification.
}


#----------------#
# GENERAL CONFIG #
#----------------#
general {
    # See https://wiki.hyprland.org/Configuring/Variables/ for more

    gaps_in = 3
    gaps_out = 10
    border_size = 1
    col.active_border = rgba(2288ffee) rgba(a6f7adff) 45deg
    col.inactive_border = rgba(595959aa)

    layout = master
    no_border_on_floating = false
}

decoration {
    # See https://wiki.hyprland.org/Configuring/Variables/ for more
    inactive_opacity = 1
    rounding = 10

    shadow {
        enabled = false
        range = 4
        color = rgba(1a1a1aee)
    }
    
    blur {
        enabled = false
        xray = true
        new_optimizations = true
        size = 1
        passes = 2
    }
    dim_inactive = true
    dim_strength = 0.1
}

animations {
    enabled = yes

    # Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more

    bezier = myBezier, 0.05, 0.9, 0.1, 1.05

    animation = windows, 1, 7, myBezier
    animation = windowsOut, 1, 7, default, popin 80%
    animation = border, 1, 10, default
    animation = fade, 1, 7, default
    animation = workspaces, 1, 6, default
}

misc {
    disable_hyprland_logo = true
    disable_splash_rendering = false
    vrr = 2
    vfr = 1
    allow_session_lock_restore = true
}

dwindle {
    # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
    pseudotile = yes # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
    preserve_split = yes # you probably want this
}

master {
    # See https://wiki.hyprland.org/Configuring/Master-Layout/ for more
}

gestures {
    # See https://wiki.hyprland.org/Configuring/Variables/ for more
    workspace_swipe = true
    workspace_swipe_distance = 300
}

cursor {
    no_warps = false
    inactive_timeout = 60
}

xwayland {
    force_zero_scaling = true
}


# Display full sized (without gaps), if only window on screen
workspace = w[tv1], gapsout:0, gapsin:0
workspace = f[1], gapsout:0, gapsin:0
windowrulev2 = bordersize 0, floating:0, onworkspace:w[tv1]
windowrulev2 = rounding 0, floating:0, onworkspace:w[tv1]
windowrulev2 = bordersize 0, floating:0, onworkspace:f[1]
windowrulev2 = rounding 0, floating:0, onworkspace:f[1]


# See https://wiki.hyprland.org/Configuring/Keywords/ for more
$mainMod = SUPER

# WINDOW RULES
windowrule = float, title:^(.*)(rofi)(.*)$
# windowrule = size 800 900, title:^(.*)(rofi)(.*)$
windowrule = animation popin, title:^(.*)(rofi)(.*)$
windowrule = center, title:^(.*)(rofi)(.*)$
windowrule = move 1450 50, title:^(.*)(Power menu)$
windowrule = workspace 2, evince
windowrule = workspace 2, okular
windowrule = fullscreen, title:wlogout
windowrule = workspace 2, title:^(.*)(LibreWolf)(.*)$
windowrule = workspace 2, title:^(.*)(WebCord)(.*)$
windowrule = workspace 3, title:^(Steam)(.*)$
windowrule = workspace 1, title:^(.*)(VSCodium)$
windowrule = workspace 3, minecraft-launcher
windowrule = tile, minecraft-launcher
windowrule = fullscreen, title:^(.*)Minecraft*(.*)$
windowrule = workspace 3, title:^(.*)Minecraft*(.*)$
# Hide terminator
windowrule = float, title:^(.*)hidden-terminator(.*)$
windowrule = size 0 0, title:^(.*)hidden-terminator(.*)$
windowrule = move 3000 0, title:^(.*)hidden-terminator(.*)$
windowrule = workspace 1, title:^(.*)hidden-terminator(.*)$

windowrule = float, file_progress
windowrule = float, confirm
windowrule = float, dialog
windowrule = float, download
windowrule = float, notification
windowrule = float, error
windowrule = float, splash
windowrule = float, confirmreset
windowrule = float, title:Open File
windowrule = float, title:branchdialog
windowrule = float, Lxappearance
windowrule = float, title:^(Media viewer)$
windowrule = float, title:^(Volume Control)$
windowrule = float, title:^(Picture-in-Picture)$
windowrule = float, title:^(Loading)(.*)$
windowrule = float, pavucontrol-qt
windowrule = float, pavucontrol
windowrule = float, file-roller
windowrule = idleinhibit always, ^(Steam)$
windowrule = idleinhibit focus, ^(Rocket League)(.*)$
windowrule = fullscreen, ^(Steam Big Picture)$
windowrule = idleinhibit always, steam
windowrule = idleinhibit always, lutris
windowrule = idleinhibit focus, vlc
windowrule = idleinhibit focus, supertuxkart
windowrule = idleinhibit fullscreen, title:^(.*)(WebCord)(.*)$
windowrule = idleinhibit fullscreen, title:^(.*)(~)(.*)$
windowrule = idleinhibit focus, title:^(.*)(~)(.*)$
windowrule = idleinhibit focus, title:^(.*)(LibreWolf)(.*)$

# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
bind = $mainMod, Q, killactive
bind = $mainMod SHIFT, Q, exit
bind = $mainMod, Return, exec, kitty
# bind = $mainMod, Return, exec, terminator
bind = $mainMod, C, killactive, 
bind = $mainMod, E, exec, thunar
bind = $mainMod, V, togglefloating,
bind = $mainMod, F, fullscreen,

# Launch commands
bind = $mainMod SHIFT, L, exec, librewolf
bind = $mainMod SHIFT, K, exec, librewolf http://localhost:8080/admin && librewolf http://localhost:8081/test/login
bind = $mainMod SHIFT, D, exec, terminator --title "hidden-terminator" -e "GDK_SCALE=2 webcord && exit"
# bind = $mainMod SHIFT, D, exec, webcord
# bind = $mainMod SHIFT, V, exec, terminator --title "hidden-terminator" -e "GDK_SCALE=2 codium && exit"
bind = $mainMod SHIFT, V, exec, codium
bind = $mainMod SHIFT, T, exec, thunderbird
bind = $mainMod SHIFT, M, exec, systemctl start docker && terminator -e "sudo docker run -it --network=host --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size 16G --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v /home/janis/projects:/mnt rocm/pytorch:latest"
# bind = $mainMod SHIFT, G, exec, notify-send 'Preparing system for gaming...' && /usr/lib/polkit-kde-authentication-agent-1 && notify-send 'Starting CoreCtrl...' && corectrl
bind = $mainMod SHIFT, G, exec, notify-send 'Preparing system for gaming...' && corectrl
bind = $mainMod SHIFT, P, exec, notify-send 'Steam is launching...' && steam
bind = $mainMod SHIFT, R, exec, notify-send 'START CORECTRL! (Super + Shift + G twice). Launching in Remoteplay optimised session' && steam -pipewire
bind = $mainMod CTRL, K, exec, notify-send 'Insta-Kill activated' && hyprctl kill

# Screenshots
bind = $mainMod SHIFT, S, exec, grimblast --notify copy area
bind = $mainMod CTRL, S, exec, grimblast --notify copysave area
bind = $mainMod ALT, S, exec, grimblast --notify save area
bind = , PRINT, exec, grimblast --notify copy screen
bind = CTRL, PRINT, exec, grimblast --notify copysave screen
bind = SHIFT, PRINT, exec, grimblast --notify save screen

# Rofi commands
bind = $mainMod, Space, exec, killall rofi || rofi -show combi -modes combi -combi-modes "window,drun,run"
bind = $mainMod SHIFT, Space, exec, rofi -modi "Global Search":"~/.config/rofi/spotlight/rofi-spotlight.sh" -show "Global Search" -config ~/.config/rofi/spotlight/rofi.rasi
bind = $mainMod, P, exec, killall rofi || rofi -show p -modi p:rofi-power-menu -theme ~/.config/rofi/themes/power.rasi

# Logout commands
bind = $mainMod, escape, exec, wlogout
bind = $mainMod, L, exec, hyprlock
#bind = $mainMod, L, exec, swaylock --screenshots --clock --indicator --grace 10 --fade-in 2 --effect-blur 10x10 --indicator-radius 200 --ring-color ff0202 --show-failed-attempts --effect-greyscale --effect-vignette 0.6:0.6

# Move focus with mainMod + arrow keys
bind = $mainMod, left, movefocus, l
bind = $mainMod, right, movefocus, r
bind = $mainMod, up, movefocus, u
bind = $mainMod, down, movefocus, d

# Switch workspaces with mainMod + [0-9]
bind = $mainMod, 1, workspace, 1
bind = $mainMod, 2, workspace, 2
bind = $mainMod, 3, workspace, 3
bind = $mainMod, 4, workspace, 4
bind = $mainMod, 5, workspace, 5
bind = $mainMod, 6, workspace, 6
bind = $mainMod, 7, workspace, 7
bind = $mainMod, 8, workspace, 8
bind = $mainMod, 9, workspace, 9
bind = $mainMod, 0, workspace, 10
bind = $mainMod ALT, left, workspace, e-1
bind = $mainMod ALT, right, workspace, e+1


# Move active window to a workspace with mainMod + SHIFT + [0-9]
bind = $mainMod SHIFT, 1, movetoworkspace, 1
bind = $mainMod SHIFT, 2, movetoworkspace, 2
bind = $mainMod SHIFT, 3, movetoworkspace, 3
bind = $mainMod SHIFT, 4, movetoworkspace, 4
bind = $mainMod SHIFT, 5, movetoworkspace, 5
bind = $mainMod SHIFT, 6, movetoworkspace, 6
bind = $mainMod SHIFT, 7, movetoworkspace, 7
bind = $mainMod SHIFT, 8, movetoworkspace, 8
bind = $mainMod SHIFT, 9, movetoworkspace, 9
bind = $mainMod SHIFT, 0, movetoworkspace, 10
bind = $mainMod SHIFT, left, movetoworkspace, e-1
bind = $mainMod SHIFT, right, movetoworkspace, e+1

# Scroll through existing workspaces with mainMod + scroll
bind = $mainMod, mouse_down, workspace, e+1
bind = $mainMod, mouse_up, workspace, e-1

# Tile window to a part of the screen
bind = $mainMod CTRL, left, movewindow, left
bind = $mainMod CTRL, right, movewindow, right

# move to next window / previous window with ALT + Tab / SHIFT + ALT + Tab
bind = ALT SHIFT, tab, cyclenext, prev
# bind = ALT, tab, cyclenext, next
# bind = ALT CTRL, tab, focusurgentorlast
bind = ALT, tab, focusurgentorlast

# Master layout commands
bind = $mainMod CTRL, M, layoutmsg, swapwithmaster
bind = $mainMod SHIFT, A, layoutmsg, addmaster
bind = $mainMod SHIFT CTRL, right, layoutmsg, orientationnext
bind = $mainMod SHIFT CTRL, left, layoutmsg, orientationprev

# Move/resize windows with mainMod + LMB/RMB and dragging
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow


# Freeze
bind = $mainMod SHIFT, escape, exec, hyprfreeze -a


# Volume control
bind = ,code:123, exec, pamixer -i 5
bind = ,code:122, exec, pamixer -d 5
bind = ,code:121, exec, pamixer -t


# Brightness-Control
bind = ,code:232, exec, light -U 5 && notify-send 'Display brightness decreased by 5%'
bind = ,code:233, exec, light -A 5 && notify-send 'Display brightness increased by 5%'


# Monitor config binds
bind = $mainMod CTRL, D, exec, hyprctl keyword monitor HDMI-A-1, 1920x1080@60, 1920x0, 1, mirror, eDP-1 && notify-send 'Set to mirror internal display'
bind = $mainMod CTRL, E, exec, hyprctl keyword monitor HDMI-A-1, 1920x1080@60, 1920x0, 1 && notify-send 'Set to expand external display'

# Internal display controls
bind = $mainMod ALT, E, exec, hyprctl keyword monitor eDP-1, 2880x1800@60, 0x0, 1.5 && notify-send 'Set to battery optimized display settings'
bind = $mainMod ALT, P, exec, hyprctl keyword monitor eDP-1, preferred, 0x0, 1.5 && notify-send 'Set to performance optimized display settings'
