summaryrefslogtreecommitdiff
path: root/dotfiles/system/.profile.d/chronographic.sh
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2025-05-10 15:06:27 -0500
committerCraig Jennings <c@cjennings.net>2025-05-10 15:06:27 -0500
commita9eb95269dd183b6f8e56e322b50e7973815565e (patch)
tree7b6ffd66d7907305d7ffc24b632beab4d9b18f42 /dotfiles/system/.profile.d/chronographic.sh
parentab76058ce2f1f0c9a9935647bddf16b03e5a3e1f (diff)
sorting through profile
Diffstat (limited to 'dotfiles/system/.profile.d/chronographic.sh')
-rw-r--r--dotfiles/system/.profile.d/chronographic.sh116
1 files changed, 0 insertions, 116 deletions
diff --git a/dotfiles/system/.profile.d/chronographic.sh b/dotfiles/system/.profile.d/chronographic.sh
deleted file mode 100644
index d53fe2b..0000000
--- a/dotfiles/system/.profile.d/chronographic.sh
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/bin/sh
-
-# chronographic.sh
-# Craig Jennings <c@cjennings.net>
-# quick and dirty terminal clock, timer, alarm and stopwatch functions
-
-alias beep='paplay $BEEP'
-export BEEP="/usr/share/sounds/freedesktop/stereo/bell.oga"
-
-##
-## CLOCK
-##
-
-clock() {
- while true; do tput clear; echo ""; date +" %l : %M %p" | figlet -f roman -w 200 ; sleep 1; done
-}
-
-##
-## TIMER
-##
-
-timer() {
- # Ensure we have at least two arguments
- if [ "$#" -lt 2 ]; then
- echo "Pass the time and a notification. Example: timer 1h30m Parking expiring"
- return 1
- fi
- message="${@:2}"
- start_time=$(date +"%H:%M:%S %p")
- printf "\nStarting %s timer at $start_time\n" "$1"
- snore "$1" && paplay "$BEEP" && notify-send "Timer" "$message" && echo ""
-}
-
-##
-## ALARM
-##
-
-alarm() {
- # Ensure we have two or more arguments
- if [ "$#" -lt 2 ]; then
- echo "Pass both the time and a message. Example: alarm 1:45pm Time to eat!"
- return 1
- fi
-
- # Validate the first argument is a valid time
- ! date -d "$1" >/dev/null 2>&1 && echo "Invalid time: $1" && return 1
-
- # silently schedule the command using 'at' command
- echo "paplay \$BEEP && notify-send \"Alarm\" \"$@\"" | at "$1" >> /dev/null
- echo "Alarm '${@:2}' is queued for $1." && echo "To see all alarms, issue the command: atq" && echo ""
-}
-
-##
-## STOPWATCH FUNCTIONS
-##
-
-sw_start_time=0
-sw_started=0
-
-swreset() {
- sw_start_time=0
- sw_started=0
- echo "Stopwatch reset"
-}
-
-swshow() {
- if [ "$sw_started" = 0 ] ; then
- echo "Error: Stopwatch not started" >&2 && return 1
- fi
-
- current_time=$(date +%s)
- elapsed_time=$((current_time - sw_start_time))
-
- if (( elapsed_time < 60 )); then
- # Display elapsed time in seconds
- echo "Elapsed time: $elapsed_time seconds"
- elif (( elapsed_time < 3600 )); then
- # Display elapsed time in minutes and seconds
- minutes=$((elapsed_time / 60))
- seconds=$((elapsed_time % 60))
- echo "Elapsed time: $minutes minutes, $seconds seconds"
- else
- # Display elapsed time in hours, minutes, and seconds
- hours=$((elapsed_time / 3600))
- minutes=$(((elapsed_time / 60) % 60))
- seconds=$((elapsed_time % 60))
- echo "Elapsed time: $hours hours, $minutes minutes, and $seconds seconds"
- fi
-}
-
-swstop() {
- swshow
- swreset
-}
-
-swstart() {
- if [ "$sw_started" = 1 ] ; then
- printf "Stopwatch is already started. Reset? (y/n): "
- read -r answer
- if [ "$answer" = "y" -o "$answer" = "Y" ]; then
- swreset
- # continue on to start the new timer
- elif [ "$answer" = "n" -o "$answer" = "N" ]; then
- echo "Stopwatch not reset."
- swshow
- # return to avoid restarting the timer
- return
- else
- echo "Error: Invalid input. Exiting." >&2 && return 1
- fi
- fi
-
- sw_started=1
- sw_start_time=$(date +%s)
- printf "Stopwatch started at %s\n\n" "$(date +"%H:%M:%S %p")"
-}