aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'config/hypr/scripts')
-rwxr-xr-xconfig/hypr/scripts/KeyBinds.sh40
-rwxr-xr-xconfig/hypr/scripts/RofiThemeSelector-modified.sh75
-rwxr-xr-xconfig/hypr/scripts/RofiThemeSelector.sh4
3 files changed, 63 insertions, 56 deletions
diff --git a/config/hypr/scripts/KeyBinds.sh b/config/hypr/scripts/KeyBinds.sh
index 639dd3a1..324a9d00 100755
--- a/config/hypr/scripts/KeyBinds.sh
+++ b/config/hypr/scripts/KeyBinds.sh
@@ -1,36 +1,40 @@
#!/bin/bash
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
-# Searchable enabled keybinds using rofi
+# searchable enabled keybinds using rofi
-# Kill yad to not interfere with this binds
+# kill yad to not interfere with this binds
pkill yad || true
-# Check if rofi is already running
+# check if rofi is already running
if pidof rofi > /dev/null; then
pkill rofi
fi
-# Define the config files
-KEYBINDS_CONF="$HOME/.config/hypr/configs/Keybinds.conf"
-USER_KEYBINDS_CONF="$HOME/.config/hypr/UserConfigs/UserKeybinds.conf"
-LAPTOP_CONF="$HOME/.config/hypr/UserConfigs/Laptops.conf"
+# define the config files
+keybinds_conf="$HOME/.config/hypr/configs/Keybinds.conf"
+user_keybinds_conf="$HOME/.config/hypr/UserConfigs/UserKeybinds.conf"
+laptop_conf="$HOME/.config/hypr/UserConfigs/Laptops.conf"
rofi_theme="$HOME/.config/rofi/config-keybinds.rasi"
msg='☣️ NOTE ☣️: Clicking with Mouse or Pressing ENTER will have NO function'
-# Combine the contents of the keybinds files and filter for keybinds
-KEYBINDS=$(cat "$KEYBINDS_CONF" "$USER_KEYBINDS_CONF" | grep -E '^bind')
+# combine the contents of the keybinds files and filter for keybinds
+keybinds=$(cat "$keybinds_conf" "$user_keybinds_conf" | grep -E '^bind')
-# Check if Laptop.conf exists and add its keybinds if present
-if [[ -f "$LAPTOP_CONF" ]]; then
- LAPTOP_BINDS=$(grep -E '^bind' "$LAPTOP_CONF")
- KEYBINDS+=$'\n'"$LAPTOP_BINDS"
+# check if laptop.conf exists and add its keybinds if present
+if [[ -f "$laptop_conf" ]]; then
+ laptop_binds=$(grep -E '^bind' "$laptop_conf")
+ keybinds+=$'\n'"$laptop_binds"
fi
-# Check for any keybinds to display
-if [[ -z "$KEYBINDS" ]]; then
- echo "No keybinds found."
+# check for any keybinds to display
+if [[ -z "$keybinds" ]]; then
+ echo "no keybinds found."
exit 1
fi
-# Use rofi to display the keybinds
-echo "$KEYBINDS" | rofi -dmenu -i -config "$rofi_theme" -mesg "$msg"
+# replace $mainmod with super in the displayed keybinds for rofi
+display_keybinds=$(echo "$keybinds" | sed 's/\$mainMod/SUPER/g')
+
+# use rofi to display the keybinds with the modified content
+echo "$display_keybinds" | rofi -dmenu -i -config "$rofi_theme" -mesg "$msg"
+s \ No newline at end of file
diff --git a/config/hypr/scripts/RofiThemeSelector-modified.sh b/config/hypr/scripts/RofiThemeSelector-modified.sh
index e4d476c3..2af75a73 100755
--- a/config/hypr/scripts/RofiThemeSelector-modified.sh
+++ b/config/hypr/scripts/RofiThemeSelector-modified.sh
@@ -36,7 +36,7 @@ then
fi
TMP_CONFIG_FILE=$(${MKTEMP}).rasi
-rofi_theme_dir="${HOME}/.local/share/rofi/themes"
+#rofi_theme_dir="${HOME}/.local/share/rofi/themes"
rofi_config_file="${XDG_CONFIG_HOME:-${HOME}/.config}/rofi/config.rasi"
##
@@ -50,32 +50,25 @@ declare -a theme_names
# Function that tries to find all installed rofi themes.
# This fills in #themes array and formats a displayable string #theme_names
##
-find_themes()
-{
- DIRS="${HOME}/.local/share"
- OLDIFS=${IFS}
- IFS=:
- # Add user dir.
- DIRS+=":${XDG_CONFIG_HOME:-${HOME}/.config}"
- for p in ${DIRS}; do
- p=${p%/}
- TD=${p}/rofi/themes
- if [ -n "${p}" ] && [ -d "${TD}" ]
- then
- echo "Checking themes in: ${TD}"
- for file in ${TD}/*.rasi
- do
- if [ -f "${file}" ]
- then
- themes+=("${file}")
- FN=$(basename "${file}")
- NAME=${FN%.*} # Extract the file name without extension
- theme_names+=("${NAME}") # Only add the base file name
+# Find themes in defined directories
+find_themes() {
+ directories=("$HOME/.local/share/rofi/themes" "$HOME/.config/rofi/themes")
+
+ for TD in "${directories[@]}"; do
+ if [ -d "$TD" ]; then
+ echo "Checking themes in: $TD"
+ for file in "$TD"/*.rasi; do
+ if [ -f "$file" ] && [ ! -L "$file" ]; then
+ themes+=("$file")
+ theme_names+=("$(basename "${file%.*}")")
+ else
+ echo "Skipping symlink: $file"
fi
- done
+ done
+ else
+ echo "Directory does not exist: $TD"
fi
done
- IFS=${OLDIFS}
}
##
@@ -83,16 +76,27 @@ find_themes()
##
add_theme_to_config() {
local theme_name="$1"
- local theme_path="$rofi_theme_dir/$theme_name"
-
- # if config in $HOME to write as $HOME
- if [[ "$theme_path" == $HOME/* ]]; then
- theme_path_with_tilde="~${theme_path#$HOME}"
+ local theme_path
+
+ # Determine the correct path for the theme
+ if [[ -f "$HOME/.local/share/rofi/themes/$theme_name.rasi" ]]; then
+ theme_path="$HOME/.local/share/rofi/themes/$theme_name.rasi"
+ elif [[ -f "$HOME/.config/rofi/themes/$theme_name.rasi" ]]; then
+ theme_path="$HOME/.config/rofi/themes/$theme_name.rasi"
else
- theme_path_with_tilde="$theme_path"
+ echo "Theme not found: $theme_name"
+ return 1
fi
- # If no @theme is in the file, add it
+ # Resolve symlinks if present
+ if [[ -L "$theme_path" ]]; then
+ theme_path=$(readlink -f "$theme_path")
+ fi
+
+ # Convert path to use ~ for home directory
+ theme_path_with_tilde="~${theme_path#$HOME}"
+
+ # Add or update @theme line in config
if ! grep -q '^\s*@theme' "$rofi_config_file"; then
echo -e "\n\n@theme \"$theme_path_with_tilde\"" >> "$rofi_config_file"
echo "Added @theme \"$theme_path_with_tilde\" to $rofi_config_file"
@@ -102,13 +106,12 @@ add_theme_to_config() {
echo "Updated @theme line to $theme_path_with_tilde"
fi
- # Ensure no more than max # of lines with //@theme lines
- max_line="9"
+ # Limit the number of @theme lines to a maximum of 9
+ max_lines=9
total_lines=$(grep -c '^\s*//@theme' "$rofi_config_file")
- if [ "$total_lines" -gt "$max_line" ]; then
- excess=$((total_lines - max_line))
- # Remove the oldest or the very top //@theme lines
+ if [ "$total_lines" -gt "$max_lines" ]; then
+ excess=$((total_lines - max_lines))
for i in $(seq 1 "$excess"); do
$SED -i '0,/^\s*\/\/@theme/ { /^\s*\/\/@theme/ {d; q; }}' "$rofi_config_file"
done
diff --git a/config/hypr/scripts/RofiThemeSelector.sh b/config/hypr/scripts/RofiThemeSelector.sh
index cbce04b0..968d1f30 100755
--- a/config/hypr/scripts/RofiThemeSelector.sh
+++ b/config/hypr/scripts/RofiThemeSelector.sh
@@ -5,7 +5,7 @@
IFS=$'\n\t'
# Define directories and variables
-rofi_theme_dir="$HOME/.local/share/rofi/themes"
+rofi_theme_dir="$HOME/.config/rofi/themes"
rofi_config_file="$HOME/.config/rofi/config.rasi"
SED=$(which sed)
iDIR="$HOME/.config/swaync/images"
@@ -25,7 +25,7 @@ menu() {
add_theme_to_config() {
local theme_name="$1"
local theme_path="$rofi_theme_dir/$theme_name"
-
+
# if config in $HOME to write as $HOME
if [[ "$theme_path" == $HOME/* ]]; then
theme_path_with_tilde="~${theme_path#$HOME}"
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage