| 1 |
#!/usr/bin/env sh |
| 2 |
|
| 3 |
# Description: Set the selected image as wallpaper. |
| 4 |
# Uses nitrogen or pywal on X11, swww on wayland. |
| 5 |
# |
| 6 |
# Usage: Hover on an image and run the script to set it as wallpaper. |
| 7 |
# |
| 8 |
# Shell: POSIX compliant |
| 9 |
# Author: juacq97 |
| 10 |
|
| 11 |
resp= |
| 12 |
|
| 13 |
if [ -n "$1" ]; then |
| 14 |
if [ "$(file --mime-type "$1" | awk '{print $NF}' | awk -F '/' '{print $1}')" = "image" ]; then |
| 15 |
if [ "$XDG_SESSION_TYPE" = "x11" ]; then |
| 16 |
if type nitrogen >/dev/null 2>&1; then |
| 17 |
printf "Set to full desktop or a specific monitors? [0, 1, etc. Defaults to full.]" |
| 18 |
read -r resp |
| 19 |
if [ "$resp" != "" ]; then |
| 20 |
nitrogen --set-zoom-fill --save "$1" --head="$resp" |
| 21 |
else |
| 22 |
nitrogen --set-zoom-fill --save "$1" |
| 23 |
fi |
| 24 |
elif type wal >/dev/null 2>&1; then |
| 25 |
wal -i "$1" |
| 26 |
else |
| 27 |
printf "nitrogen or pywal missing" |
| 28 |
read -r _ |
| 29 |
fi |
| 30 |
else |
| 31 |
if type swww >/dev/null 2>&1; then |
| 32 |
swww img "$1" |
| 33 |
else |
| 34 |
printf "swww missing" |
| 35 |
read -r _ |
| 36 |
fi |
| 37 |
fi |
| 38 |
|
| 39 |
# If you want a system notification, uncomment the next 3 lines. |
| 40 |
# notify-send -a "nnn" "Wallpaper changed!" |
| 41 |
# else |
| 42 |
# notify-send -a "nnn" "No image selected" |
| 43 |
|
| 44 |
fi |
| 45 |
fi |