소스 검색

meta: move timer stuff to it's own file

master
sentriz 2 달 전
부모
커밋
2b70631290
No known key found for this signature in database 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"



불러오는 중...
취소
저장