Hacker News new | ask | show | jobs
by branweb 2060 days ago
Interesting...I wrote this to display a countdown in the i3 status bar:

  #!/usr/bin/env sh

  DIFF_DAYS=""

  death_clock () {
    DEATH_DATE=$(date --date 'YYYY-MM-DD -u' +%s)
    TODAY=$(date +%s)
    DIFF=$(expr "$DEATH_DATE" - "$TODAY")
    DIFF_DAYS=$(expr "$DIFF" / $(expr 24 \* 3600))
  }

  i3status | (read line && echo "$line" && read line && echo "$line" && read line && echo "$line" && while :
  do
    read line
    death_clock
    echo ",[{\"full_text\":\"days left: ${DIFF_DAYS}\", \"color\": \"#0000FF\" },${line#,\[}" || exit 1
  done)
Definitely not polished but seems to work if you fill in the "YYYY-MM-DD" with your expected date of departure.