-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbing-rotate.sh
executable file
·76 lines (57 loc) · 2.55 KB
/
bing-rotate.sh
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
#!/bin/bash
# Adapted from https://gist.github.com/pedrosland/10464302
# $bing is needed to form the fully qualified URL for
# the Bing pic of the day
bing="http://www.bing.com"
# $xmlURL is needed to get the xml data from which
# the relative URL for the Bing pic of the day is extracted
# The idx parameter determines where to start from. 0 is the current day,
# 1 the previous day, etc.
xmlURL="http://www.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1&mkt=en-WW"
# $saveDir is used to set the location where Bing pics of the day
# are stored. $HOME holds the path of the current user's home directory
saveDir="$HOME/Downloads/wallpapers/"
# Create saveDir if it does not already exist
mkdir -p $saveDir
# Set picture options
# Valid options are: none,wallpaper,centered,scaled,stretched,zoom,span ned
picOpts="zoom"
# The desired Bing picture resolution to download
# Valid options: "_1024x768" "_1280x720" "_1366x768" "_1920x1200"
picRes="_1920x1080"
# The file extension for the Bing pic
picExt=".jpg"
# Extract the relative URL of the Bing pic of the day from
# the XML data retrieved from xmlURL, form the fully qualified
# URL for the pic of the day, and store it in $picURL
picURL=$bing$(echo $(curl -s $xmlURL) | grep -oP "<urlBase>(.*)</urlBase>" | cut -d ">" -f 2 | cut -d "<" -f 1)$picRes$picExt
# Temporary Name
tempName="temp.jpg"
# Download the Bing pic of the day
curl -s -o $saveDir$tempName $picURL
# Notify user
notify-send "Downloaded Bing picture of the day"
# Get the description from the EXIF of the image
#annotation=$(/usr/bin/vendor_perl/exiftool -s -s -s -Title "$saveDir$tempName")
annotation=$(exiftool -s -s -s -Title "$saveDir$tempName")
# Final Name given by Bing
picName=${picURL##*/}
picFileName=${picName%.*}.png
# Dir to place the altered images (with image description)
deskDir="${saveDir}desktop/"
# Make sure the directory exists
mkdir -p $deskDir
# Write the EXIF into the Wallpaper
#convert $saveDir$tempName -fill white -undercolor '#00000080' -font Ubuntu-Regular -pointsize 24 -gravity Southeast -annotate +0+5 " $annotation " $deskDir$picName
# Ubuntu Unity (no bottom menu)
#convert $saveDir$tempName -fill white -undercolor '#00000080' -font Ubuntu-Regular -pointsize 24 -gravity Southeast -annotate +0+61 " $annotation " $deskDir$picFileName
# Cinnamon (bottom menu)
# Remove Temp
#rm $saveDir$tempName
mv $saveDir$tempName $saveDir$picName
#backgroundHolder=/usr/share/backgrounds/bing.png
#cp "$(realpath $saveDir$picName)" "$backgroundHolder"
# Remove pictures older than 7 days
find $deskDir -atime 14 -delete
# Exit the script
exit