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

$mainMod = SUPER

$terminal = alacritty
$fileManager = nautilus
$menu = rofi -show combi -combi-modes "window,run,ssh" -modes combi
$emojiMenu = rofi -modi emoji -show emoji

bind = $mainMod, R, exec, ~/.config/hypr/scripts/run-eww.sh

bind = $mainMod, E, exec, $fileManager                   # E - file manager
bind = $mainMod, F, fullscreen                           # F - fullscreen
bind = $mainMod, D, togglesplit,                         # D - toggle split
bind = $mainMod, M, exit                                 # M - exit
bind = $mainMod, Q, killactive                           # Q - kill active window
bind = alt, Q, killactive                                # alt + Q - kill active window
bind = $mainMod, S, swapactiveworkspaces, 0 1            # S - swap monitor workspaces
bind = $mainMod, T, exec, $terminal                      # T - terminal
bind = $mainMod, V, togglefloating                       # V - toggle floatin

bind = $mainMod shift, L, exec, hyprlock                 # super + {shift + L - lock screen

bind = $mainMod, F1, exec, ~/.config/hypr/scripts/game-mode.sh   # F1 - game mode
bind = $mainMod, F2, exec, eww open --toggle monitor-bump        # F2 - monitor bump

# rudimentary Alt+Tab and Alt+Shift+Tab
bind = alt, tab, cyclenext
bind = alt shift, tab, cyclenext, prev

# rcmd emulation
$rcmd = SUPER ALT
bind = $rcmd, f, focuswindow, firefox
bind = $rcmd, c, focuswindow, class:Code
bind = $rcmd, a, focuswindow, class:Alacritty
bind = $rcmd, t, focuswindow, telegram
bind = $rcmd, d, focuswindow, class:Todoist

bind = alt, space,         exec, $menu        # alt+space - rofi a la spotlight
bind = alt super shift, e, exec, $emojiMenu   # alt+super+shift+e - emoji menu
bind = $mainMod, code:49, focuscurrentorlast

bind = ctrl shift super, N, exec, swaync-client --toggle-panel   # N - toggle swaync panel

# eww
bind = ctrl shift super, Q, exec, eww open --toggle power-menu
bind = ctrl shift super, M, exec, eww open --toggle media-menu
bind = ctrl shift super, R, exec, ~/.config/hypr/scripts/run-apps.sh
bind = ctrl shift super, W, exec, ~/Scripts/wallpaper   # change wallpapers

# screenshots
# TODO: consider switching away to different shortcuts
bind = alt shift,      3, exec, ~/.config/hypr/scripts/screenshots/capture-screen.sh
bind = ctrl alt shift, 3, exec, ~/.config/hypr/scripts/screenshots/copy-screen.sh
bind = alt shift,      4, exec, ~/.config/hypr/scripts/screenshots/capture-area.sh
bind = ctrl alt shift, 4, exec, ~/.config/hypr/scripts/screenshots/copy-area.sh


### Window Management

# Move focus with mainMod + hjkl
bind = $mainMod, h, movefocus, l
bind = $mainMod, l, movefocus, r
bind = $mainMod, k, movefocus, u
bind = $mainMod, j, movefocus, d

# move to prev / next monitor
bind = ctrl alt super, left,  movewindow, mon:+1
bind = ctrl alt super, right, movewindow, mon:-1

# resize with ctrl super shift hjkl
bind = $mainMod ctrl shift, L, resizeactive, 30 0
bind = $mainMod ctrl shift, H, resizeactive, -30 0
bind = $mainMod ctrl shift, K, resizeactive, 0 30
bind = $mainMod ctrl shift, J, resizeactive, 0 -30

# move with ctrl super hjkl
bind = ctrl super, H, movewindow, l
bind = ctrl super, L, movewindow, r
bind = ctrl super, K, movewindow, u
bind = ctrl super, J, movewindow, 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

# TODO: disabled due to incompatibility with screenshots
# Move active window to a workspace with ctrl + shift + alt + [0-9]
# bind = ctrl shift alt, 1, movetoworkspace, 1
# bind = ctrl shift alt, 2, movetoworkspace, 2
# bind = ctrl shift alt, 3, movetoworkspace, 3
# bind = ctrl shift alt, 4, movetoworkspace, 4
# bind = ctrl shift alt, 5, movetoworkspace, 5
# bind = ctrl shift alt, 6, movetoworkspace, 6
# bind = ctrl shift alt, 7, movetoworkspace, 7
# bind = ctrl shift alt, 8, movetoworkspace, 8
# bind = ctrl shift alt, 9, movetoworkspace, 9
# bind = ctrl shift alt, 0, movetoworkspace, 10

# go to next/prev workspace with ctrl alt hj
bind = ctrl alt, H, workspace, -1
bind = ctrl alt, L, workspace, +1

# move to next/prev workspace with ctrl alt shift hj
bind = ctrl alt shift, H, movetoworkspace, -1
bind = ctrl alt shift, L, movetoworkspace, +1

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

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

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