diff options
author | Leo Vivier <zaeph@zaeph.net> | 2022-10-23 18:28:09 +0200 |
---|---|---|
committer | Leo Vivier <zaeph@zaeph.net> | 2022-10-23 18:28:09 +0200 |
commit | 8fcec90fd02cfa4c970f24f6ee29607b4a69e318 (patch) | |
tree | 15e7bbd9196fb547fafdc29b9fa34d07bd451e3d /2022/organizers-notebook | |
parent | 08f44d9324b4b067d86f91d1bd712da4f1b88745 (diff) | |
download | emacsconf-wiki-8fcec90fd02cfa4c970f24f6ee29607b4a69e318.tar.xz emacsconf-wiki-8fcec90fd02cfa4c970f24f6ee29607b4a69e318.zip |
Overhaul script
Diffstat (limited to '2022/organizers-notebook')
-rw-r--r-- | 2022/organizers-notebook/index.org | 68 |
1 files changed, 46 insertions, 22 deletions
diff --git a/2022/organizers-notebook/index.org b/2022/organizers-notebook/index.org index e722c41f..8de46eb1 100644 --- a/2022/organizers-notebook/index.org +++ b/2022/organizers-notebook/index.org @@ -3586,49 +3586,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 |