blob: e01627f606cf5de2ba75c764adaacd177d2d2a16 (
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
|
#!/bin/sh
# Set images as background with feh.
# Get absolute path of file.
if ! file="$(realpath "$1" 2> /dev/null)"; then
echo "Usage: setbg <file>"
exit 0
fi
# Check if file is an image.
case "$(file -bi "$file")" in
image/*)
;;
*)
echo "setbg: invalid file operand" 1>&2
exit 1
;;
esac
printf -- "#!/bin/sh\n\n" > "$HOME/bin/bg"
printf -- "feh --no-fehbg --bg-scale %s\n" "$file" >> "$HOME/bin/bg"
chmod 755 "$HOME/bin/bg"
sh "$HOME/bin/bg"
exit 0
|