tmux-golden-apple

pomodoro timer tmux plugin
git clone git://git.pyratebeard.net/tmux-golden-apple.git
Log | Files | Refs | README | LICENSE

commit 916b219ab895669eff6c9a47412eb9e19015fe30
parent 4f2e3009e43d43593f998dcb9c3030ee3464440b
Author: pyratebeard <root@pyratebeard.net>
Date:   Thu, 14 Jul 2022 14:32:05 +0100

shellcheck updates

Diffstat:
Mgolden_apple.tmux | 16++++++++--------
Mscripts/timer.sh | 28++++++++++++++--------------
2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/golden_apple.tmux b/golden_apple.tmux @@ -2,13 +2,13 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -timer="#($CURRENT_DIR/scripts/timer.sh)" +timer="#(${CURRENT_DIR}/scripts/timer.sh)" interpolate_string="\#{goldenapple}" interpolate() { - local -r status="$1" - local -r status_value=$(tmux show-option -gqv "$status") - tmux set-option -gq "$status" "${status_value/$interpolate_string/$timer}" + local -r status="${1}" + local -r status_value=$(tmux show-option -gqv "${status}") + tmux set-option -gq "${status}" "${status_value/$interpolate_string/$timer}" } timer() { @@ -17,18 +17,18 @@ timer() { } killtimer() { - for p in $(ps -ef | grep $CURRENT_DIR/scripts/timer.sh | grep -v grep | awk '{print $2}') ; do - kill -9 $p + for p in $(pgrep "${CURRENT_DIR}"/scripts/timer.sh | grep -v grep | awk '{print $2}') ; do + kill -9 "${p}" done tmux source-file ~/.tmux.conf >/dev/null 2>&1 } main() { tmux source-file ~/.tmux.conf >/dev/null 2>&1 - case $1 in + case "${1}" in start) timer ;; stop) killtimer ; exit 0 ;; esac } -main $1 +main "${1}" diff --git a/scripts/timer.sh b/scripts/timer.sh @@ -4,13 +4,13 @@ work=15 work_option="@work" get_tmux_option() { - local -r option="$1" - local -r default_option="$2" - local -r option_value="$(tmux show-option -gqv "$option")" - if [ -z "$option_value" ] ; then - echo "$default_option" + local -r option="${1}" + local -r default_option="${2}" + local -r option_value="$(tmux show-option -gqv "${option}")" + if [ -z "${option_value}" ] ; then + echo "${default_option}" else - echo "$option_value" + echo "${option_value}" fi } @@ -19,26 +19,26 @@ pomodoro_timer() { echo "running" > /tmp/goldenapple.status IFS=: - set -- $* + set -- "$@" secs=$(( ${1#0} * 60 + 00 )) - while [ $secs -gt 0 ] + while [ ${secs} -gt 0 ] do sleep 1 & - printf "\r %02d:%02d " $(( (secs/60)%60)) $((secs%60)) - secs=$(( $secs - 1 )) + printf "\r %02d:%02d " $(( ( secs/60 ) % 60 )) $(( secs % 60 )) + secs=$(( secs - 1 )) wait done echo - for p in $(ps -ef | grep $CURRENT_DIR/scripts/timer.sh | grep -v grep | awk '{print $2}') ; do - kill -9 $p + for p in $(pgrep "${CURRENT_DIR}"/scripts/timer.sh | grep -v grep | awk '{print $2}') ; do + kill -9 "${p}" done tmux source-file ~/.tmux.conf >/dev/null 2>&1 tmux display-popup -w 30% -h 8% echo "pomodoro work period done" } main() { - local -r work_count="$(get_tmux_option "$work_option" "$work")" - pomodoro_timer ${work_count} + local -r work_count="$(get_tmux_option "${work_option}" "${work}")" + pomodoro_timer "${work_count}" } main