ソースを参照

meta: move timer stuff to it's own file

master
sentriz 2ヶ月前
コミット
2b70631290
この署名に対応する既知のキーがデータベースに存在しません GPGキーID: 9A8DAE1CA907B862
2個のファイルの変更14行の追加23行の削除
  1. +12
    -10
      conf_common/bin/timer
  2. +2
    -13
      conf_extra/bin/blocks/block_timer

+ 12
- 10
conf_common/bin/timer ファイルの表示

@@ -1,15 +1,17 @@
#!/usr/bin/env bash

if test $# -ne 1; then
echo "please provide a diff in seconds" >&2
exit 1
fi
future_file="$XDG_CACHE_HOME/timer_left"
future="$(cat "$future_file" 2>/dev/null || date "+%s")"
test $# -eq 1 \
&& echo "$(("$future" + "$1"))" >"$future_file" \
&& exit

timer_file="$XDG_CACHE_HOME/timer_left"
test ! -e "$future_file" && exit

future="$(date "+%s")"
if [[ -e "$timer_file" ]]; then
future="$(cat "$timer_file")"
fi
left="$(("$future" - $(date "+%s")))"
test "$left" -le 0 \
&& notify-send.sh -t 600 "timer" "the time has passed" \
&& rm "$future_file" 2>/dev/null \
&& exit

echo "$(("$future" + "$1"))" >"$timer_file"
echo "$left"

+ 2
- 13
conf_extra/bin/blocks/block_timer ファイルの表示

@@ -1,18 +1,7 @@
#!/usr/bin/env bash

timer_file="$XDG_CACHE_HOME/timer_left"
if [[ ! -e "$timer_file" ]]; then
exit
fi

future="$(cat "$timer_file")"
left="$(("$future" - $(date "+%s")))"

if [[ "$left" -le 0 ]]; then
notify-send.sh -t 600 "timer" "the time has passed"
rm "$timer_file"
exit
fi
left="$(timer)"
test -e "$left" && exit

date --utc --date="@$left" "+timer %Mm %Ss"



読み込み中…
キャンセル
保存