summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSacha Chua <sacha@sachachua.com>2022-10-23 14:07:17 -0400
committerSacha Chua <sacha@sachachua.com>2022-10-23 14:07:17 -0400
commitabdd318f04c299a11dfafcc8c5881481d52c2bc7 (patch)
treef3d2df8e98d58964b87df481d9352c9478bad918
parent020dbe6e2a6397667936e5032a78d9d6d746a770 (diff)
parent8fcec90fd02cfa4c970f24f6ee29607b4a69e318 (diff)
downloademacsconf-wiki-abdd318f04c299a11dfafcc8c5881481d52c2bc7.tar.xz
emacsconf-wiki-abdd318f04c299a11dfafcc8c5881481d52c2bc7.zip
Merge branch 'master' of git://git.emacsconf.org/emacsconf-wiki
-rw-r--r--2022/organizers-notebook/index.org68
1 files changed, 46 insertions, 22 deletions
diff --git a/2022/organizers-notebook/index.org b/2022/organizers-notebook/index.org
index 88117253..02415adc 100644
--- a/2022/organizers-notebook/index.org
+++ b/2022/organizers-notebook/index.org
@@ -3695,49 +3695,73 @@ Throw an error if ERROR is non-nil, skip otherwise."
#+begin_src sh :eval no :tangle prerecs-wait-new.sh
#!/usr/bin/env sh
-set -eu
+sleep_duration=600
-sleep_duration=1800
-
-data=prerec-wait-new.data
+data="$(basename "$0" ".sh").data"
touch "$data"
-plural() {
+plural () {
if [ "$2" = 1 ] || [ "$2" = -1 ]; then
echo "${1}"
else
case $1 in
"is" )
- "are"
+ echo "are"
;;
- ,* )
- "${1}s"
+ * )
+ echo "${1}s"
esac
fi
}
+current_time() {
+ date +"[%T]"
+}
+
+log() {
+ printf "%s $1\n" "$(current_time)"
+}
+
+color_green="\e[32m"
+color_white="\e[0m"
+
+log2() {
+ log "${color_green}$1${color_white}"
+}
+
notify() {
- echo "$1"
- notify-send -t 0 "EmacsConf" "$1"
+ log2 "$1"
+ notify-send -t 0 "EmacsConf" "$(log "$1")"
}
-echo "Currently waiting for prerec"
+_sleep() {
+ log "Checking again in ${sleep_duration}s"
+ sleep "$sleep_duration"
+}
-prerecs_number_past=$(cat "$data")
-diff=0
+log2 "Currently waiting for prerec"
while true; do
- prerecs_number_current="$(TERM=xterm ssh orga@media.emacsconf.org -- ls -1 /srv/upload | wc -l)"
- diff=$((prerecs_number_current - prerecs_number_past))
- if [ $diff -gt 0 ]; then
- break
- fi
- sleep "$sleep_duration"
-done
+ prerecs_number_past=$(cat "$data")
+ diff=0
-notify "Yay~, $diff new $(plural "prerec" $diff) $(plural "is" $diff) available!"
+ while true; do
+ log "Checking..."
+ prerecs_number_current="$(TERM=xterm ssh orga@media.emacsconf.org -- ls -1 /srv/upload | wc -l)"
+ diff=$((prerecs_number_current - prerecs_number_past))
+ if [ $diff -gt 0 ]; then
+ break
+ fi
+ log "No new prerec."
+ _sleep
+ done
+
+ notify "$diff new $(plural "prerec" $diff) $(plural "is" $diff) available!"
-echo "$prerecs_number_current" > "$data"
+ echo "$prerecs_number_current" > "$data"
+
+ _sleep
+done
#+end_src