#!/bin/bash # # countdown-status # Prints how much is left until a specified time. # # Author: Jacek Mikrut (jacekmikrut.software at gmail.com) # # Copyright (c) 2012 Jacek Mikrut # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. function main() { set_default_variable_values if requested_help "$@"; then echo_help; exit 0; fi if requested_version "$@"; then echo_version; exit 0; fi read_script_arguments "$@" if data_file_exists; then if ! data_file_contains_proper_header; then echo_wrong_data_file_header exit 1 fi read_data_from_file process_data_from_file fi apply_data_from_script_arguments if needs_to_save_data; then save_data_to_file fi echo_status } function set_default_variable_values() { app_name="countdown-status" script_name="countdown-status" app_version="0.0.1" app_webpage="https://github.com/jacekmikrut/countdown-status" data_file_name=".countdown-status-data" data_file_path="$HOME/$data_file_name" data_file_header="This is a $app_name app's data file. Please do not modify it." off_message="OFF" prefix_message="" suffix_message="" time_is_up_message="Time's up!" } function requested_help() { [[ "$1" == "--help" || "$1" == "help" ]] } function requested_version() { [[ "$1" == "--version" || "$1" == "-v" ]] } function echo_help() { echo "Usage: $script_name [-