aboutsummaryrefslogtreecommitdiff
path: root/setwll
blob: 67e99a8a66262dc1db2215d9b7a9b1b242ab1ddd (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh
# may be moved to theme setter
cd "$(dirname "$0")" || exit

listwalls=0
unload=0
secondary=""
primary=""
all=""

while getopts "hlup:s:a:" opt; do
    case "$opt" in
        h)
            printf -- "-l  list wallpapers
-u  unload current wall after switching
-p  set primary mon wallpaper
-s  set secondary mon wallpaper
-a  set all mon wallpaper

unloading only applies to hyprpaper
add scripts to wallpaper_scripts for easier switching\n"
            exit 0
            ;;
        l) listwalls=1
            ;;
        u) unload=1
            ;;
        p) primary="$OPTARG"
            ;;
        s) secondary="$OPTARG"
            ;;
        a) all="$OPTARG"
            ;;
        *) break ;;
    esac
done

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

if [ $listwalls = 1 ]; then
    ls ./wallpaper_scripts
    exit 0
fi

if [ "$all" ]; then
    primary="$all"
    secondary="$all"
fi

if [ -z "$primary" ]; then
    primary="$(./wallpaper_scripts/default-primary.sh)"
else
    if [ -f "./wallpaper_scripts/$primary.sh" ]; then
        primary="$(./wallpaper_scripts/"$primary.sh")"
    fi
fi

if [ -z "$secondary" ]; then
    secondary="$(./wallpaper_scripts/default-secondary.sh)"
else
    if [ -f "./wallpaper_scripts/$secondary.sh" ]; then
        secondary="$(./wallpaper_scripts/"$secondary".sh)"
    fi
fi


if [ "$WAYLAND_DISPLAY" ]; then
    if [ "$XDG_CURRENT_DESKTOP" = "sway:wlroots" ]; then
        PID=$(pidof swaybg)
        swaybg -o HDMI-A-1 -i "$primary" -m fill -o DP-1 -i "$secondary" -m fill &
        sleep 0.4s
        kill "$PID"
    else
        current_wal="$(hyprctl hyprpaper listactive | grep HDMI-A-1 | sed 's/HDMI-A-1 = //')"
        hyprctl hyprpaper preload "$primary"
        hyprctl hyprpaper wallpaper "HDMI-A-1,$primary"
        if [ $unload = 1 ]; then
            hyprctl hyprpaper unload "$current_wal"
        fi

        current_wal="$(hyprctl hyprpaper listactive | grep DP-1 | sed 's/DP-1 = //')"
        hyprctl hyprpaper preload "$secondary"
        hyprctl hyprpaper wallpaper "DP-1,$secondary"
        if [ $unload = 1 ]; then
            hyprctl hyprpaper unload "$current_wal"
        fi
    fi
else
    if [ -z "$1" ]; then
        nitrogen --head=0 --set-zoom-fill "$primary"

        nitrogen --head=1 --set-zoom-fill "$secondary"
    fi
fi