From 064bfbb969fd0dfeffab21e3d9c2fe147ff5f6b6 Mon Sep 17 00:00:00 2001 From: "Ja.KooLit" Date: Sat, 23 Dec 2023 15:26:35 +0900 Subject: Update and rename ChangeTheme.sh to ZshChangeTheme.sh Script is also updated to exit if no choice have been selected as previous script is changing to 3den, which is the first choice on my system --- config/hypr/scripts/ChangeTheme.sh | 35 -------------------------------- config/hypr/scripts/ZshChangeTheme.sh | 38 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 35 deletions(-) delete mode 100755 config/hypr/scripts/ChangeTheme.sh create mode 100755 config/hypr/scripts/ZshChangeTheme.sh (limited to 'config') diff --git a/config/hypr/scripts/ChangeTheme.sh b/config/hypr/scripts/ChangeTheme.sh deleted file mode 100755 index 3b7ad3d4..00000000 --- a/config/hypr/scripts/ChangeTheme.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - - -themes_dir="$HOME/.oh-my-zsh/themes" -file_extension=".zsh-theme" - -themes_array=($(find "$themes_dir" -type f -name "*$file_extension" -exec basename {} \; | sed -e "s/$file_extension//")) - - -rofi_command="rofi -dmenu -config ~/.config/rofi/config-themezsh.rasi" - -menu() { - for theme in "${themes_array[@]}"; do - echo "$theme" - done -} - -main() { - choice=$(menu | ${rofi_command}) - zsh_path="$HOME/.zshrc" - var_name="ZSH_THEME" - for i in "${themes_array[@]}"; do - if [[ "$i" == "$choice"* ]]; then - if [ -f "$zsh_path" ]; then - sed -i "s/^$var_name=.*/$var_name=\"$i\"/" "$zsh_path" - else - echo "File not found" - fi - break - fi - done - -} - -main diff --git a/config/hypr/scripts/ZshChangeTheme.sh b/config/hypr/scripts/ZshChangeTheme.sh new file mode 100755 index 00000000..7057ed2e --- /dev/null +++ b/config/hypr/scripts/ZshChangeTheme.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +themes_dir="$HOME/.oh-my-zsh/themes" +file_extension=".zsh-theme" + +themes_array=($(find "$themes_dir" -type f -name "*$file_extension" -exec basename {} \; | sed -e "s/$file_extension//")) + +rofi_command="rofi -dmenu -config ~/.config/rofi/config-zsh-theme.rasi" + +menu() { + for theme in "${themes_array[@]}"; do + echo "$theme" + done +} + +main() { + choice=$(menu | ${rofi_command}) + + # if nothing selected, script wont change anything + if [ -z "$choice" ]; then + exit 0 + fi + + zsh_path="$HOME/.zshrc" + var_name="ZSH_THEME" + for i in "${themes_array[@]}"; do + if [[ "$i" == "$choice"* ]]; then + if [ -f "$zsh_path" ]; then + sed -i "s/^$var_name=.*/$var_name=\"$i\"/" "$zsh_path" + else + echo "File not found" + fi + break + fi + done +} + +main -- cgit v1.2.3