#env=LIBSEAT_BACKEND,seatd
# env = HYPRLAND_LOG_WLR,1
#env = WLR_DRM_DEVICES,$HOME/.config/hypr/nvidia:$HOME/.config/hypr/amd
#env = WLR_DRM_DEVICES,$HOME/.config/hypr/amd:$HOME/.config/hypr/nvidia
# env = WLR_DRM_DEVICES,$HOME/.config/hypr/amd-render:$HOME/.config/hypr/nvidia-render
#env = LIBVA_DRIVER_NAME,nvidia
#env = XDG_SESSION_TYPE,wayland
#env = GBM_BACKEND,nvidia-drm
#env = __GLX_VENDOR_LIBRARY_NAME,nvidia
#cursor { no_hardware_cursors = true }

# env = AQ_DRM_DEVICES,/dev/dri/card1
#env = AQ_NO_MODIFIERS,1
monitor=,preferred,auto,1

# env = LIBVA_DRIVER_NAME,nvidia
# env = XDG_SESSION_TYPE,wayland
# env = GBM_BACKEND,nvidia-drm
# env = __GLX_VENDOR_LIBRARY_NAME,nvidia

cursor {
    no_hardware_cursors = true
}

render {
    explicit_sync = false
}

source = ~/.config/hypr/monitors.conf
source = ~/.config/hypr/workspaces.conf
source = ~/.config/hypr/hyprland.colors.conf

debug:disable_logs = false

debug {
	disable_logs = false
}

plugin {
    hyprtrails {
        color = rgba(ffaa00ff)
    }
    hyprexpo {
        columns = 3
        gap_size = 5
        bg_col = rgb(111111)
        workspace_method = center current # [center/first] [workspace] e.g. first 1 or center m+1

        enable_gesture = true # laptop touchpad
        gesture_fingers = 3  # 3 or 4
        gesture_distance = 300 # how far is the "max"
        gesture_positive = true # positive = swipe down. Negative = swipe up.
    }
}

# See https://wiki.hyprland.org/Configuring/Monitors/
#monitor=,preferred,auto,auto


# See https://wiki.hyprland.org/Configuring/Keywords/ for more

# Execute your favorite apps at launch
# exec-once = waybar & hyprpaper & firefox

# KDE auth agent

exec-once=dbus-update-activation-environment --systemd --all
exec-once=systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP QT_QPA_PLATFORMTHEME
# exec-once=/usr/lib/polkit-kde-authentication-agent-1
exec-once = systemctl --user start hyprpolkitagent
exec-once=otd-daemon
exec-once=lorri daemon

#exec-once=wlsunset -S 6:00 -s 21:30
# exec-once=swaybg -m fill -i ~/.config/hypr/wallpapers/sunflowers.jpg
exec-once = swww-daemon
# "$(cat ~/.local/state/quickshell/user/generated/wallpaper/path.txt)"
exec-once = sleep 0.5; swww img ~/.config/hypr/wallpapers/sunflowers.jpg --transition-step 100 --transition-fps 120 --transition-type grow --transition-angle 30 --transition-duration 1
# exec-once=waybar
exec-once=quickshell
exec-once=blueman-applet
exec-once=dunst
exec-once=udev-block-notify
#exec-once=~/.config/hypr/scripts/sleep.sh
exec-once=echo us > /tmp/kb_layout
#exec-once=hyprctl setcursor Sweet 30
exec-once=sleep 10;aw-qt& sleep 2; awatcher
exec-once = nm-applet --indicator # systray app for Network/Wifi
exec-once=kdeconnect-indicator
exec-once = hyprpm reload -n
exec-once = wl-paste --type text --watch cliphist store
exec-once = wl-paste --type image --watch cliphist store
exec-once = fcitx5
exec-once = easyeffects --gapplication-service

#$swaylock = swaylock --screenshots --clock --indicator --effect-blur 6x6 --fade-in 0.2 --ring-color 4e9dc2 --key-hl-color 71b0ce
$swaylock = hyprlock
exec-once=hypridle

# exec-once=swayidle -w timeout 300 '$swaylock --grace 2' before-sleep '$swaylock'
# Needs repackaging...
# exec-once=/usr/lib/pam_kwallet_init

env = QT_QPA_PLATFORMTHEME,qt5ct
env = QT_AUTO_SCREEN_SCALE_FACTOR,1
env = QT_ENABLE_HIGHDPI_SCALING,1
env = QT_QPA_PLATFORM,wayland;xcb
env = XCURSOR_SIZE,24
env = LIBVA_DRIVER_NAME,nvidia
env = XDG_SESSION_TYPE,wayland
env = __GLX_VENDOR_LIBRARY_NAME,nvidia
#env = WLR_NO_HARDWARE_CURSORS,1
env = WLR_DRM_DEVICES,/dev/dri/card1:/dev/dri/card0
env = GDK_SCALE,1
env = GDK_BACKEND,wayland,x11
env = QT_WAYLAND_DISABLE_WINDOWDECORATION,1
env = MOZ_ENABLE_WAYLAND,1
env = XDG_SESSION_DESKTOP,Hyprland
env = XDG_CURRENT_DESKTOP,Hyprland

#monitor=eDP-1,highrr,0x0,1.25
#monitor=eDP-2,highrr,0x0,1.25
#monitor=desc:AOC 24G2W1G4 0x0000297D,highrr,auto,1
#monitor=HDMI-A-1,highrr,2048x0,1
#monitor=HDMI-A-1,highrr,auto,1
#monitor=,preferred,auto,1
# TV frame
#monitor=HDMI-A-1,addreserved,50,50,50,50
#monitor=HDMI-A-1,preferred,auto,1,transform,2
#monitor=HDMI-A-1,preferred,auto,1,mirror,eDP-2

#workspace = 10,monitor:HDMI-A-1,default:true

xwayland {
    force_zero_scaling = true
}

# Source a file (multi-file configs)
# source = ~/.config/hypr/myColors.conf

# For all categories, see https://wiki.hyprland.org/Configuring/Variables/
input {
    kb_layout=us,cz
    kb_variant=,qwerty
    kb_model=
    kb_options=grp:win_space_toggle
    kb_rules=

    numlock_by_default=trues

    follow_mouse=1
    float_switch_override_focus=true

    touchpad {
        natural_scroll = yes
    }
    touchdevice {
        output = HDMI-A-1
        transform = 2
    }

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

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

    gaps_in = 5
    gaps_out = 10
    border_size = 1
    # col.active_border = rgba(75DDDD50) rgba(09BC8A50) 45deg
    # col.inactive_border = rgba(172A3AFF)

    layout = master
    resize_on_border = true
}

decoration {
    # See https://wiki.hyprland.org/Configuring/Variables/ for more

    rounding = 10
    
    blur {
        enabled = true
        size = 2
        passes = 4
        new_optimizations = on
        ignore_opacity = on
        # xray = true
    }

    # drop_shadow = yes
    # shadow_range = 4
    # shadow_render_power = 3
    # col.shadow = rgba(1a1a1aee)
}

animations {
    enabled = yes
    bezier = wind, 0.05, 0.9, 0.1, 1.05
    bezier = winIn, 0.1, 1, 0.1, 1
    bezier = winOut, 0.3, 0, 0, 1
    bezier = liner, 1, 1, 1, 1
    animation = windows, 1, 6, wind, slide
    animation = windowsIn, 1, 6, winIn, popin 80%
    animation = windowsOut, 1, 5, winOut, popin 80%
    animation = windowsMove, 1, 5, wind, slide
    animation = border, 1, 1, liner
    animation = borderangle, 1, 30, liner, loop
    animation = fade, 1, 10, default
    animation = workspaces, 1, 5, wind
}

group {
    groupbar {
#        font_size = 10
#        col.active = rgb(F7E733)
#        col.inactive = rgba(F7E73330)
    }
#    col.border_active = rgba(75DDDDFF) rgba(75DDDD70) 45deg
#    col.border_inactive = rgb(172A3A)
}

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
    #new_is_master = false
}

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

# Example per-device config
# See https://wiki.hyprland.org/Configuring/Keywords/#executing for more
#device:epic-mouse-v1 {
#    sensitivity = -0.5
#}

misc {
    disable_hyprland_logo=true
    disable_splash_rendering=true
    mouse_move_enables_dpms=true
}

windowrule=float,class:blueman
windowrule=float,class:Anydesk
windowrule=float,class:file_progress
windowrule=float,class:confirm
windowrule=float,class:dialog
windowrule=float,class:download
windowrule=float,class:notification
windowrule=float,class:error
windowrule=float,class:splash
windowrule=float,class:confirmreset
windowrule=float,title:Open File
windowrule=float,title:branchdialog
windowrule=tile,title:*vivaldi*

# can be more specific (:bar, :mediaControls, etc)
layerrule = blur, quickshell:bar
layerrule = ignorealpha .2, quickshell:bar
layerrule = blur, quickshell:overview
layerrule = blurpopups, quickshell:overview
layerrule = ignorealpha .2, quickshell:overview
layerrule = blur, quickshell:sidebarLeft
layerrule = blurpopups, quickshell:sidebarLeft
layerrule = ignorealpha .2, quickshell:sidebarLeft
layerrule = blur, quickshell:sidebarRight
layerrule = blurpopups, quickshell:sidebarRight
layerrule = ignorealpha .2, quickshell:sidebarRight

blurls=gtk-layer-shell
blurls=lockscreen
blurls = rofi

$dir =  ~/.config
#! quickshell
# bindr = SUPER, R, exec, pkill rofi || $dir/rofi/bin/launcher
bind = SUPER, r, global, quickshell:overviewSearchToggle
# bind = SUPER, P, exec, pkill rofi || $dir/rofi/bin/powermenu
bind = SUPER, p, global, quickshell:sessionToggle
bind = SUPER, m, global, quickshell:mediaControlsToggle
bind = SUPER, grave, global, quickshell:sidebarLeftToggle
bind = SUPER, b, global, quickshell:sidebarRightToggle
bind = SUPER, slash, global, quickshell:cheatsheetToggle
bind = SUPER, tab, global, quickshell:overviewToggle
bindrt = SUPER, SUPER_L, global, quickshell:workspaceNumber
bindd = Super, h, Clipboard history >> clipboard, global, quickshell:overviewClipboardToggle # Clipboard history >> clipboard
bindd = Super, Period, Emoji >> clipboard, global, quickshell:overviewEmojiToggle # Emoji >> clipboard

$mainMod = SUPER

#! programs
bind = $mainMod, T, exec, kitty
bind=$mainMod,K,exec,kitty
bind=SUPER,B,exec,vivaldi-stable
bind = super+ctrl, q, exit, 
bind = $mainMod, E, exec, dolphin
#! current window management
bind = $mainMod, Q, killactive,
# bind = $mainMod, V, togglefloating,
#bind = $mainMod, R, exec, rofi -show drun
#bind = $mainMod, P, pseudo, # dwindle
bind = $mainMod, J, togglesplit, # dwindle
bind = SUPER, G, togglegroup
bind=SUPER,V,togglefloating,
bind=SUPER,F,fullscreen,
bind=SUPER,A,swapactiveworkspaces,current +1

# bind = SUPER, grave, hyprexpo:expo, toggle

#! media keys
bindle=, XF86MonBrightnessUp, exec, xbacklight -inc 10
bindle=, XF86MonBrightnessDown, exec, xbacklight -dec 10

bindle=, XF86AudioRaiseVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ +5%;canberra-gtk-play -i audio-volume-change -d "volumeChange"
bindle=, XF86AudioLowerVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ -5%;canberra-gtk-play -i audio-volume-change -d "volumeChange"
bindl=, XF86AudioMute, exec, pactl set-sink-mute @DEFAULT_SINK@ toggle
bindl=, XF86AudioMicMute, exec, pactl set-source-mute @DEFAULT_SOURCE@ toggle

bindl=, XF86AudioPlay, exec, playerctl play-pause # the stupid key is called play , but it toggles 
bindl=, XF86AudioNext, exec, playerctl next 
bindl=, XF86AudioPrev, exec, playerctl previous

#! focus
bind = SUPER+ALT, left, movefocus, l
bind = SUPER+ALT, right, movefocus, r
bind = SUPER+ALT, up, movefocus, u
bind = SUPER+ALT, down, movefocus, d
bind = SUPER+SHIFT, left,changegroupactive,b
bind = SUPER+SHIFT,right,changegroupactive,f

#! workspaces
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, 1, workspace, 10
bind = $mainMod+ALT, 2, workspace, 11
bind = $mainMod+ALT, 3, workspace, 12
bind = $mainMod+ALT, 4, workspace, 13
bind = $mainMod+ALT, 5, workspace, 14
bind = $mainMod+ALT, 6, workspace, 15
bind = $mainMod+ALT, 7, workspace, 16
bind = $mainMod+ALT, 8, workspace, 17
bind = $mainMod+ALT, 9, workspace, 18
bind = $mainMod+ALT, 0, workspace, 19


bind = SUPER+CONTROL, right, workspace, +1
bind = SUPER+CONTROL, left, workspace, -1
bind = super+control+shift,left,movetoworkspace,-1
bind = super+control+shift,right,movetoworkspace,+1

#! window movement
bind = SUPER, right, movewindow, mon:+1
bind = SUPER, left, movewindow, mon:-1

bind = ALT, tab, cyclenext,
bind = ALT+SHIFT, tab, cyclenext, prev

#! screenshots
# bind = ,Print,exec,grim - | wl-copy
bind = ,Print,exec,hyprshot --clipboard-only --mode active --mode output
# bind = SUPER+SHIFT,S,exec,spectacle --copy-image --region --background # no gui
# bind = SUPER+SHIFT,S,exec,grim -g "$(slurp)" - | wl-copy
bind = SUPER+SHIFT,S,exec,hyprshot --freeze --clipboard-only --mode region
bind = SUPER, L,exec,$swaylock

#! move windows to workspaces
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

#! mouse bindings
bind = $mainMod, mouse_down, workspace, e+1
bind = $mainMod, mouse_up, workspace, e-1

bind = super alt, m, layoutmsg,swapwithmaster

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

#! global keybinds
bind = CTRL+ALT,1,pass,^(com\.obsproject\.Studio)$
bind = CTRL+ALT,2,pass,^(com\.obsproject\.Studio)$

windowrulev2=opacity 0.9,class:Code
windowrulev2=opacity 0.9,class:Spotify

windowrulev2=workspace 10,class:Code # Open Code on secondary monitor

windowrulev2 = float,class:^(qt5ct)$
windowrulev2 = float,class:^(nwg-look)$
windowrulev2 = float,class:^(org.kde.ark)$
windowrulev2 = float,class:^(Signal)$ #Signal-Gtk
windowrulev2 = float,class:^(com.github.rafostar.Clapper)$ #Clapper-Gtk
windowrulev2 = float,class:^(app.drey.Warp)$ #Warp-Gtk
windowrulev2 = float,class:^(net.davidotek.pupgui2)$ #ProtonUp-Qt
windowrulev2 = float,class:^(yad)$ #Protontricks-Gtk
windowrulev2 = float,class:^(eog)$ #Imageviewer-Gtk
windowrulev2 = float,class:^(io.gitlab.theevilskeleton.Upscaler)$ #Upscaler-Gtk
windowrulev2 = float,class:^(pavucontrol)$
windowrulev2 = float,class:^(blueman-manager)$
windowrulev2 = float,class:^(nm-applet)$
windowrulev2 = float,class:^(nm-connection-editor)$
windowrulev2 = float,class:^(org.kde.polkit-kde-authentication-agent-1)$
windowrulev2 = tile,class:dev.warp.Warp

# some themeing
exec = gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
exec = gsettings set org.gnome.desktop.interface font-antialiasing 'rgba'
exec = gsettings set org.gnome.desktop.interface font-hinting 'full'

decoration {
    dim_special = 0.3
    blur {
        special = true
    }
}


#windowrule = nofullscreenrequest,flameshot
windowrule = float,title:flameshot
windowrule = monitor 1,title:flameshot
windowrule = move 0 0,title:flameshot
windowrule = noanim,title:flameshot
