Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added linux notification #2

Merged
merged 2 commits into from Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion pomodoro.tmux
Expand Up @@ -17,6 +17,7 @@ set_start_binding() {
local key
for key in $key_bindings; do
tmux bind-key "$key" run-shell "$CURRENT_DIR/scripts/pomodoro.sh start"
tmux bind-key "C-$key" run-shell "$CURRENT_DIR/scripts/pomodoro.sh manual"
done
}

Expand Down Expand Up @@ -47,4 +48,4 @@ main() {
update_tmux_option "status-right"
update_tmux_option "status-left"
}
main
main
25 changes: 19 additions & 6 deletions scripts/pomodoro.sh
Expand Up @@ -73,11 +73,18 @@ send_notification() {
local title=$1
local message=$2
local sound=$(get_sound)
if [ "$sound" == "off" ]; then
osascript -e 'display notification "'"$message"'" with title "'"$title"'"'
else
osascript -e 'display notification "'"$message"'" with title "'"$title"'" sound name "'"$sound"'"'

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
notify-send -t 5000 "$title" "$message"

elif [[ "$OSTYPE" == "darwin"* ]]; then
if [[ sound == "on" ]]; then
osascript -e 'display notification "'"$message"'" with title "'"$title"'" sound name "'"$sound"'"'
else
osascript -e 'display notification "'"$message"'" with title "'"$title"'"'
fi
fi

fi
}

Expand All @@ -102,6 +109,10 @@ pomodoro_cancel() {
return 0
}

pomodoro_manual() {
tmux command-prompt -p 'Pomodoro Mins:' 'set -g @pomodoro_mins %1'
}

pomodoro_status() {
local pomodoro_start_time=$(read_file "$POMODORO_FILE")
local pomodoro_status=$(read_file "$POMODORO_STATUS_FILE")
Expand All @@ -122,9 +133,9 @@ pomodoro_status() {
send_notification "🍅 Pomodoro completed!" "Your Pomodoro has now completed"
write_to_file "on_break" "$POMODORO_STATUS_FILE"
fi
printf "$(get_tmux_option "$pomodoro_complete" "$pomodoro_complete_default")$((-($difference - $(get_pomodoro_duration) - $(get_pomodoro_break)))) "
printf "$(get_tmux_option "$pomodoro_complete" "$pomodoro_complete_default")$((-($difference - $(get_pomodoro_duration) - $(get_pomodoro_break))))m "
else
printf "$(get_tmux_option "$pomodoro_on" "$pomodoro_on_default")$(($(get_pomodoro_duration) - $difference)) "
printf "$(get_tmux_option "$pomodoro_on" "$pomodoro_on_default")$(($(get_pomodoro_duration) - $difference))m "
fi
}

Expand All @@ -136,6 +147,8 @@ main() {
pomodoro_start
elif [ "$cmd" = "cancel" ]; then
pomodoro_cancel
elif [ "$cmd" = "manual" ]; then
pomodoro_manual
else
pomodoro_status
fi
Expand Down