3 # Description: Set the selected image as wallpaper.
4 # Uses nitrogen or pywal on X11, swww on wayland.
6 # Usage: Hover on an image and run the script to set it as wallpaper.
8 # Shell: POSIX compliant
11 selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
16 printf '%s\0' "$@" >> "$selection"
20 if [ "$(file --mime-type "$1" | awk '{print $NF}' | awk -F '/' '{print $1}')" = "image" ]; then
21 if [ "$XDG_SESSION_TYPE" = "x11" ]; then
22 if type nitrogen >/dev/null 2>&1; then
23 printf "Set to full desktop or a specific monitors? [0, 1, etc. Defaults to full.]"
25 if [ "$resp" != "" ]; then
26 nitrogen --set-zoom-fill --save "$1" --head="$resp"
28 nitrogen --set-zoom-fill --save "$1"
30 elif type wal >/dev/null 2>&1; then
33 printf "nitrogen or pywal missing"
37 if type swww >/dev/null 2>&1; then
45 # If you want a system notification, uncomment the next 3 lines.
46 # notify-send -a "nnn" "Wallpaper changed!"
48 # notify-send -a "nnn" "No image selected"