diff --git a/bin/omarchy-show-keybindings b/bin/omarchy-show-keybindings index 6124355..abd9b0b 100755 --- a/bin/omarchy-show-keybindings +++ b/bin/omarchy-show-keybindings @@ -1,59 +1,64 @@ #!/bin/bash -# A script to display Hyprland keybindings defined in your configuration -# using wofi for an interactive search menu. +# Define modifier flags as associative array for name lookup +# per https://github.com/hyprwm/Hyprland/blob/main/src/devices/IKeyboard.hpp#L13-L22 +declare -A MODIFIER_NAMES=( + [$((1 << 0))]="SHIFT" + [$((1 << 1))]="CAPS" + [$((1 << 2))]="CTRL" + [$((1 << 3))]="ALT" + [$((1 << 4))]="MOD2" + [$((1 << 5))]="MOD3" + [$((1 << 6))]="SUPER" + [$((1 << 7))]="MOD5" +) -USER_HYPRLAND_CONF="$HOME/.config/hypr/hyprland.conf" -OMARCHY_BINDINGS_CONF="$HOME/.local/share/omarchy/default/hypr/bindings.conf $HOME/.local/share/omarchy/default/hypr/bindings/tiling.conf $HOME/.local/share/omarchy/default/hypr/bindings/utilities.conf $HOME/.local/share/omarchy/default/hypr/bindings.conf $HOME/.local/share/omarchy/default/hypr/media.conf" +decode_modmask() { + local modifiers=$1 + local result=() -OMARCHY_BINDINGS_CONF="$HOME/.local/share/omarchy/default/hypr/bindings.conf \ -$HOME/.local/share/omarchy/default/hypr/bindings/tiling.conf \ -$HOME/.local/share/omarchy/default/hypr/bindings/utilities.conf \ -$HOME/.local/share/omarchy/default/hypr/media.conf" + for bit in "${!MODIFIER_NAMES[@]}"; do + if (( modifiers & bit )); then + result+=("${MODIFIER_NAMES[$bit]}") + fi + done -# Process the configuration file to extract and format keybindings -# 1. `grep` finds all lines starting with 'bind' (allowing for leading spaces). -# 2. The first `sed` removes comments (anything after a '#'). -# 3. `awk` does the heavy lifting of formatting the output. -# - It sets the field separator to a comma ','. -# - It removes the 'bind... =' part from the beginning of the line. -# - It joins the key combination (e.g., "SUPER + Q"). -# - It joins the command that the key executes. -# - It prints everything in a nicely aligned format. -# 4. The final `sed` cleans up any leftover commas from the end of lines. -grep -h '^[[:space:]]*bind' $USER_HYPRLAND_CONF $OMARCHY_BINDINGS_CONF | - sed 's/#.*//' | - sed '/^[[:space:]]*$/d' | - sort -u | - awk -F, ' -{ - # Strip trailing comments - sub(/#.*/, ""); + # Output all detected modifiers (plus-separated) + echo "${result[*]}" +} - # Remove the "bind... =" part and surrounding whitespace - sub(/^[[:space:]]*bind[^=]*=(\+[[:space:]])?(exec, )?[[:space:]]*/, "", $1); +# Read live keybinds, not config file +OLD_IFS=$IFS +IFS=$'\n' +readarray -t KEYBINDS < <(hyprctl -j binds | jq -cr '.[]') +IFS=$OLD_IFS - # Combine the modifier and key (first two fields) - key_combo = $1 " + " $2; +# Loop over each keybind and pipe results to wofi for inspection/execution +# Format to send to wofi: +# +# -- # - +# exec -- alacritty #SUPER return - Launch a Terminal +# or +# exit -- #SUPER+ALT ESCAPE - Logout +# +# Wofi's pre-display-cmd looks for the '#' and prints everything after it +# in the wofi window. When we pipe that to `xargs hyprctl dispatch`, the +# Comment character ensures we ignore the description text and only executes +# the dispatcher + arg. +for keyconfig in "${KEYBINDS[@]}"; do + # Use pipe '|' to delimit results + IFS="|" read modmask key keycode description dispatcher arg < <(echo $(echo "$keyconfig" | jq -r '[.modmask, .key, .keycode, .description, .dispatcher, .arg] | join("|")')) + keys=($(decode_modmask $modmask) $key) + IFS=$OLD_IFS - # Clean up: strip leading "+" if present, trim spaces - gsub(/^[ \t]*\+?[ \t]*/, "", key_combo); - gsub(/[ \t]+$/, "", key_combo); + # We can't use IFS here, as it only supports single characters + delimiter=" + " - # Reconstruct the command from the remaining fields - action = ""; - for (i = 3; i <= NF; i++) { - action = action $i (i < NF ? "," : ""); - } + # Join the array elements with the delimiter + combo=$(printf "%s$delimiter" "${keys[@]}") - # Clean up trailing commas, remove leading "exec, ", and trim - sub(/,$/, "", action); - gsub(/(^|,)[[:space:]]*exec[[:space:]]*,?/, "", action); - gsub(/^[ \t]+|[ \t]+$/, "", action); - gsub(/[ \t]+/, " ", key_combo); # Collapse multiple spaces to one + # Remove the trailing delimiter + combo="${combo%$delimiter}" - if (action != "") { - printf "%-35s → %s\n", key_combo, action; - } -}' | - flock --nonblock /tmp/.wofi.lock -c "wofi -dmenu -i --width 60% --height 70% -p 'Hyprland Keybindings' -O alphabetical --style=\"$HOME/.local/share/omarchy/default/wofi/search.css\"" + printf "%s -- %s #%-30s → %s\n" "$dispatcher" "$arg" "$combo" "$description" +done | flock --nonblock /tmp/.wofi.lock -c "wofi --cache-file /dev/null --width 40% --height 70% -d -i -p 'Hyprland Keybindings' --style=\"$HOME/.local/share/omarchy/default/wofi/search.css\" -m --pre-display-cmd \"echo '%s' | cut -d'#' -f2 | tr -d '\n'\" | xargs hyprctl dispatch" diff --git a/bin/omarchy-toggle-dnd b/bin/omarchy-toggle-dnd new file mode 100644 index 0000000..6c52b51 --- /dev/null +++ b/bin/omarchy-toggle-dnd @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +makoctl mode -t do-not-disturb > /dev/null + +makoctl mode | grep -q 'do-not-disturb' \ + && notify-send "Silenced notifications" \ + || notify-send "Enabled notifications" diff --git a/default/hypr/bindings.conf b/default/hypr/bindings.conf index 15bfb20..835421d 100644 --- a/default/hypr/bindings.conf +++ b/default/hypr/bindings.conf @@ -1,16 +1,8 @@ # Deprecated bindings file. New installations include everything directly. +# Order matters for how they show up when you press SUPER + K to see the +# defined keybinds -bind = SUPER, return, exec, $terminal -bind = SUPER, F, exec, $fileManager -bind = SUPER, B, exec, $browser -bind = SUPER, M, exec, $music -bind = SUPER, N, exec, $terminal -e nvim -bind = SUPER, T, exec, $terminal -e btop -bind = SUPER, D, exec, $terminal -e lazydocker -bind = SUPER, G, exec, $messenger -bind = SUPER, O, exec, obsidian -disable-gpu -bind = SUPER, slash, exec, $passwordManager - +source = ~/.local/share/omarchy/default/hypr/bindings/01-important.conf source = ~/.local/share/omarchy/default/hypr/bindings/media.conf source = ~/.local/share/omarchy/default/hypr/bindings/tiling.conf source = ~/.local/share/omarchy/default/hypr/bindings/utilities.conf diff --git a/default/hypr/bindings/01-important.conf b/default/hypr/bindings/01-important.conf new file mode 100644 index 0000000..1ed2ec9 --- /dev/null +++ b/default/hypr/bindings/01-important.conf @@ -0,0 +1,14 @@ +# Launching +bindd = SUPER, space, Application Launcher, exec, pkill wofi || wofi --show drun --sort-order=alphabetical --style="$HOME/.local/share/omarchy/default/wofi/search.css" +bindd = SUPER, K, Show Keybindings, exec, ~/.local/share/omarchy/bin/omarchy-show-keybindings + +bindd = SUPER, return, Launch a Terminal, exec, $terminal +bindd = SUPER, F, Launch a File Manager, exec, $fileManager +bindd = SUPER, B, Launch a Browser, exec, $browser +bindd = SUPER, M, Launch a Music Player, exec, $music +bindd = SUPER, N, Launch nvim, exec, $terminal -e nvim +bindd = SUPER, T, Launch btop, exec, $terminal -e btop +bindd = SUPER, D, Launch lazydocker, exec, $terminal -e lazydocker +bindd = SUPER, G, Launch a Messenger App, exec, $messenger +bindd = SUPER, O, Launch Obsidian, exec, obsidian -disable-gpu +bindd = SUPER, slash, Launch a Password Manager, exec, $passwordManager diff --git a/default/hypr/bindings/media.conf b/default/hypr/bindings/media.conf index a70d8d6..aadcc3b 100644 --- a/default/hypr/bindings/media.conf +++ b/default/hypr/bindings/media.conf @@ -1,13 +1,13 @@ -# Laptop multimedia keys for volume and LCD brightness -bindel = ,XF86AudioRaiseVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+ -bindel = ,XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- -bindel = ,XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle -bindel = ,XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle -bindel = ,XF86MonBrightnessUp, exec, brightnessctl -e4 -n2 set 5%+ -bindel = ,XF86MonBrightnessDown, exec, brightnessctl -e4 -n2 set 5%- +# Laptop multimedia keys for volume, media control, and LCD brightness +bindeld = ,XF86AudioRaiseVolume, Raise Volume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+ +bindeld = ,XF86AudioLowerVolume, Lower Volume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- +bindeld = ,XF86AudioMute, Mute Speakers, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle +bindeld = ,XF86AudioMicMute, Mute Mic, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle +bindeld = ,XF86MonBrightnessUp, Raise Brightness, exec, brightnessctl -e4 -n2 set 5%+ +bindeld = ,XF86MonBrightnessDown, Lower Brightness, exec, brightnessctl -e4 -n2 set 5%- # Requires playerctl -bindl = , XF86AudioNext, exec, playerctl next -bindl = , XF86AudioPause, exec, playerctl play-pause -bindl = , XF86AudioPlay, exec, playerctl play-pause -bindl = , XF86AudioPrev, exec, playerctl previous +bindld = , XF86AudioNext, Next Track, exec, playerctl next +bindld = , XF86AudioPause, Pause Media, exec, playerctl play-pause +bindld = , XF86AudioPlay, Pause Media, exec, playerctl play-pause +bindld = , XF86AudioPrev, Previous Track, exec, playerctl previous diff --git a/default/hypr/bindings/tiling.conf b/default/hypr/bindings/tiling.conf index 6dcc37a..0a55195 100644 --- a/default/hypr/bindings/tiling.conf +++ b/default/hypr/bindings/tiling.conf @@ -1,58 +1,58 @@ # Close window -bind = SUPER, W, killactive, +bindd = SUPER, W, Close Window, killactive, # Control tiling -bind = SUPER, J, togglesplit, # dwindle -bind = SUPER, P, pseudo, # dwindle -bind = SUPER, V, togglefloating, +bindd = SUPER, J, Toggle Split, togglesplit, # dwindle +bindd = SUPER, P, Toggle Pseudo, pseudo # dwindle +bindd = SUPER, V, Toggle Floating, togglefloating, +bindd = SUPER CTRL, F, Toggle Fullscreen, fullscreen # Move focus with mainMod + arrow keys -bind = SUPER, left, movefocus, l -bind = SUPER, right, movefocus, r -bind = SUPER, up, movefocus, u -bind = SUPER, down, movefocus, d +bindd = SUPER, left, Move Focus Left, movefocus, l +bindd = SUPER, right, Move Focus Right, movefocus, r +bindd = SUPER, up, Move Focus Up, movefocus, u +bindd = SUPER, down, Move Focus Down, movefocus, d # Switch workspaces with mainMod + [0-9] -bind = SUPER, code:10, workspace, 1 -bind = SUPER, code:11, workspace, 2 -bind = SUPER, code:12, workspace, 3 -bind = SUPER, code:13, workspace, 4 -bind = SUPER, code:14, workspace, 5 -bind = SUPER, code:15, workspace, 6 -bind = SUPER, code:16, workspace, 7 -bind = SUPER, code:17, workspace, 8 -bind = SUPER, code:18, workspace, 9 -bind = SUPER, code:19, workspace, 10 +bindd = SUPER, code:10, Switch to workspace 1, workspace, 1 +bindd = SUPER, code:11, Switch to workspace 2, workspace, 2 +bindd = SUPER, code:12, Switch to workspace 3, workspace, 3 +bindd = SUPER, code:13, Switch to workspace 4, workspace, 4 +bindd = SUPER, code:14, Switch to workspace 5, workspace, 5 +bindd = SUPER, code:15, Switch to workspace 6, workspace, 6 +bindd = SUPER, code:16, Switch to workspace 7, workspace, 7 +bindd = SUPER, code:17, Switch to workspace 8, workspace, 8 +bindd = SUPER, code:18, Switch to workspace 9, workspace, 9 +bindd = SUPER, code:19, Switch to workspace 10, workspace, 10 # Move active window to a workspace with mainMod + SHIFT + [0-9] -bind = SUPER SHIFT, code:10, movetoworkspace, 1 -bind = SUPER SHIFT, code:11, movetoworkspace, 2 -bind = SUPER SHIFT, code:12, movetoworkspace, 3 -bind = SUPER SHIFT, code:13, movetoworkspace, 4 -bind = SUPER SHIFT, code:14, movetoworkspace, 5 -bind = SUPER SHIFT, code:15, movetoworkspace, 6 -bind = SUPER SHIFT, code:16, movetoworkspace, 7 -bind = SUPER SHIFT, code:17, movetoworkspace, 8 -bind = SUPER SHIFT, code:18, movetoworkspace, 9 -bind = SUPER SHIFT, code:19, movetoworkspace, 10 +bindd = SUPER SHIFT, code:10, Move Active Window to workspace 1, movetoworkspace, 1 +bindd = SUPER SHIFT, code:11, Move Active Window to workspace 2, movetoworkspace, 2 +bindd = SUPER SHIFT, code:12, Move Active Window to workspace 3, movetoworkspace, 3 +bindd = SUPER SHIFT, code:13, Move Active Window to workspace 4, movetoworkspace, 4 +bindd = SUPER SHIFT, code:14, Move Active Window to workspace 5, movetoworkspace, 5 +bindd = SUPER SHIFT, code:15, Move Active Window to workspace 6, movetoworkspace, 6 +bindd = SUPER SHIFT, code:16, Move Active Window to workspace 7, movetoworkspace, 7 +bindd = SUPER SHIFT, code:17, Move Active Window to workspace 8, movetoworkspace, 8 +bindd = SUPER SHIFT, code:18, Move Active Window to workspace 9, movetoworkspace, 9 +bindd = SUPER SHIFT, code:19, Move Active Window to workspace 10, movetoworkspace, 10 # Swap active window with the one next to it with mainMod + SHIFT + arrow keys -bind = SUPER SHIFT, left, swapwindow, l -bind = SUPER SHIFT, right, swapwindow, r -bind = SUPER SHIFT, up, swapwindow, u -bind = SUPER SHIFT, down, swapwindow, d +bindd = SUPER SHIFT, left, Swap Active Window with Left, swapwindow, l +bindd = SUPER SHIFT, right, Swap Active Window with Right, swapwindow, r +bindd = SUPER SHIFT, up, Swap Active Window with Up, swapwindow, u +bindd = SUPER SHIFT, down, Swap Active Window with Down, swapwindow, d # Resize active window -bind = SUPER, minus, resizeactive, -100 0 -bind = SUPER, equal, resizeactive, 100 0 -bind = SUPER SHIFT, minus, resizeactive, 0 -100 -bind = SUPER SHIFT, equal, resizeactive, 0 100 +bindd = SUPER, minus, Shrink Window Horizontally, resizeactive, -100 0 +bindd = SUPER, equal, Grow Window Horizontally, resizeactive, 100 0 +bindd = SUPER SHIFT, minus, Shrink Window Vertically, resizeactive, 0 -100 +bindd = SUPER SHIFT, equal, Grow Window Vertically, resizeactive, 0 100 # Scroll through existing workspaces with mainMod + scroll -bind = SUPER, mouse_down, workspace, e+1 -bind = SUPER, mouse_up, workspace, e-1 +bindd = SUPER, mouse_down, Scroll Down though workspaces, workspace, e+1 +bindd = SUPER, mouse_up, Scroll Up through workspaces, workspace, e-1 # Move/resize windows with mainMod + LMB/RMB and dragging -bindm = SUPER, mouse:272, movewindow -bindm = SUPER, mouse:273, resizewindow - +bindmd = SUPER, mouse:272, Move Windows, movewindow +bindmd = SUPER, mouse:273, Resize Windows, resizewindow diff --git a/default/hypr/bindings/utilities.conf b/default/hypr/bindings/utilities.conf index 0e6b1b7..74fb16b 100644 --- a/default/hypr/bindings/utilities.conf +++ b/default/hypr/bindings/utilities.conf @@ -1,32 +1,29 @@ -# Launching -bind = SUPER, space, exec, pkill wofi || wofi --show drun --sort-order=alphabetical --style="$HOME/.local/share/omarchy/default/wofi/search.css" -bind = SUPER, K, exec, ~/.local/share/omarchy/bin/omarchy-show-keybindings - # Aesthetics -bind = SUPER SHIFT, SPACE, exec, pkill -SIGUSR1 waybar -bind = SUPER CTRL, SPACE, exec, ~/.local/share/omarchy/bin/swaybg-next -bind = SUPER SHIFT CTRL, SPACE, exec, ~/.local/share/omarchy/bin/omarchy-theme-next +bindd = SUPER SHIFT, SPACE, Hide Waybar, exec, pkill -SIGUSR1 waybar +bindd = SUPER ALT, SPACE, Reload Waybar, exec, pkill -SIGUSR2 waybar +bindd = SUPER CTRL, SPACE, Next Wallpaper, exec, ~/.local/share/omarchy/bin/swaybg-next +bindd = SUPER SHIFT CTRL, SPACE, Next Theme, exec, ~/.local/share/omarchy/bin/omarchy-theme-next # Notifications -bind = SUPER, comma, exec, makoctl dismiss -bind = SUPER SHIFT, comma, exec, makoctl dismiss --all -bind = SUPER CTRL, comma, exec, makoctl mode -t do-not-disturb && makoctl mode | grep -q 'do-not-disturb' && notify-send "Silenced notifications" || notify-send "Enabled notifications" +bindd = SUPER, comma, Dismiss Notification, exec, makoctl dismiss +bindd = SUPER SHIFT, comma, Dismiss All Notifications, exec, makoctl dismiss --all +bindd = SUPER CTRL, comma, Toggle Do Not Disturb, exec, ~/.local/share/omarchy/bin/omarchy-toggle-dnd # Power menu controls lock, suspend, relaunch, restart, shutdown -bind = SUPER, ESCAPE, exec, ~/.local/share/omarchy/bin/omarchy-power-menu +bindd = SUPER, ESCAPE, Show Power Menu (Lock/Suspend/Relaunch/Restart/Shutdown), exec, ~/.local/share/omarchy/bin/omarchy-power-menu # Toggle idling -bind = SUPER CTRL, I, exec, ~/.local/share/omarchy/bin/omarchy-toggle-idle +bindd = SUPER CTRL, I, Toggle Idling, exec, ~/.local/share/omarchy/bin/omarchy-toggle-idle # Control Apple Display brightness -bind = CTRL, F1, exec, ~/.local/share/omarchy/bin/apple-display-brightness -5000 -bind = CTRL, F2, exec, ~/.local/share/omarchy/bin/apple-display-brightness +5000 -bind = SHIFT CTRL, F2, exec, ~/.local/share/omarchy/bin/apple-display-brightness +60000 +bindd = CTRL, F1, Dim Apple Screen Brightness, exec, ~/.local/share/omarchy/bin/apple-display-brightness -5000 +bindd = CTRL, F2, Raise Apple Screen Brightness, exec, ~/.local/share/omarchy/bin/apple-display-brightness +5000 +bindd = SHIFT CTRL, F2, Set Apple Screen Brightness to Max, exec, ~/.local/share/omarchy/bin/apple-display-brightness +60000 # Screenshots -bind = , PRINT, exec, hyprshot -m region -bind = SHIFT, PRINT, exec, hyprshot -m window -bind = CTRL, PRINT, exec, hyprshot -m output +bindd = , PRINT, Screenshot a Region, exec, hyprshot -m region +bindd = SHIFT, PRINT, Screenshot a Window, exec, hyprshot -m window +bindd = CTRL, PRINT, Screenshot Desktop, exec, hyprshot -m output # Color picker -bind = SUPER, PRINT, exec, hyprpicker -a +bindd = SUPER, PRINT, Pick a Color, exec, hyprpicker -a diff --git a/install/development.sh b/install/development.sh index 9fbf0ec..f986891 100644 --- a/install/development.sh +++ b/install/development.sh @@ -3,4 +3,5 @@ yay -S --noconfirm --needed \ imagemagick \ mariadb-libs postgresql-libs \ github-cli \ - lazygit lazydocker-bin + lazygit lazydocker-bin \ + jq