-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtokei
160 lines (137 loc) · 5.31 KB
/
tokei
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
#!/bin/sh
setbackend=1
setdesktop=1
# Grab options
optstr=b:d:hn:o
while getopts $optstr var
do
case $var in
b) backend=$OPTARG; setbackend=0;;
d) desktop=$OPTARG; setdesktop=0;;
h) echo "This is a simple script to grab wallpaper from Bijin-Tokei (http://www.bijint.com/) and set them every minute, as close to on the minute as I can get it. Bijin-Tokei is a wallpaper style that has people holding up the time. I don't read Japanese(which the site is in), or speak it for that matter. However, I assume that the backends are seperated by city/provence, ect, with most of them being just girls, and binan being just guys.
-b Sets the backend to use. You have your choice of okinawa, nagoya, jp, osaka, chiba, aomori, niigata, kyoto, kobe, hiroshima, nagasaki, saitama, fukuoka, tochigi, kagoshima, or binan. By default it uses jp.
-d Sets the desktop to use. You have your choice of lxdm, lxqt, xfce, feh, mate, gnome, and unity, with lxdm being the default.
-h This help.\
-n Uses notify-send to send notifications on time change, how often depending on what number you pass, such as -n 5 will notify every 5 min.
-o This will download all the files in your backend set to ~/.config/tokei/wallpaper/$backend. This allows you to use it offline, as well as helps deal with the poor connection (depending on your location). If you have trouble, and are getting blank images, try this This does take some time though";exit ;;
n) notifysend=yes; timeadded=0; notify=$OPTARG;;
o) offline=yes
esac
done
shift $(( $OPTIND - 1 ))
# Check for config file/dir
if [ ! -f ~/.config/tokei/config.conf ]
then
mkdir -p ~/.config/tokei/wallpaper/jp/
echo "backend=jp" > ~/.config/tokei/config.conf
echo desktop=lxdm >> ~/.config/tokei/config.conf
fi
# Set desktop
if [ $setdesktop = "0" ]
then
echo $(cat ~/.config/tokei/config.conf | grep -v desktop) > ~/.config/tokei/config.conf
echo "desktop=$desktop" >> ~/.config/tokei/config.conf
echo "Desktop set as $desktop"
else
desktop=$(cat ~/.config/tokei/config.conf | grep desktop | sed -e 's/=/\n/g' | grep -v desktop)
echo "Desktop set as $desktop"
fi
# Set backend
if [ $setbackend = "0" ]
then
echo $(cat ~/.config/tokei/config.conf | grep -v backend) > ~/.config/tokei/config.conf
echo "backend=$backend" >> ~/.config/tokei/config.conf
echo "Backend set as $backend"
else
backend=$(cat ~/.config/tokei/config.conf | grep backend | sed -e 's/=/\n/g' | grep -v backend)
echo "Backend set as $backend"
fi
# Make folder for wallpaper if missing
if [ ! -d "~/.config/tokei/wallpaper/$backend" ]
then
mkdir -p ~/.config/tokei/wallpaper/$backend
fi
# Check if all files should be downloaded.
if [ "$offline" == yes ]
then
minute=01
hour=00
curl --connect-timeout 20 --retry 5 http://www.bijint.com/assets/pict/$backend/pc/0000.jpg -o ~/.config/tokei/wallpaper/$backend/0000.jpg
sleep 5
while :
do
if [ $minute -eq "59" ]
then
curl --connect-timeout 20 --retry 5 http://www.bijint.com/assets/pict/$backend/pc/$hour$minute.jpg -o ~/.config/tokei/wallpaper/$backend/$hour$minute.jpg
minute=00
let hour="10#"$hour+1
if [ $hour -lt "10" ]
then
hour="0$hour"
fi
if [ $hour -eq "24" ]
then
echo "You have finished downloading all files in $backend. You can now use this program offline"
exit
fi
else
curl --connect-timeout 20 --retry 5 http://www.bijint.com/assets/pict/$backend/pc/$hour$minute.jpg -o ~/.config/tokei/wallpaper/$backend/$hour$minute.jpg
let minute="10#"$minute+1
echo "minute=$minute"
if [ $minute -lt "10" ]
then
minute="0$minute"
fi
sleep 5
fi
done
fi
while :
do
date=$(date +%H%M)
# Get picture for current time if missing
if [ ! -f ~/.config/tokei/wallpaper/$backend/$date.jpg ]
then
curl http://www.bijint.com/assets/pict/$backend/pc/$date.jpg -o ~/.config/tokei/wallpaper/$backend/$date.jpg
fi
echo "$desktop"
# Set picture to the wallpaper for various desktops
# Function stuff
function lxdm {
pcmanfm --set-wallpaper ~/.config/tokei/wallpaper/$backend/$date.jpg --wallpaper-mode=scaled
}
function lxqt {
pcmanfm-qt --set-wallpaper ~/.config/tokei/wallpaper/$backend/$date.jpg --wallpaper-mode=scaled
}
function xfce {
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s ~/.config/tokei/wallpaper/$backend/$date.jpg
}
function mate {
mateconftool-2 -t str --set /desktop/mate/background/picture_filename ~/.config/tokei/wallpaper/$backend/$date.jpg
mateconftool-2 -t str --set /desktop/mate/background/picture_options stretched
}
function gnome {
gsettings set org.gnome.desktop.background picture-uri "file:///home/$USER/.config/tokei/wallpaper/$backend/$date.jpg"
}
function unity {
gsettings set org.gnome.desktop.background picture-uri "file:///home/$USER/.config/tokei/wallpaper/$backend/$date.jpg"
}
function feh {
feh --bg-scale ~/.config/tokei/wallpaper/$backend/$date.jpg
}
$desktop
if [ "$notifysend" == "yes" ]
then
let timeadded=$timeadded+1
if [ $notify = "$timeadded" ]
then
notify-send -t 2500 -i ~/.config/tokei/wallpaper/$backend/$date.jpg "The current time is $(date +%H:%M)"
timeadded=0
fi
fi
# This set here makes it sleep till the next minute. Thus, as soon as the minute changes, it starts changing the background.
seconds=$(date +%S)
let "sleep = 60 - $seconds"
echo "sleeping for $sleep seconds"
sleep $sleep
done