-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsdtp
65 lines (57 loc) · 1.85 KB
/
sdtp
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
#!/bin/sh
#
# Copyright (c) 2000-2015 Matthew Pearson <[email protected]>.
#
# These scripts are free. There is no warranty; your mileage may vary.
# Visit http://creativecommons.org/licenses/by-nc-sa/4.0/ for more details.
#
# $Id$
# paint the root window with an image named on the command line
#
SNAME=`basename $0`
USAGE="usage: $SNAME [-s] [<img>]"
VSAGE="\t-s scale image to fit desktop\n\n\
\t$SNAME changes the root window graphic to <img> or randomly.\n\n\
\tThis script looks for files in \$HOME/desktops/XxY/, where XxY\n\
\tis the resolution of the current display. Users with multiple\n\
\tdisplays might place images suitable for one screen in\n\
\t\$HOME/desktops/1024x768/ and ones for another in 1280x852/.\n\
\tIf no file is set on the command line, one is chosen at random.\n"
serror() {
printf '%s: %s.\n' $SNAME "$*"
exit 1
}
RES=`xdpyinfo | awk '/dimensions/ { print $2 }'`
[ $? -eq 0 ] && [ "$RES" ] || serror 'xdpyinfo unavailable'
while getopts lrsh arg
do
case $arg in
r) : ;; # deprecated
s) xvarg="-maxp" ;;
h) echo $USAGE
printf "$VSAGE"
exit 0 ;;
*) echo $USAGE
exit 1 ;;
esac
done
shift `expr $OPTIND - 1`
if [ "$1" ]
then
img=`ls $HOME/desktops/$RES/${1}* 2>/dev/null`
[ "$img" ] || img=`ls $HOME/desktops/*/${1}* 2>/dev/null`
[ "$img" ] || img=`ls $HOME/desktops/${1}* 2>/dev/null`
else
[ -d $HOME/desktops/$RES ] || \
serror 'no files exist at current resolution' $RES
seed=`date +%S`
filec=`ls $HOME/desktops/$RES | wc -w`
index=`expr 1 + $seed % $filec`
img=$HOME/desktops/$RES/`ls $HOME/desktops/$RES | awk "NR == $index"`
fi
[ `echo "$img" | wc -w` -gt 1 ] && \
serror 'ambiguous image name' \"$1\"
[ -f "$img" ] || serror 'could not find image' \"$1\"
echo "setting desktop to $img..."
exec xv $xvarg -root $img -rmode 5 -quit
#EOF __TAGGED__