From 9e7b47f1b8dafbfadee3863355b3785384ffe436 Mon Sep 17 00:00:00 2001 From: JaKooLit Date: Mon, 27 Nov 2023 12:04:47 +0900 Subject: Here are changes made 1.) Use pywal for dunst colors. However, seems backgrounds are not changing. Perhaps only on OpenSuse? 2.) Deleted preconfigured style for dunst. to align with #1 changes 3.) Rewrite some scripts to align with PywalDunst. 4.) New script created for Dunst-Pywal called PywalDunst.sh 5.) Random wallpaper auto change is not increased timing to change every 15 mins 6.) Some scripts are re-written --- config/hypr/scripts/WaybarLayout.sh | 45 +++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 17 deletions(-) (limited to 'config/hypr/scripts/WaybarLayout.sh') diff --git a/config/hypr/scripts/WaybarLayout.sh b/config/hypr/scripts/WaybarLayout.sh index dd5fc387..dbe0ee7f 100755 --- a/config/hypr/scripts/WaybarLayout.sh +++ b/config/hypr/scripts/WaybarLayout.sh @@ -1,26 +1,42 @@ #!/bin/bash -CONFIG="$HOME/.config/waybar/configs" -WCONFIG="$HOME/.config/waybar/config" +set -euo pipefail +IFS=$'\n\t' +# Define directories +config_dir="$HOME/.config/waybar/configs" +waybar_config="$HOME/.config/waybar/config" +scripts_dir="$HOME/.config/hypr/scripts" +rofi_config="$HOME/.config/rofi/config-waybar-layout.rasi" + +# Function to display menu options menu() { - # List only files (excluding directories) in the directory and sort alphabetically options=() while IFS= read -r file; do - if [ -f "$CONFIG/$file" ]; then - options+=("$file") - fi - done < <(find "$CONFIG" -maxdepth 1 -type f -exec basename {} \; | sort) - + options+=("$(basename "$file")") + done < <(find "$config_dir" -maxdepth 1 -type f -exec basename {} \; | sort) + printf '%s\n' "${options[@]}" } +# Apply selected configuration apply_config() { - ln -sf "$CONFIG/$1" "$WCONFIG" + ln -sf "$config_dir/$1" "$waybar_config" + restart_waybar_if_needed +} + +# Restart Waybar +restart_waybar_if_needed() { + if pgrep -x "waybar" >/dev/null; then + pkill waybar + sleep 0.1 # Delay for Waybar to completely terminate + fi + "${scripts_dir}/Refresh.sh" & } +# Main function main() { - choice=$(menu | rofi -dmenu -config ~/.config/rofi/config-waybar-layout.rasi) + choice=$(menu | rofi -dmenu -config "$rofi_config") if [[ -z "$choice" ]]; then echo "No option selected. Exiting." @@ -29,10 +45,7 @@ main() { case $choice in "no panel") - if pgrep -x "waybar" >/dev/null; then - pkill waybar - fi - exit 0 + pgrep -x "waybar" && pkill waybar || true ;; *) apply_config "$choice" @@ -40,12 +53,10 @@ main() { esac } -# Check if rofi is already running +# Kill Rofi if already running before execution if pgrep -x "rofi" >/dev/null; then pkill rofi exit 0 fi main - -~/.config/hypr/scripts/Refresh.sh & -- cgit v1.2.3