项目作者: Yaoir

项目描述 :
Timer, stopwatch, alarm clock, and clock programs for the command line.
高级语言: Go
项目地址: git://github.com/Yaoir/Chronograph.git
创建时间: 2018-12-30T19:45:03Z
项目社区:https://github.com/Yaoir/Chronograph

开源协议:

下载


Introduction

Chronograph is a group of four command line programs that implement functions found in a chronograph watch.

The programs are:

alarm - alarm clock

alarm

clock - time-of-day clock

clock

stopwatch - stopwatch with pause, reset, and lap functions

stopwatch

timer - countdown timer

timer

Quick Start

All of the programs are written in Go and use Cgo. They were developed on Linux and may work on macOS, but not on Windows.

In the example commands, $ is used to indicate a shell prompt.

Compile

  1. $ go build alarm.go
  2. $ go build clock.go
  3. $ go build stopwatch.go
  4. $ go build timer.go

or if you have GNU make installed:

  1. $ make

Run

  1. $ clock
  2. $ stopwatch
  3. $ timer 10s
  4. $ alarm <clock_time>

See the manual pages (included below) for details.

Installation

The included Makefile contains rules for installing the programs and manual pages. Set the variables BINDIR and MANDIR in Makefile appropriately before running one of

  1. make install

and/or

  1. make install-man

to install the programs and/or manual pages, respectively.

Using the Programs as GUI Apps

The distribution includes shell scripts alarm-gui, clock-gui, stopwatch-gui, and timer-gui as examples of how to run the programs within a virtual terminal so they act more like GUI apps. They all depend on konsole(1) for the virtual terminal. You will need to modify the scripts if you want to use another virtual terminal.

Manual Pages

  1. ALARM(1) User Commands ALARM(1)
  2. NAME
  3. alarm - alarm clock
  4. SYNOPSIS
  5. alarm time
  6. DESCRIPTION
  7. alarm(1) is a command line alarm clock. It displays the time of day
  8. until reaching the specified time.
  9. ARGUMENTS
  10. The argument specifies the time that alarm exits. The following formats
  11. may be used:
  12. Exactly on the hour:
  13. 3pm
  14. 3PM
  15. 15
  16. Exactly on the minute:
  17. 3:04pm
  18. 3:04PM
  19. 15:04
  20. Exactly on the second:
  21. 3:04:05pm
  22. 3:04:05PM
  23. 15:04:05
  24. EXAMPLES
  25. An alarm set to play an mp3 (with the command aplay alarmbell.mp3) at
  26. 2:30 pm (14:30):
  27. alarm 2:30pm && aplay alarmbell.mp3
  28. An alarm set to print "hello, world" at 9 pm (21:00):
  29. alarm 21:00 && echo "hello, world"
  30. Reminder to feed the cat at 10am:
  31. alarm 10am && echo feed the cat
  32. EXIT VALUES
  33. 0 Normal command exit (reached alarm time)
  34. 1 Quit by user (with q or Q key)
  35. 2 Quit by Control-C or SIGKILL
  36. 3 Error (bad arguments)
  37. When using alarm in loop in a shell script, use this code to have the
  38. script exit when alarm is interrupted, either with a q or Q keypress,
  39. or a Control-C or SIGKILL from another source:
  40. alarm 1pm
  41. # exit if interrupted
  42. if [ $? -ne 0 ]
  43. then
  44. exit 1
  45. fi
  46. The following causes the shell script to exit if it receives an inter
  47. rupt signal (Control-C), but if the user types a q or Q, alarm will
  48. quit early, and the loop inside the shell script will continue to exe
  49. cute:
  50. alarm 2pm
  51. # ignore user quit with q or Q key,
  52. # but exit if interrupted with SIGKILL (Control-C)
  53. if [ $? -eq 2 ]
  54. then
  55. exit 1
  56. fi
  57. BUGS
  58. The time is always shown with a 24-hour clock, even when the alarm is
  59. set with a 12-hour clock.
  60. AUTHOR
  61. Jay Ts (http://jayts.com)
  62. COPYRIGHT
  63. Copyright 2019 Jay Ts
  64. Released under the GNU Public License, version 3.0 (GPLv3)
  65. (http://www.gnu.org/licenses/gpl.html)
  66. Jay Ts June 2019 ALARM(1)
  1. CLOCK(1) User Commands CLOCK(1)
  2. NAME
  3. clock - clock
  4. SYNOPSIS
  5. clock
  6. DESCRIPTION
  7. clock(1) is a command-line clock. It displays the running wall clock
  8. time and is accurate to about 1/10 second.
  9. Type a ´q´, ´Q´, or Control-C to exit.
  10. ARGUMENTS
  11. None.
  12. EXIT VALUES
  13. 1 Quit by user (with q key)
  14. 2 Quit by Control-C or SIGKILL
  15. 3 Error (bad arguments)
  16. BUGS
  17. The time is always shown with a 24-hour clock.
  18. AUTHOR
  19. Jay Ts (http://jayts.com)
  20. COPYRIGHT
  21. Copyright 2019 Jay Ts
  22. Released under the GNU Public License, version 3.0 (GPLv3)
  23. (http://www.gnu.org/licenses/gpl.html)
  24. Jay Ts June 2019 CLOCK(1)
  1. STOPWATCH(1) User Commands STOPWATCH(1)
  2. NAME
  3. stopwatch - stopwatch
  4. SYNOPSIS
  5. stopwatch [-p]
  6. DESCRIPTION
  7. stopwatch(1) is a stopwatch that runs in a virtual terminal.
  8. It is controlled with keys on the keyboard as follows:
  9. SPACE, p, P
  10. Pause/restart the stopwatch.
  11. l, L
  12. Lap Timer. The current timing is printed, and counting continues on the following line.
  13. r, R
  14. Reset. Works only while paused.
  15. q, Q, e, E, Ctrl-C, Ctrl-D, Enter/Return
  16. Stop the stopwatch and exit.
  17. ARGUMENTS
  18. When the -p option is specified, the stopwatch starts in the paused
  19. state.
  20. EXIT VALUES
  21. 1 Quit by user (with q key)
  22. 2 Quit by Control-C or SIGKILL
  23. 3 Error (bad arguments)
  24. AUTHOR
  25. Jay Ts (http://jayts.com)
  26. COPYRIGHT
  27. Copyright 2019 Jay Ts
  28. Released under the GNU Public License, version 3.0 (GPLv3)
  29. (http://www.gnu.org/licenses/gpl.html)
  30. Jay Ts June 2019 STOPWATCH(1)
  1. TIMER(1) User Commands TIMER(1)
  2. NAME
  3. timer - countdown timer
  4. SYNOPSIS
  5. timer duration
  6. DESCRIPTION
  7. timer(1) is a countdown timer.
  8. While the timer is running, the remaining time is displayed. The com
  9. mand exits when the time remaining reaches 0.
  10. ARGUMENTS
  11. The argument specifies the duration. Some examples of valid arguments
  12. follows:
  13. 5s Five seconds
  14. 22.9s Twenty-two and 9/10 seconds
  15. 179s 179 seconds (or two minutes and 59 seconds)
  16. 7m Seven minutes
  17. 32m30s 32½ minutes
  18. 1h45m One hour and 45 minutes
  19. 2h56m4s Two hours, 56 minutes, and 4 seconds
  20. 5h Five hours
  21. 100h One hundred hours
  22. EXAMPLES
  23. Pause for 5 seconds, showing the countdown:
  24. timer 5s
  25. After 2 minutes and 30 seconds, play an mp3 (with the command aplay
  26. alarmbell.mp3):
  27. timer 2m30s && aplay alarmbell.mp3
  28. Print "hello, world" after waiting 21 minutes:
  29. timer 21m && echo "hello, world"
  30. EXIT VALUES
  31. 0 Normal command exit (timer reached 0)
  32. 1 Quit by user (with q key)
  33. 2 Quit by Control-C or SIGKILL
  34. 3 Error (bad arguments)
  35. When using timer in loop in a shell script, use this code to have the
  36. script exit when the timer is interrupted, either with a q or Q key
  37. press, or a Control-C or SIGKILL from another source:
  38. timer 600s
  39. # exit if interrupted
  40. if [ $? -ne 0 ]
  41. then
  42. exit 1
  43. fi
  44. The following causes the shell script to exit if it receives an inter
  45. rupt signal (Control-C), but if the user types a q or Q, timer will
  46. quit early, and the loop inside the shell script will continue to exe
  47. cute:
  48. timer 600s
  49. # ignore user quit with q or Q key,
  50. # but exit if interrupted with SIGKILL (Control-C)
  51. if [ $? -eq 2 ]
  52. then
  53. exit 1
  54. fi
  55. BUGS
  56. The time is always shown with a 24-hour clock, even when the duration
  57. is set with a 12-hour clock.
  58. AUTHOR
  59. Jay Ts (http://jayts.com)
  60. COPYRIGHT
  61. Copyright 2019 Jay Ts
  62. Released under the GNU Public License, version 3.0 (GPLv3)
  63. (http://www.gnu.org/licenses/gpl.html)
  64. Jay Ts June 2019 TIMER(1)