-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
wallutils
171 lines (164 loc) · 4.33 KB
/
wallutils
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#
## @file Utils/wallutils
## @brief Wallpaper shell script utility functions
## @author Ronald Joe Record (rr at ronrecord dot com)
## @copyright Copyright (c) 2016, Ronald Joe Record, all rights reserved.
## @date Written 17-Sep-2016
## @version 1.0.1
##
# Set these to your top-level pictures directory paths
SEA_DIR="/Volumes/Seagate_8TB/Pictures"
NFS_DIR="/mac/pictures"
LIN_DIR="/u/pictures"
# Set PICROOT in your environment to override what is set here
if [ "${PICROOT}" ]
then
WHDIR="${PICROOT}/Work/Wallhaven"
else
if [ -d "${SEA_DIR}" ]
then
WHDIR="${SEA_DIR}/Work/Wallhaven"
else
if [ -d "${NFS_DIR}" ]
then
WHDIR="${NFS_DIR}/Work/Wallhaven"
else
WHDIR="${LIN_DIR}/Work/Wallhaven"
fi
fi
fi
query=
demo=
model=
playboy=
penthouse=
photodromm=
suicide=
japanese=
artist=
photo=
latest=
numdown=
page=
quiet=
categories=
filters=
subdir=
prevperc=
LN="ln"
if [ -r /usr/local/share/bash/kv ]
then
. /usr/local/share/bash/kv
have_kv=1
else
have_kv=
fi
## @fn progress()
## @brief Displays a progress bar and percentage of tasks completed
## @param param1 Total number of tasks
## @param param2 Number of tasks completed thus far
progress() {
numd=$1
comp=$2
perdone=`echo "$comp/$numd" | bc -l`
statlen=`echo "($perdone*70)/1" | bc`
remain=`echo "70-$statlen" | bc`
percent=`echo "($perdone*100)/1" | bc`
[ "$prevperc" ] || prevperc=$percent
[ $prevperc -eq $percent ] || {
printf '%0.s#' $(seq 1 $statlen)
[ $percent -lt 100 ] && printf '%0.s_' $(seq 1 $remain)
printf " $percent%% "
printf "\r"
}
}
## @fn usage()
## @brief Display command line usage options
## @param none
##
## Exit the program after displaying the usage message and example invocations
usage() {
printf "\nUsage: %s [-n num] [-c cat] [-f filter] [-p page]" $0
printf " [-l subdir] [-s search] [-abdhLmPqu]"
printf "\n\nWhere:\n\t-n num specifies the number of downloads"
printf "\n\t-c cat specifies the category mask (001 - 111)"
printf "\n\t-f filter specifies the filter mask (001 - 111)"
printf "\n\t-p page specifies the start page"
printf "\n\t-l subdir specifies the download subdirectory to use"
printf "\n\t-d indicates demo mode, tell me what you would do but don't do it"
printf "\n\t-L indicates use symbolic links when finding duplicates"
printf "\n\t-b indicates Playboy Model search, use Models/Playboy/<model_name> download dir"
printf "\n\t-e indicates Penthouse Model search, use Models/Penthouse/<model_name> download dir"
printf "\n\t-h indicates Photodromm Model search, use Models/Photodromm/<model_name> download dir"
printf "\n\t-a indicates Artist search, use Artists/<artist_name> download dir"
printf "\n\t-m indicates Model search, use Models/<model_name> download dir"
printf "\n\t-P indicates Photographer search, use Photographers/<name> download dir"
printf "\n\t-R indicates retrieve most recent wallpapers for search term"
printf "\n\t-S indicates Suicide Girl search, use Suicide_Girls/<model_name> download dir"
printf "\n\t-q indicates quiet mode, suppress messages"
printf "\n\t-s search specifies the search terms ( + for AND, space for OR)"
printf "\n\t-u displays this usage message\n"
exit 1
}
while getopts l:n:c:f:p:s:abedhJLmPRSqu flag; do
case $flag in
l)
subdir=$OPTARG
;;
d)
demo=1
;;
J)
japanese=1
;;
L)
LN="ln -s"
;;
P)
photo=1
;;
R)
latest="-m date_added"
;;
S)
suicide=1
;;
b)
playboy=1
;;
e)
penthouse=1
;;
h)
photodromm=1
;;
a)
artist=1
;;
m)
model=1
;;
n)
numdown=$OPTARG
;;
c)
categories=$OPTARG
;;
f)
filters=$OPTARG
;;
p)
page=$OPTARG
;;
q)
quiet="-Q"
;;
s)
query="$OPTARG"
;;
*)
usage
;;
esac
done
shift $(( OPTIND - 1 ))