aboutsummaryrefslogtreecommitdiff
path: root/set-theme
blob: f4b5e305ee153ca7a2bf4a749679721236f8ea1e (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash

# CONFIG
ignore_background_color="#04000a"
highlight="#08000a"
default_theme="tokyo-night"

# END CONFIG
cd "$(dirname "$0")"

ignore_file=0
list_files=0
ignore_background=0
run_pywal=0
set_wallpaper=0

while getopts "h?lpbw" opt; do
    case "$opt" in
        h) 
            printf -- "-l  list themes
-p  run pywall
-b  ignore background and use one defined in script
-w  set wallpaper with setwll if \$wallpaper exist"
            exit 0
            ;;
        l) list_files=1
            ;;
        b) ignore_background=1
            ;;
        p) run_pywal=1
            ignore_file=1
            ;;
        w) set_wallpaper=1
            ;;
    esac
done

shift $((OPTIND-1))
[ "${1:-}" = "--" ] && shift

theme_file=$1

if [ $list_files == 1 ]; then
    ls $1 ./themes/
    exit 0
fi

if [ "$theme_file" == "" ]; then
    theme_file="$default_theme"
fi

if [ $ignore_file == 0 ]; then
    source ./themes/$theme_file.sh || exit 1
fi


if [ $run_pywal == 1 ]; then
    if [ $(pgrep hyprpaper) ]; then
        wallpaper=$(hyprctl hyprpaper listactive | grep HDMI | sed 's/HDMI-A-1 = //')
        wal -seti "$wallpaper"
        . "$HOME/.cache/wal/colors.sh"
        [ $ignore_background == 1 ] && background="$ignore_background_color"
    else
        echo NO AVAILABLE WALLPAPER ENGINE
        echo please define wallpaper
        exit 1
    fi
fi

[ $ignore_background == 1 ] && background="$ignore_background_color"

runs_dir="$(find ./targets -mindepth 1 -maxdepth 1 -type f -executable)"
for s in $runs_dir; do
    source "$s"
done

if [ $set_wallpaper == 1 ] && [ "$wallpaper" ]; then
    setwll -ua "$wallpaper"
fi