blob: 63cda8b3cbb5822bcf78461773d1029d7efb0c1e (
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
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
|
#!/bin/sh
. $HOME/.shenv
set -e
# space-separated dirs where wallpaper can be found
dirs="$HOME/lib/annex/doc/img/wallpaper/pro"
# the user can request to freeze the current wallpaper by `touch $HOME/local/.norotate`
test -e "$HOME/local/.norotate" && exit 0
# We don't know to deal with more than one monitor, so don't even try
# (to resize an image for each monitor's wallpaper, and then paste it
# at the right coordinates in a single wallpaper.png to be applied to
# the root window with feh, we would need to be using a real scripting
# language (e.g. Python's pillow))
# (maybe this: https://github.com/hhannine/Superpaper)
monitors="$(xrandr -q | grep ' connected' | wc -l)"
test $monitors -gt 1 && exit 0
# Could keep a log of recently used wallpapers and don't use those
# again (would need code to expire from the log, and if want this,
# should probably write a real, general program not just this
# Sean-specific script)
if [ "x$1" = "x" ]; then
# https://stackoverflow.com/a/16758439
img="$(find $dirs -name '*' -exec file -L {} \; | grep -o -P '^.+: \w+ image' | shuf -n 1 | cut -d: -f1)"
else
img="$1"
fi
if [ -n "$DISPLAY" ]; then
dims="$(xdpyinfo | grep dimensions: | awk '{print $2}')"
elif [ -e "$HOME/local/wallpaper.png" ]; then
dims="$(identify $HOME/local/wallpaper.png | awk '{print $3}')"
else
echo >&2 "$0: unable to determine display dimensions"
exit 1
fi
if [ -n "$img" ]; then
# this will just size up images with the correct aspect ratio. For
# images with the wrong aspect ratio, it'll crop them. I find that's
# usually better than adding borders (which is what the commented out
# cmd does)
convert "$img" \
-resize "$dims"^ -gravity center -extent "$dims" \
$HOME/local/wallpaper.png
# convert "$img" \
# -resize "$dims" -background black -gravity center -extent "$dims" \
# $HOME/local/wallpaper.png
# this calls feh
[ -n "$DISPLAY" ] && i3-startup-always
fi
# do develacc too, though we can't call i3-startup-always
if [ -d "$HOME/local/develacc/local" ]; then
if [ "x$2" = "x" ]; then
img2="$(find $dirs -name '*' -exec file -L {} \; | grep -o -P '^.+: \w+ image' | shuf -n 1 | cut -d: -f1)"
else
img2="$2"
fi
if [ -n "$img2" ]; then
convert "$img2" \
-resize "$dims"^ -gravity center -extent "$dims" \
$HOME/local/develacc/local/wallpaper.png
fi
fi
|