# -----------------------------------------------------
# Key bindings
# name: "Default"
# -----------------------------------------------------

# SUPER KEY
$mainMod = SUPER
$HYPRSCRIPTS = ~/.config/hypr/scripts
$SCRIPTS = ~/.config/ml4w/scripts

# Applications
bind = $mainMod, RETURN, exec, ~/.config/ml4w/settings/terminal.sh    # Open the terminal
bind = $mainMod, B, exec, ~/.config/ml4w/settings/browser.sh          # Open the browser
bind = $mainMod, E, exec, ~/.config/ml4w/settings/filemanager.sh      # Open the filemanager
bind = $mainMod CTRL, E, exec, ~/.config/ml4w/settings/emojipicker.sh # Open the emoji picker
bind = $mainMod CTRL, C, exec, ~/.config/ml4w/settings/calculator.sh  # Open the calculator

# Display
bind = $mainMod SHIFT, mouse_down, exec, hyprctl keyword cursor:zoom_factor $(awk "BEGIN {print $(hyprctl getoption cursor:zoom_factor | grep 'float:' | awk '{print $2}') + 0.5}") # Increase display zoom
bind = $mainMod SHIFT, mouse_up, exec, hyprctl keyword cursor:zoom_factor $(awk "BEGIN {print $(hyprctl getoption cursor:zoom_factor | grep 'float:' | awk '{print $2}') - 0.5}") # Decrease display zoom
bind = $mainMod SHIFT, Z, exec, hyprctl keyword cursor:zoom_factor 1 # Reset display zoom

# Windows
bind = $mainMod, Q, killactive                                                              # Kill active window
bind = $mainMod SHIFT, Q, exec, hyprctl activewindow | grep pid | tr -d 'pid:' | xargs kill # Quit active window and all open instances
bind = $mainMod, F, fullscreen, 0                                                              # Set active window to fullscreen
bind = $mainMod, M, fullscreen, 1                                                           # Maximize Window
bind = $mainMod, T, togglefloating                                                          # Toggle active windows into floating mode
bind = $mainMod SHIFT, T, workspaceopt, allfloat                                            # Toggle all windows into floating mode
bind = $mainMod, J, togglesplit                                                             # Toggle split
bind = $mainMod, left, movefocus, l                                                         # Move focus left
bind = $mainMod, right, movefocus, r                                                        # Move focus right
bind = $mainMod, up, movefocus, u                                                           # Move focus up
bind = $mainMod, down, movefocus, d                                                         # Move focus down
bindm = $mainMod, mouse:272, movewindow                                                     # Move window with the mouse
bindm = $mainMod, mouse:273, resizewindow                                                   # Resize window with the mouse
bind = $mainMod SHIFT, right, resizeactive, 100 0                                           # Increase window width with keyboard
bind = $mainMod SHIFT, left, resizeactive, -100 0                                           # Reduce window width with keyboard
bind = $mainMod SHIFT, down, resizeactive, 0 100                                            # Increase window height with keyboard
bind = $mainMod SHIFT, up, resizeactive, 0 -100                                             # Reduce window height with keyboard
bind = $mainMod, G, togglegroup                                                             # Toggle window group
bind = $mainMod, K, swapsplit                                                               # Swapsplit
bind = $mainMod ALT, left, swapwindow, l                                                    # Swap tiled window left
bind = $mainMod ALT, right, swapwindow, r                                                   # Swap tiled window right
bind = $mainMod ALT, up, swapwindow, u                                                      # Swap tiled window up
bind = $mainMod ALT, down, swapwindow, d                                                    # Swap tiled window down
binde = ALT,Tab,cyclenext                                                                   # Cycle between windows
binde = ALT,Tab,bringactivetotop                                                            # Bring active window to the top

# Actions
bind = $mainMod CTRL, R, exec, hyprctl reload                                             # Reload Hyprland configuration
bind = $mainMod SHIFT, A, exec, $HYPRSCRIPTS/toggle-animations.sh                         # Toggle animations
bind = $mainMod, PRINT, exec, $HYPRSCRIPTS/screenshot.sh                                  # Take a screenshot
bind = $mainMod SHIFT, S, exec, $HYPRSCRIPTS/screenshot.sh                                # Take a screenshot
bind = $mainMod CTRL, Q, exec, ~/.config/ml4w/scripts/wlogout.sh                          # Start wlogout
bind = $mainMod SHIFT, W, exec, waypaper --random                                         # Change the wallpaper
bind = $mainMod CTRL, W, exec, waypaper                                                   # Open wallpaper selector
bind = $mainMod ALT, W, exec, $HYPRSCRIPTS/wallpaper-automation.sh                        # Start random wallpaper script
bind = $mainMod CTRL, RETURN, exec, ~/.config/hypr/scripts/launcher.sh                    # Open application launcher
bind = $mainMod CTRL, K, exec, $HYPRSCRIPTS/keybindings.sh                                # Show keybindings
bind = $mainMod SHIFT, B, exec, ~/.config/waybar/launch.sh                                # Reload waybar
bind = $mainMod CTRL, B, exec, ~/.config/waybar/toggle.sh                                 # Toggle waybar
bind = $mainMod SHIFT, R, exec, $HYPRSCRIPTS/loadconfig.sh                                # Reload hyprland config
bind = $mainMod, V, exec, $SCRIPTS/cliphist.sh                                            # Open clipboard manager
bind = $mainMod CTRL, T, exec, ~/.config/waybar/themeswitcher.sh                          # Open waybar theme switcher
bind = $mainMod CTRL, S, exec, flatpak run com.ml4w.settings                              # Open ML4W Dotfiles Settings app
bind = $mainMod ALT, G, exec, $HYPRSCRIPTS/gamemode.sh                                    # Toggle game mode
bind = $mainMod CTRL, L, exec, ~/.config/hypr/scripts/power.sh lock                       # Start wlogout
bind = $mainMod SHIFT, H, exec, $HYPRSCRIPTS/hyprshade.sh                                 # Launch Hyprshade
bind = CTRL, Tab, exec, ~/.config/ml4w/scripts/focus.sh                                   # Open Select Window Menu

# Sidepad
bind = $mainMod CTRL, right, exec, ~/.config/ml4w/scripts/sidepad.sh                      # Open Sidepad
bind = $mainMod CTRL, left, exec, ~/.config/ml4w/scripts/sidepad.sh --hide                # Close Sidepad
bind = $mainMod, S, exec, ~/.config/ml4w/scripts/sidepad.sh --init                        # Init Sidepad
bind = $mainMod SHIFT, S, exec, ~/.config/ml4w/scripts/sidepad.sh --select                # Select Sidepad

# Workspaces
bind = $mainMod, ampersand, workspace, 1  # Open workspace 1
bind = $mainMod, eacute, workspace, 2     # Open workspace 2
bind = $mainMod, quotedbl, workspace, 3   # Open workspace 3
bind = $mainMod, apostrophe, workspace, 4 # Open workspace 4
bind = $mainMod, parenleft, workspace, 5  # Open workspace 5
bind = $mainMod, minus, workspace, 6      # Open workspace 6
bind = $mainMod, egrave, workspace, 7     # Open workspace 7
bind = $mainMod, underscore, workspace, 8 # Open workspace 8
bind = $mainMod, ccedilla, workspace, 9   # Open workspace 9
bind = $mainMod, agrave, workspace, 10    # Open workspace 10

bind = $mainMod SHIFT, ampersand, movetoworkspace, 1  # Move active window to workspace 1
bind = $mainMod SHIFT, eacute, movetoworkspace, 2     # Move active window to workspace 2
bind = $mainMod SHIFT, quotedbl, movetoworkspace, 3   # Move active window to workspace 3
bind = $mainMod SHIFT, apostrophe, movetoworkspace, 4 # Move active window to workspace 4
bind = $mainMod SHIFT, parenleft, movetoworkspace, 5  # Move active window to workspace 5
bind = $mainMod SHIFT, minus, movetoworkspace, 6      # Move active window to workspace 6
bind = $mainMod SHIFT, egrave, movetoworkspace, 7     # Move active window to workspace 7
bind = $mainMod SHIFT, underscore, movetoworkspace, 8 # Move active window to workspace 8
bind = $mainMod SHIFT, ccedilla, movetoworkspace, 9   # Move active window to workspace 9
bind = $mainMod SHIFT, agrave, movetoworkspace, 10    # Move active window to workspace 10

bind = $mainMod, Tab, workspace, m+1       # Open next workspace
bind = $mainMod SHIFT, Tab, workspace, m-1 # Open previous workspace

bind = $mainMod CTRL, ampersand, exec, $HYPRSCRIPTS/moveTo.sh 1  # Move all windows to workspace 1
bind = $mainMod CTRL, eacute, exec, $HYPRSCRIPTS/moveTo.sh 2     # Move all windows to workspace 2
bind = $mainMod CTRL, quotedbl, exec, $HYPRSCRIPTS/moveTo.sh 3   # Move all windows to workspace 3
bind = $mainMod CTRL, apostrophe, exec, $HYPRSCRIPTS/moveTo.sh 4 # Move all windows to workspace 4
bind = $mainMod CTRL, parenleft, exec, $HYPRSCRIPTS/moveTo.sh 5  # Move all windows to workspace 5
bind = $mainMod CTRL, minus, exec, $HYPRSCRIPTS/moveTo.sh 6      # Move all windows to workspace 6
bind = $mainMod CTRL, egrave, exec, $HYPRSCRIPTS/moveTo.sh 7     # Move all windows to workspace 7
bind = $mainMod CTRL, underscore, exec, $HYPRSCRIPTS/moveTo.sh 8 # Move all windows to workspace 8
bind = $mainMod CTRL, ccedilla, exec, $HYPRSCRIPTS/moveTo.sh 9   # Move all windows to workspace 9
bind = $mainMod CTRL, agrave, exec, $HYPRSCRIPTS/moveTo.sh 10    # Move all windows to workspace 10

bind = $mainMod, mouse_down, workspace, e+1  # Open next workspace
bind = $mainMod, mouse_up, workspace, e-1    # Open previous workspace
bind = $mainMod CTRL, down, workspace, empty # Open the next empty workspace

# Fn keys
bind = , XF86MonBrightnessUp, exec, brightnessctl -q s +10%                                                                 # Increase brightness by 10%
bind = , XF86MonBrightnessDown, exec, brightnessctl -q s 10%-                                                               # Reduce brightness by 10%
bind = , XF86AudioRaiseVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ +5%                                               # Increase volume by 5%
bind = , XF86AudioLowerVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ -5%                                               # Reduce volume by 5%
bind = , XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle                                                    # Toggle mute
bind = , XF86AudioPlay, exec, playerctl play-pause                                                                          # Audio play pause
bind = , XF86AudioPause, exec, playerctl pause                                                                              # Audio pause
bind = , XF86AudioNext, exec, playerctl next                                                                                # Audio next
bind = , XF86AudioPrev, exec, playerctl previous                                                                            # Audio previous
bind = , XF86AudioMicMute, exec, pactl set-source-mute @DEFAULT_SOURCE@ toggle                                              # Toggle microphone
bind = , XF86Calculator, exec, ~/.config/ml4w/settings/calculator.sh                                                        # Open calculator
bind = , XF86Lock, exec, hyprlock                                                                                           # Open screenlock
bind = , XF86Tools, exec, alacritty --class dotfiles-floating -e ~/.config/ml4w/apps/ML4W_Dotfiles_Settings-x86_64.AppImage # Open ML4W Dotfiles Settings app

bind = , code:238, exec, brightnessctl -d smc::kbd_backlight s +10
bind = , code:237, exec, brightnessctl -d smc::kbd_backlight s 10-
