aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/WaybarStyles.sh
blob: de3a54dc332798a49515b7c80e9ec37f5b47199a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash

CONFIG="$HOME/.config/waybar/style"
WCONFIG="$HOME/.config/waybar/style.css"

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+=("$(basename "$file" .css)")
        fi
    done < <(find "$CONFIG" -maxdepth 1 -type f -name '*.css' -exec basename {} \; | sort)
    
    printf '%s\n' "${options[@]}"
}

apply_style() {
    ln -sf "$CONFIG/$1.css" "$WCONFIG"
}

main() {
    choice=$(menu | rofi -dmenu -config ~/.config/rofi/config-waybar-style.rasi)

    if [[ -z "$choice" ]]; then
        echo "No option selected. Exiting."
        exit 0
    fi

    apply_style "$choice"

    # Restart relevant processes
    for process in waybar mako dunst; do
        if pgrep -x "$process" >/dev/null; then
            pkill "$process"
        fi
    done

    # Launch Refresh.sh in the background
    ~/.config/hypr/scripts/Refresh.sh &
}

# Check if rofi is already running
if pgrep -x "rofi" >/dev/null; then
    pkill rofi
    exit 0
fi

main
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage