diff options
Diffstat (limited to 'config/hypr/scripts')
| -rwxr-xr-x | config/hypr/scripts/Animations.sh | 12 | ||||
| -rwxr-xr-x | config/hypr/scripts/ClipManager.sh | 5 | ||||
| -rwxr-xr-x | config/hypr/scripts/KeyBinds.sh | 3 | ||||
| -rwxr-xr-x | config/hypr/scripts/RofiEmoji.sh | 5 | ||||
| -rwxr-xr-x | config/hypr/scripts/RofiSearch.sh | 5 | ||||
| -rwxr-xr-x | config/hypr/scripts/RofiThemeSelector.sh | 75 |
6 files changed, 92 insertions, 13 deletions
diff --git a/config/hypr/scripts/Animations.sh b/config/hypr/scripts/Animations.sh index 7789cb05..b4d368e9 100755 --- a/config/hypr/scripts/Animations.sh +++ b/config/hypr/scripts/Animations.sh @@ -12,23 +12,19 @@ iDIR="$HOME/.config/swaync/images" SCRIPTSDIR="$HOME/.config/hypr/scripts" animations_dir="$HOME/.config/hypr/animations" UserConfigs="$HOME/.config/hypr/UserConfigs" +rofi_theme="~/.config/rofi/config-Animations.rasi" # list of animation files, sorted alphabetically with numbers first animations_list=$(find "$animations_dir" -maxdepth 1 -type f | sed 's/.*\///' | sed 's/\.conf$//' | sort -V) # Rofi Menu -chosen_file=$(echo "$animations_list" | rofi -i -dmenu -config ~/.config/rofi/config-Animations.rasi) +chosen_file=$(echo "$animations_list" | rofi -i -dmenu -config $rofi_theme) # Check if a file was selected if [[ -n "$chosen_file" ]]; then - # Find the full path of the chosen file - full_path="$animations_dir/$chosen_file.conf" - - cp "$full_path" "$UserConfigs/UserAnimations.conf" - + full_path="$animations_dir/$chosen_file.conf" + cp "$full_path" "$UserConfigs/UserAnimations.conf" notify-send -u low -i "$iDIR/ja.png" "$chosen_file" "Hyprland Animation Loaded" -else - notify-send -u low -i "$iDIR/ja.png" "You chose NOT" "to apply other Hyprland animations" fi sleep 1 diff --git a/config/hypr/scripts/ClipManager.sh b/config/hypr/scripts/ClipManager.sh index 13f90a9e..642adb82 100755 --- a/config/hypr/scripts/ClipManager.sh +++ b/config/hypr/scripts/ClipManager.sh @@ -2,6 +2,9 @@ # /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## # Clipboard Manager. This script uses cliphist, rofi, and wl-copy. +# Variables +rofi_theme="~/.config/rofi/config-clipboard.rasi" + # Actions: # CTRL Del to delete an entry # ALT Del to wipe clipboard contents @@ -16,7 +19,7 @@ while true; do rofi -i -dmenu \ -kb-custom-1 "Control-Delete" \ -kb-custom-2 "Alt-Delete" \ - -config ~/.config/rofi/config-clipboard.rasi < <(cliphist list) + -config $rofi_theme < <(cliphist list) ) case "$?" in diff --git a/config/hypr/scripts/KeyBinds.sh b/config/hypr/scripts/KeyBinds.sh index 9e01a7c3..f80211f5 100755 --- a/config/hypr/scripts/KeyBinds.sh +++ b/config/hypr/scripts/KeyBinds.sh @@ -14,6 +14,7 @@ fi KEYBINDS_CONF="$HOME/.config/hypr/configs/Keybinds.conf" USER_KEYBINDS_CONF="$HOME/.config/hypr/UserConfigs/UserKeybinds.conf" LAPTOP_CONF="$HOME/.config/hypr/UserConfigs/Laptop.conf" +rofi_theme="~/.config/rofi/config-keybinds.rasi" # Combine the contents of the keybinds files and filter for keybinds KEYBINDS=$(cat "$KEYBINDS_CONF" "$USER_KEYBINDS_CONF" | grep -E '^(bind|bindl|binde|bindm)') @@ -31,4 +32,4 @@ if [[ -z "$KEYBINDS" ]]; then fi # Use rofi to display the keybinds -echo "$KEYBINDS" | rofi -dmenu -i -p "Keybinds" -config ~/.config/rofi/config-keybinds.rasi
\ No newline at end of file +echo "$KEYBINDS" | rofi -dmenu -i -config $rofi_theme
\ No newline at end of file diff --git a/config/hypr/scripts/RofiEmoji.sh b/config/hypr/scripts/RofiEmoji.sh index fa27a341..1079bfdd 100755 --- a/config/hypr/scripts/RofiEmoji.sh +++ b/config/hypr/scripts/RofiEmoji.sh @@ -2,13 +2,16 @@ # /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## # Rofi Emoticons. Not my own. Cant remember the source +# Variables +rofi_theme="~/.config/rofi/config-emoji.rasi" + # Check if rofi is already running if pidof rofi > /dev/null; then pkill rofi fi sed '1,/^# # DATA # #$/d' "$0" | \ -rofi -i -dmenu -config ~/.config/rofi/config-emoji.rasi | \ +rofi -i -dmenu -config $rofi_theme | \ awk -F'\t' '{print $1}' | \ tr -d '\n' | \ wl-copy diff --git a/config/hypr/scripts/RofiSearch.sh b/config/hypr/scripts/RofiSearch.sh index faf07865..d9576a1a 100755 --- a/config/hypr/scripts/RofiSearch.sh +++ b/config/hypr/scripts/RofiSearch.sh @@ -4,7 +4,7 @@ # Opens rofi in dmenu mod and waits for input. Then pushes the input to the query of the URL. -rofi_config="$HOME/.config/rofi/config-search.rasi" +rofi_theme="$HOME/.config/rofi/config-search.rasi" # Kill Rofi if already running before execution if pgrep -x "rofi" >/dev/null; then @@ -13,5 +13,6 @@ if pgrep -x "rofi" >/dev/null; then fi # Open rofi with a dmenu and pass the selected item to xdg-open for Google search -echo "" | rofi -dmenu -config "$rofi_config" | xargs -I{} xdg-open "https://www.google.com/search?q={}" +#echo "" | rofi -dmenu -config "$rofi_config" | xargs -I{} xdg-open "https://www.google.com/search?q={}" +echo "" | rofi -dmenu -config $rofi_theme | xargs -I{} xdg-open "https://www.google.com/search?q={}" diff --git a/config/hypr/scripts/RofiThemeSelector.sh b/config/hypr/scripts/RofiThemeSelector.sh new file mode 100755 index 00000000..420316bd --- /dev/null +++ b/config/hypr/scripts/RofiThemeSelector.sh @@ -0,0 +1,75 @@ +#!/bin/bash +# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## +# Script for adding a selected theme to the Rofi config + +IFS=$'\n\t' + +# Define directories and variables +rofi_theme_dir="$HOME/.local/share/rofi/themes" +rofi_config_file="$HOME/.config/rofi/config.rasi" +SED=$(which sed) +iDIR="$HOME/.config/swaync/images" +rofi_theme="$HOME/.config/rofi/config-rofi-theme.rasi" + +# Function to display menu options +menu() { + options=() + while IFS= read -r file; do + options+=("$(basename "$file")") + done < <(find "$rofi_theme_dir" -maxdepth 1 -type f -exec basename {} \; | sort) + + printf '%s\n' "${options[@]}" +} + +# Function to add or update theme in the config.rasi +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}" + else + theme_path_with_tilde="$theme_path" + fi + + # If no @theme is in the file, add it + 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" + else + $SED -i "s/^\(\s*@theme.*\)/\/\/\1/" "$rofi_config_file" + echo -e "@theme \"$theme_path_with_tilde\"" >> "$rofi_config_file" + echo "Updated @theme line to $theme_path_with_tilde" + fi + + # Ensure no more than max # of lines with //@theme lines + max_line="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 + for i in $(seq 1 "$excess"); do + $SED -i '0,/^\s*\/\/@theme/ { /^\s*\/\/@theme/ {d; q; }}' "$rofi_config_file" + done + echo "Removed excess //@theme lines" + fi +} + +# Main function +main() { + choice=$(menu | rofi rofi -dmenu -i -config $rofi_theme) + + if [[ -z "$choice" ]]; then + exit 0 + fi + add_theme_to_config "$choice" + notify-send -i "$iDIR/ja.png" -u low 'Rofi Theme' "$choice applied." +} + +if pgrep -x "rofi" >/dev/null; then + pkill rofi +fi + +main |
