-
-
Notifications
You must be signed in to change notification settings - Fork 149
/
wallpaper-set.sh
executable file
·138 lines (115 loc) · 5.29 KB
/
wallpaper-set.sh
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/env sh
# Desc: Set-up X.Org wallpaper.
# Author: Harry Kurn <[email protected]>
# URL: https://github.com/owl4ce/dotfiles/tree/ng/.config/openbox/joyful-desktop/wallpaper-set.sh
# SPDX-License-Identifier: ISC
# shellcheck disable=SC2016
export LANG='POSIX'
exec >/dev/null 2>&1
. "${HOME}/.joyfuld"
case "${1}" in
'') WALLPAPER="$(for LS in "$CHK_WALLPAPER_DIR"/*.*; do
[ ! -f "$LS" ] || echo "${LS##*/}"
done \
| rofi -theme-str '@import "action.rasi"' \
-no-show-icons \
-no-lazy-grab \
-no-plugins \
-dmenu \
-mesg 'Select X Wallpaper')"
[ -n "$WALLPAPER" ] || exit ${?}
nitrogen --force-setter=xwindows --set-zoom-fill --save "${CHK_WALLPAPER_DIR}/${WALLPAPER}"
sed -e "/^wallpaper.${CHK_THEME}.${CHK_MODE}[ ]*/s|\".*\"$|\"${WALLPAPER}\"|" -i "$THEME_FILE"
dunstify '' "<span size='small'><u>${WALLPAPER}</u></span>\nSuccessfully applied!" \
-h string:synchronous:wallpaper-set \
-a joyful_desktop \
-i "$WALLPAPER_ICON" \
-u low
;;
g*) [ -x "$(command -v magick)" ] || exec dunstify 'Install `imagemagick`!' -h string:synchronous:install-deps \
-a joyful_desktop \
-u low
cd -- "$WALLPAPERS_DIR" || exit ${?}
for RAW in *.*; do
if [ -f "$RAW" ] && GET_WP_SIZE="$(identify -format %w "$RAW")" && [ -n "$GET_WP_SIZE" ]; then
dunstify '' "Generating X wallpaper ..\n<span size='small'><u>${RAW}</u></span>" \
-h string:synchronous:wallpaper-set \
-a joyful_desktop \
-i "$WALLPAPER_ICON" \
-t 1000
if [ "$GET_WP_SIZE" -lt 1920 ]; then
RES='_HD'
elif [ "$GET_WP_SIZE" -lt 2048 ]; then
RES='_FHD'
elif [ "$GET_WP_SIZE" -lt 2880 ]; then
RES='_2K'
elif [ "$GET_WP_SIZE" -lt 3840 ]; then
RES='_3K'
elif [ "$GET_WP_SIZE" -lt 5120 ]; then
RES='_4K'
elif [ "$GET_WP_SIZE" -lt 6144 ]; then
RES='_5K'
elif [ "$GET_WP_SIZE" -lt 7168 ]; then
RES='_6K'
elif [ "$GET_WP_SIZE" -lt 7680 ]; then
RES='_7K'
elif [ "$GET_WP_SIZE" -eq 7680 ]; then
RES='_8K'
else
RES='_ULTRA'
fi
case "$CHK_THEME" in
mech*) magick "$RAW" \
-gravity center \
-crop 16:9 \
'(' -clone 0 \
-fill '#4c566a' \
-colorize 50% \
')' -gravity center \
-compose lighten \
-composite \
'(' -clone 0 \
-fill '#4c566a' \
-colorize 20% \
')' -gravity center \
-compose darken \
-composite \
-quality 100 \
"${CHK_WALLPAPER_DIR}/${RAW%.*}${RES}.jpg" \
|| continue
;;
eyec*) magick "$RAW" \
-gravity center \
-crop 16:9 \
'(' -clone 0 \
-fill white \
-colorize 20% \
-modulate 100,127,97 \
')' -fill black \
-colorize 2.2% \
-gravity center \
-compose lighten \
-composite \
-quality 100 \
"${CHK_WALLPAPER_DIR}/${RAW%.*}${RES}.jpg" \
|| continue
;;
esac
dunstify '' "Successfully generated!\n<span size='small'>Now it's time to change X wallpaper</span>" \
-h string:synchronous:wallpaper-set \
-a joyful_desktop \
-i "$WALLPAPER_ICON" \
-u low
elif [ -d "$RAW" ]; then
continue
else
dunstify '' "Nothing to generate!\n<span size='small'>Puts in <u>~/${WALLPAPERS_DIR##*/}</u></span>" \
-h string:synchronous:wallpaper-set \
-a joyful_desktop \
-i "$WALLPAPER_ICON" \
-u low
fi
done
;;
esac
exit ${?}