irongit
hygoland/scripts/KeyBinds.sh
39 lines1.3 KBBourne Again Shell (bash)
1#!/bin/bash
2# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
3# searchable enabled keybinds using rofi
4
5# kill yad to not interfere with this binds
6pkill yad || true
7
8# check if rofi is already running
9if pidof rofi > /dev/null; then
10 pkill rofi
11fi
12
13# define the config files
14keybinds_conf="$HOME/.config/hypr/configs/Keybinds.conf"
15user_keybinds_conf="$HOME/.config/hypr/UserConfigs/UserKeybinds.conf"
16laptop_conf="$HOME/.config/hypr/UserConfigs/Laptops.conf"
17rofi_theme="$HOME/.config/rofi/config-keybinds.rasi"
18msg='☣️ NOTE ☣️: Clicking with Mouse or Pressing ENTER will have NO function'
19
20# combine the contents of the keybinds files and filter for keybinds
21keybinds=$(cat "$keybinds_conf" "$user_keybinds_conf" | grep -E '^bind')
22
23# check if laptop.conf exists and add its keybinds if present
24if [[ -f "$laptop_conf" ]]; then
25 laptop_binds=$(grep -E '^bind' "$laptop_conf")
26 keybinds+=$'\n'"$laptop_binds"
27fi
28
29# check for any keybinds to display
30if [[ -z "$keybinds" ]]; then
31 echo "no keybinds found."
32 exit 1
33fi
34
35# replace $mainmod with super in the displayed keybinds for rofi
36display_keybinds=$(echo "$keybinds" | sed 's/\$mainMod/SUPER/g')
37
38# use rofi to display the keybinds with the modified content
39echo "$display_keybinds" | rofi -dmenu -i -config "$rofi_theme" -mesg "$msg"