#          ╭──────────────────────────────────────────────────────────╮
#          │                       Keybindings                        │
#          │                          by gh                           │
#          ╰──────────────────────────────────────────────────────────╯

#          ╭──────────────────────────────────────────────────────────╮
#          │                         general                          │
#          ╰──────────────────────────────────────────────────────────╯
# See https://wiki.hyprland.org/Configuring/Keywords/
$mainMod = SUPER # Sets "Windows" key as main modifier

# apps
bind = $mainMod, T, exec, $terminal # terminal
bind = $mainMod SHIFT, T, exec, ~/.config/hypr/scripts/show-crow.sh
bind = $mainMod CTRL SHIFT, T, exec, ~/.config/hypr/scripts/translate-selection.sh
bind = $mainMod, E, exec, $fileManager # file manager
bind = $mainMod, A, exec, $toggle_menu_cmd # wofi
bind = $mainMod CTRL ALT, V, exec, ~/.config/hypr/scripts/dnd-clipboard.sh

#   ──────────────────────────────── copyq ──────────────────────────────
bind = CTRL_ALT, V, exec, copyq toggle

bind = $mainMod, F, fullscreen # fullscreen
bind = $mainMod, Q, killactive, # kill window
bind = $mainMod, V, togglefloating, # toggle float
bind = $mainMod, P, pseudo, # pseudo
bind = $mainMod, DELETE, exit, # pseudo
bind = $mainMod, R, togglesplit, # toggle split
bind = $mainMod CTRL, L, exec, hyprlock # lock screen

#   ─────────────────────────── move workspaces ─────────────────────────
bind = CTRL ALT $mainMod SHIFT CTRL ALT, H, movecurrentworkspacetomonitor, l
bind = CTRL ALT $mainMod SHIFT CTRL ALT, L, movecurrentworkspacetomonitor, r 
bind = CTRL ALT $mainMod SHIFT CTRL ALT, J, movecurrentworkspacetomonitor, d
bind = CTRL ALT $mainMod SHIFT CTRL ALT, K, movecurrentworkspacetomonitor, u 

#   ────────────────────────── window move focus ────────────────────────
binde = $mainMod, right, resizeactive, 20 0
binde = $mainMod, left, resizeactive, -20 0
binde = $mainMod, up, resizeactive, 0 -20
binde = $mainMod, down, resizeactive, 0 20
bind = $mainMod, H, movefocus, l
bind = $mainMod, L, movefocus, r
bind = $mainMod, K, movefocus, u
bind = $mainMod, J, movefocus, d

#   ────────────────────────── switch 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
binde = $mainMod SHIFT, H, workspace, -1 
binde = $mainMod SHIFT, L, workspace, +1 
binde = $mainMod SHIFT, J, workspace, previous 

#   ─────────────────────── move window to workspace ───────────────────────
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 CTRL SHIFT, H, movetoworkspace, -1 
bind = $mainMod CTRL SHIFT, L, movetoworkspace, +1 
bind = $mainMod CTRL SHIFT, J, movetoworkspace, previous 

#   ───────────────────────── workspace/scratchpad ─────────────────────────
bind = , F12, togglespecialworkspace, magic
bind = SHIFT, F12, movetoworkspace, special:magic
bind = $mainMod, M, togglespecialworkspace, music

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


#   ───────────────────────────── screenshots ───────────────────────────
bind = $mainMod SHIFT, S, exec, grimblast copy area --freeze --notify --cursor
bind = , Print, exec, grimblast copy active --freeze --notify --cursor
bind = SHIFT, Print, exec, grimblast copy screen --freeze --notify --cursor

#          ╭──────────────────────────────────────────────────────────╮
#          │                        mediakeys                         │
#          ╰──────────────────────────────────────────────────────────╯

# l -> do stuff even when locked
# e -> repeats when key is held 
bindle=, XF86AudioRaiseVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ +5% & echo $(pactl get-sink-volume @DEFAULT_SINK@ | grep -oP "\d{1,3}(?=%)" | head -1) >> /tmp/wobpipe
bindle=, XF86AudioLowerVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ -5% & echo $(pactl get-sink-volume @DEFAULT_SINK@ | grep -oP "\d{1,3}(?=%)" | head -1) >> /tmp/wobpipe
bindle=, XF86MonBrightnessUp, exec, ~/.config/scripts/set_brightness.sh +10%
bindle=, XF86MonBrightnessDown, exec, ~/.config/scripts/set_brightness.sh 10%-
bindl=, XF86AudioMute, exec, amixer set Master toggle
bindl=, XF86AudioPlay, exec, playerctl --player=$(cat ~/.config/chosen_player) play-pause 
bindl=, XF86AudioPause, exec, playerctl --player=$(cat ~/.config/chosen_player) play-pause 
bindl=, XF86AudioStop, exec, playerctl --player=$(cat ~/.config/chosen_player) play-pause 
bindl=, XF86AudioNext, exec, playerctl --player=$(cat ~/.config/chosen_player) next 
bindl=, XF86AudioPrev, exec, playerctl --player=$(cat ~/.config/chosen_player) previous
bindl= CTRL ALT SHIFT, H, exec, playerctl --player=$(cat ~/.config/chosen_player) previous 
bindl= CTRL ALT SHIFT, L, exec, playerctl --player=$(cat ~/.config/chosen_player) next
bindl= CTRL ALT SHIFT, SPACE, exec, playerctl --player=$(cat ~/.config/chosen_player) play-pause

#   ─────────────────────── select pulseaudio output ───────────────────────
bind= CTRL ALT SHIFT, O, exec, ~/.config/hypr/scripts/wofi-pulse-output.sh

#   ─────────────────────── select playerctl player ─────────────────────
bind= CTRL ALT SHIFT, P, exec, ~/.config/hypr/scripts/wofi-player.sh

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



