###################
### MY PROGRAMS ###
###################

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

# Set programs that you use
$terminal = kitty
$fileManager = kitty -e yazi
$editor = kitty micro
$menu = wofi --show=drun
$winswitch = hyprctl dispatch focuswindow address:"$(hyprctl -j clients | jq 'map("\(.workspace.id) ∴ \(.workspace.name) ┇ \(.title) ┇ \(.address)")' | sed "s/,$//; s/^\[//; s/^\]//; s/^[[:blank:]]*//; s/^\"//; s/\"$//" | grep -v "^$" | wofi -dO alphabetical | grep -o "0x.*$")"

####################
### KEYBINDINGSS ###
####################

# See https://wiki.hyprland.org/Configuring/Keywords/
$mainMod = SUPER # Sets "Windows" key as main modifier

$navleft = left
$navright = right
$navup = up
$navdown = down

$vimleft = h
$vimright = l
$vimup = k
$vimdown = j

# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
bind = $mainMod, T, exec, $terminal
bind = $mainMod, Z, exec, $terminal btop
bind = $mainMod, Q, killactive,
bind = $mainMod, M, exec, $editor
bind = $mainMod, F, exec, $fileManager
bind = $mainMod, V, togglefloating,
#bind = $mainMod, H, movecurrentworkspacetomonitor
bind = $mainMod, C, pseudo, # dwindle
bind = $mainMod, B, togglesplit, # dwindle
bind = $mainMod SHIFT, O, exec, hyprctl dispatch exit 1
#bind = $mainMod, A, exec, killall waybar ; waybar
bind = $mainMod, E, exec, eww reload
bind = $mainMod, N, exec, nextcloud
bind = $mainMod, I, exec,  env GTK_THEME=cyberqueer bash ~/Dotfiles/desktopenvs/hyprland/wofi/netman/wofi-network-manager.sh
bind = $mainMod, S, exec, [tag +mixer] kitty pulsemixer
bind = $mainMod, X, exec, wofi --show=run

# Move focus with mainMod + vim keys
bind = $mainMod, $vimleft, movefocus, l
bind = $mainMod, $vimright, movefocus, r
bind = $mainMod, $vimup, movefocus, u
bind = $mainMod, $vimdown, movefocus, d

#Move focus with mainMod + arrow keys
bind = $mainMod, $navleft, movefocus, l
bind = $mainMod, $navright, movefocus, r
bind = $mainMod, $navup, movefocus, u
bind = $mainMod, $navdown, 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

# 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

# Example special workspace (scratchpad)
bind = $mainMod, SPACE, togglespecialworkspace, magic
bind = $mainMod SHIFT, SPACE, movetoworkspace, special:magic



bind = $mainMod CTRL, $navup, togglespecialworkspace, magic
bind = $mainMod CTRL SHIFT, $navup, movetoworkspace, special:magic

bind = $mainMod CTRL SHIFT, $navdown, movetoworkspace, empty
bind = $mainMod CTRL, $navdown, movetoworkspacesilent, special:magic



bind = $mainMod CTRL, $vimup, togglespecialworkspace, magic
bind = $mainMod CTRL SHIFT, $vimup, movetoworkspace, special:magic

bind = $mainMod CTRL SHIFT, $vimdown, movetoworkspace, empty
bind = $mainMod CTRL, $vimdown, movetoworkspacesilent, special:magic



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

binde = $mainMod, XF86AudioLowerVolume, workspace, r-1
binde = $mainMod, XF86AudioRaiseVolume, workspace, r+1

bind = $mainMod SHIFT, XF86AudioLowerVolume, movetoworkspace, r-1
bind = $mainMod SHIFT, XF86AudioRaiseVolume, movetoworkspace, r+1

binde = $mainMod, XF86AudioMute, togglespecialworkspace, magic
binde = $mainMod SHIFT, XF86AudioMute, movetoworkspace, special:magic

bind = $mainMod, TAB, cyclenext
bind = $mainMod SHIFT, TAB, exec, $winswitch

bind = $mainMod ALT CTRL SHIFT, END, exit

bind = $mainMod CTRL, $navleft, workspace, r-1
bind = $mainMod CTRL, $navright, workspace, r+1

bind = $mainMod CTRL SHIFT, $navleft, movetoworkspace, r-1
bind = $mainMod CTRL SHIFT, $navright, movetoworkspace, r+1


bind = $mainMod CTRL, $vimleft, workspace, r-1
bind = $mainMod CTRL, $vimright, workspace, r+1

bind = $mainMod CTRL SHIFT, $vimleft, movetoworkspace, r-1
bind = $mainMod CTRL SHIFT, $vimright, movetoworkspace, r+1




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

# Move/rezie windows with Keyboard

#rofi keybind
bind = $mainMod, R, exec, wofi --show drun
bind = $mainMod, RETURN, exec, wofi --show drun
bind = $mainMod SHIFT, RETURN, exec, $winswitch
bind = CTRL SHIFT, R, exec, wofi --show drun

#window location edit mode source: https://www.reddit.com/r/hyprland/comments/14jehzj/comment/jpl5c8f/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

#bind = $mainMod, A, submap, fastedit
#submap = fastedit
bind = $mainMod ALT, $navright, resizeactive, 10 0
bind = $mainMod ALT, $navleft, resizeactive, -10 0
bind = $mainMod ALT, $navup, resizeactive, 0 -10
bind = $mainMod ALT, $navdown, resizeactive, 0 10

bind = $mainMod SHIFT, $navleft, movewindow, l
bind = $mainMod SHIFT, $navright, movewindow, r
bind = $mainMod SHIFT, $navup, movewindow, u
bind = $mainMod SHIFT, $navdown, movewindow, d

#vim key window nav
bind = $mainMod ALT, $vimright, resizeactive, 10 0
bind = $mainMod ALT, $vimleft, resizeactive, -10 0
bind = $mainMod ALT, $vimup, resizeactive, 0 -10
bind = $mainMod ALT, $vimdown, resizeactive, 0 10

bind = $mainMod SHIFT, $vimleft, movewindow, l
bind = $mainMod SHIFT, $vimright, movewindow, r
bind = $mainMod SHIFT, $vimup, movewindow, u
bind = $mainMod SHIFT, $vimdown, movewindow, d



#nwg-dock-hyprland

#nwg-dock-hyprland -mb 15 -r -p 

bind = $mainMod SHIFT, W, exec, killall nwg-dock-hyprland && nwg-dock-hyprland -ml 15 -r -p left
bind = $mainMod SHIFT, E, exec, killall nwg-dock-hyprland && nwg-dock-hyprland -mr 15 -r -p right
bind = $mainMod SHIFT, S, exec, killall nwg-dock-hyprland && nwg-dock-hyprland -mt 80 -r -p top
bind = $mainMod SHIFT, D, exec, killall nwg-dock-hyprland && nwg-dock-hyprland -mb 15 -r -p bottom

bindr = $mainMod, D, exec, nwg-dock-hyprland

#GROUPS

bind = $mainMod ALT, C, togglegroup, 
bind = $mainMod SHIFT, C, lockactivegroup, toggle

bind = $mainMod SHIFT ALT, $navleft, movewindoworgroup, l
bind = $mainMod SHIFT ALT, $navright, movewindoworgroup, r
bind = $mainMod SHIFT ALT, $navup, movewindoworgroup, u
bind = $mainMod SHIFT ALT, $navdown, movewindoworgroup, d

bind = $mainMod SHIFT ALT, $vimleft, movewindoworgroup, l
bind = $mainMod SHIFT ALT, $vimright, movewindoworgroup, r
bind = $mainMod SHIFT ALT, $vimup, movewindoworgroup, u
bind = $mainMod SHIFT ALT, $vimdown, movewindoworgroup, d

bind = $mainMod, A, changegroupactive, f
bind = $mainMod, Y, changegroupactive, b

#bind = , escape, submap, reset
#submap = reset

bind = $mainMod SHIFT, Q, exec, hyprctl kill

#screenshot capture
bind = , Print, exec, grim -g "$(slurp -d)" - | wl-copy
bind = $mainMod, P, exec, grim -g "$(slurp -d)" - | wl-copy

#audio controls
binde =, XF86AudioRaiseVolume, exec, wpctl set-volume -l 1.4 @DEFAULT_AUDIO_SINK@ 5%+

binde =, XF86AudioLowerVolume, exec, wpctl set-volume -l 1.4 @DEFAULT_AUDIO_SINK@ 5%-

bind =, XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle 

bind =, XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle 

bindle=, XF86MonBrightnessUp, exec, bri --up
bindle=, XF86MonBrightnessDown, exec, bri --down

bindl=, XF86AudioPlay, exec, playerctl play-pause -p spotify, vlc
