From 92de1d9b553a743c963b4764fda0e2d7f7660363 Mon Sep 17 00:00:00 2001 From: koksnuss Date: Mon, 21 May 2018 15:31:52 +0200 Subject: [PATCH] fix and refractor datetime --- config | 2 +- modules/datetime | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/config b/config index 9f0a606..61e79b4 100644 --- a/config +++ b/config @@ -57,4 +57,4 @@ label=◎ instance=mic [datetime] -# instance=long +#instance=pm diff --git a/modules/datetime b/modules/datetime index 408ca93..e65cf89 100755 --- a/modules/datetime +++ b/modules/datetime @@ -1,17 +1,18 @@ #!/bin/bash -FULL=$(date '+%A %-d.%-m.%Y W%V, %-H:%M:%S') -SHORT=$(date '+%-H:%M') +toggle_long_instance () { [[ "$LONG" == "true" ]] && LONG=false || LONG=true; } -[[ "$BLOCK_INSTANCE" == "long" ]] && export I3_LONG_DATETIME=true - -if [[ "$BLOCK_BUTTON" == "1" ]]; then - if [[ "$I3_LONG_DATETIME" == "true" ]]; then - export I3_LONG_DATETIME=false - else - export I3_LONG_DATETIME=true - fi +if [[ "$BLOCK_INSTANCE" =~ "pm" ]]; then + FULL=$(date '+%A %-d.%-m.%Y W%V, %-I:%M:%S%p') + SHORT=$(date '+%-I:%M%p') +else + FULL=$(date '+%A %-d.%-m.%Y W%V, %-H:%M:%S') + SHORT=$(date '+%-H:%M') fi -[[ "$I3_LONG_DATETIME" == "true" ]] && echo $FULL || echo $SHORT +[[ "$BLOCK_INSTANCE" =~ "long" ]] && toggle_long_instance + +[[ "$BLOCK_BUTTON" == "1" ]] && toggle_long_instance + +[[ "$LONG" == "true" ]] && echo $FULL || echo $SHORT echo $SHORT