-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathtomato.sh
executable file
·37 lines (33 loc) · 4.72 KB
/
tomato.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
#!/bin/bash
basedir=$(cd $(dirname $(readlink -f ${BASH_SOURCE:-$0}));pwd)
cd ${basedir}
workPeriod=${1:?"undefined 'workPeriod'"};shift
restPeriod=${1:?"undefined 'restPeriod'"};shift
iconData='<svg id="Capa_1" enable-background="new 0 0 512 512" height="512" viewBox="0 0 512 512" width="512" xmlns="http://www.w3.org/2000/svg"><g><circle cx="256" cy="256" fill="#95b0ed" r="248.5"/><path d="m256 37.5v437c120.674 0 218.5-97.826 218.5-218.5s-97.826-218.5-218.5-218.5z" fill="#c4f3ff"/><path d="m444.5 256c0-120.674-84.394-218.5-188.5-218.5-120.674 0-218.5 97.826-218.5 218.5s97.826 218.5 218.5 218.5c104.106 0 188.5-97.826 188.5-218.5z" fill="#fff"/><path d="m429.5 241h-30v30h30c8.28 0 15-6.72 15-15s-6.72-15-15-15z" fill="#452096"/><path d="m399.5 241h-132.52v30h132.52c8.28 0 15-6.72 15-15s-6.72-15-15-15z" fill="#5c2bc8"/><path d="m271 112.5c0-8.284-6.716-15-15-15s-15 6.716-15 15v132.523h30z" fill="#5c2bc8"/><circle cx="256" cy="256" fill="#95b0ed" r="30"/><ellipse cx="419.246" cy="161.75" rx="7.5" ry="7.5" transform="matrix(.971 -.238 .238 .971 -26.458 104.493)"/><path d="m356.745 96.504c2.071-3.587.842-8.174-2.745-10.245s-8.174-.842-10.245 2.745-.842 8.174 2.745 10.245c3.587 2.072 8.174.843 10.245-2.745z"/><circle cx="256" cy="67.5" r="7.5"/><path d="m165.5 99.25c3.587-2.071 4.816-6.658 2.745-10.245s-6.658-4.816-10.245-2.745-4.816 6.658-2.745 10.245 6.658 4.816 10.245 2.745z"/><ellipse cx="92.754" cy="161.75" rx="7.5" ry="7.5" transform="matrix(.15 -.989 .989 .15 -81.097 229.145)"/><circle cx="67.5" cy="256" r="7.5"/><ellipse cx="92.754" cy="350.25" rx="7.5" ry="7.5" transform="matrix(.994 -.109 .109 .994 -37.627 12.198)"/><path d="m155.255 415.496c-2.071 3.587-.842 8.174 2.745 10.245s8.174.842 10.245-2.745.842-8.174-2.745-10.245c-3.587-2.072-8.174-.843-10.245 2.745z"/><circle cx="256" cy="444.5" r="7.5"/><path d="m346.5 412.75c-3.587 2.071-4.816 6.658-2.745 10.245s6.658 4.816 10.245 2.745 4.816-6.658 2.745-10.245-6.658-4.816-10.245-2.745z"/><ellipse cx="419.246" cy="350.25" rx="7.5" ry="7.5" transform="matrix(.27 -.963 .963 .27 -31.128 659.451)"/><circle cx="256" cy="256" r="7.5"/><path d="m437.02 74.98c-48.353-48.351-112.64-74.98-181.02-74.98s-132.667 26.629-181.02 74.98c-48.351 48.353-74.98 112.64-74.98 181.02s26.629 132.667 74.98 181.02c48.353 48.351 112.64 74.98 181.02 74.98s132.667-26.629 181.02-74.98c48.351-48.353 74.98-112.64 74.98-181.02s-26.629-132.667-74.98-181.02zm-181.02 422.02c-132.888 0-241-108.112-241-241s108.112-241 241-241 241 108.112 241 241-108.112 241-241 241z"/><path d="m415.806 96.194c-42.685-42.686-99.439-66.194-159.806-66.194-54.612 0-107.335 19.748-148.458 55.605-3.122 2.722-3.446 7.46-.724 10.582 2.722 3.123 7.46 3.446 10.582.724 38.391-33.475 87.613-51.911 138.6-51.911 116.346 0 211 94.654 211 211s-94.654 211-211 211-211-94.654-211-211c0-50.987 18.436-100.209 51.911-138.6 2.722-3.122 2.398-7.86-.724-10.582-3.121-2.722-7.859-2.398-10.582.724-35.857 41.123-55.605 93.846-55.605 148.458 0 60.367 23.508 117.121 66.194 159.806s99.439 66.194 159.806 66.194 117.121-23.508 159.806-66.194 66.194-99.439 66.194-159.806-23.508-117.121-66.194-159.806z"/><path d="m138.621 373.38c2.929 2.929 7.678 2.929 10.606 0l86.108-86.109c5.93 3.931 13.033 6.229 20.665 6.229 12.242 0 23.131-5.898 29.98-15h143.52c12.407 0 22.5-10.093 22.5-22.5s-10.093-22.5-22.5-22.5h-143.52c-2.129-2.83-4.649-5.35-7.48-7.479v-113.521c0-12.407-10.093-22.5-22.5-22.5s-22.5 10.093-22.5 22.5v113.521c-9.102 6.848-15 17.737-15 29.979 0 7.632 2.297 14.735 6.229 20.665l-86.108 86.109c-2.93 2.928-2.93 7.677 0 10.606zm290.879-124.88c4.136 0 7.5 3.364 7.5 7.5s-3.364 7.5-7.5 7.5h-136.755c.494-2.424.755-4.932.755-7.5s-.261-5.076-.755-7.5zm-181-136c0-4.136 3.364-7.5 7.5-7.5s7.5 3.364 7.5 7.5v106.755c-2.424-.494-4.932-.755-7.5-.755s-5.076.261-7.5.755zm7.5 121c12.407 0 22.5 10.093 22.5 22.5s-10.093 22.5-22.5 22.5-22.5-10.093-22.5-22.5 10.093-22.5 22.5-22.5z"/></g></svg>'
icon=${basedir}/clock.svg
echo ${iconData} >${icon}
countdown(){
local icon=${1:?"undefined 'icon'"};shift
local period=${1:?"undefined 'period'"};shift
local tickPeriod=${1:?"undefined 'tickPeriod'"};shift
local message=${1:?"undefined 'message'"};shift
local startSec=$(date +"%s")
local endSec=$((startSec+period))
while : ; do
local nowSec=$(date +"%s")
local sinceSec=$((endSec-nowSec))
if [ ${sinceSec} -le 0 ];then
break
fi
local sinceMin=$((sinceSec/60))
sinceSec=$((sinceSec%60))
expiryTimeMs=$(perl -MList::Util=max,min -e "print max(2,min(10,int(${tickPeriod}/2)))*1000")
notify-send -t ${expiryTimeMs} -i ${icon} "${message}: ${sinceMin}m${sinceSec}s"
sleep ${tickPeriod}
done
notify-send -t 1 -i ${icon} "${message}: Countdown done!!"
}
while : ; do
countdown ${icon} ${workPeriod} 10 "WORKING"
countdown ${icon} ${restPeriod} 10 "RESTING"
done