File: wallpaper

package info (click to toggle)
nnn 5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,184 kB
  • sloc: ansic: 11,902; sh: 3,585; makefile: 512; cpp: 80; python: 31; csh: 2
file content (45 lines) | stat: -rwxr-xr-x 1,355 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env sh

# Description: Set the selected image as wallpaper.
# Uses nitrogen or pywal on X11, swww on wayland.
#
# Usage: Hover on an image and run the script to set it as wallpaper.
#
# Shell: POSIX compliant
# Author: juacq97

resp=

if [ -n "$1" ]; then
    if [ "$(file --mime-type "$1" | awk '{print $NF}' | awk -F '/' '{print $1}')" = "image" ]; then
        if [ "$XDG_SESSION_TYPE" = "x11" ]; then
            if type nitrogen >/dev/null 2>&1; then
            	printf "Set to full desktop or a specific monitors? [0, 1, etc. Defaults to full.]"
            	read -r resp
            	if [ "$resp" != "" ]; then
            		nitrogen --set-zoom-fill --save "$1" --head="$resp"
            	else
                	nitrogen --set-zoom-fill --save "$1"
            	fi
            elif type wal >/dev/null 2>&1; then
                wal -i "$1"
            else
                printf "nitrogen or pywal missing"
                read -r _
            fi
        else
            if type swww >/dev/null 2>&1; then
                swww img "$1"
            else
                printf "swww missing"
                read -r _
            fi
        fi

    # If you want a system notification, uncomment the next 3 lines.
    # notify-send -a "nnn" "Wallpaper changed!"
    #   else
    # notify-send -a "nnn" "No image selected"

    fi
fi