From b51ad5a371f5d1019d7ba4e5c3cb7adb77b4a9b8 Mon Sep 17 00:00:00 2001 From: Arturo Volpe Date: Sun, 29 Jan 2017 13:11:40 -0300 Subject: [PATCH 1/2] Add timetrap formatter --- timetrap/formatters/notes.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 timetrap/formatters/notes.rb diff --git a/timetrap/formatters/notes.rb b/timetrap/formatters/notes.rb new file mode 100644 index 0000000..062e89f --- /dev/null +++ b/timetrap/formatters/notes.rb @@ -0,0 +1,26 @@ +class Timetrap::Formatters::Notes + def initialize(entries) + @entries = entries + end + + def format_seconds secs + negative = secs < 0 + secs = secs.abs + formatted = "%s:%02d" % [secs/3600, (secs%3600)/60] + formatted = "-#{formatted}" if negative + formatted + end + + def output + toRet = @entries + .select{ |entry| entry[:end] == nil } + .map{ |entry| "#{entry[:note][0,8]} (#{format_seconds(entry.duration)})" } + .join(",") + + if toRet.empty? + puts 'No entries' + else + puts toRet + end + end +end From e616a499f67f5f836aad8579e8baa98627902ee0 Mon Sep 17 00:00:00 2001 From: felichas Date: Sun, 7 Oct 2018 17:14:41 +0100 Subject: [PATCH 2/2] Fix error message without actually exiting. Application was displaying error message, but continuing with the execution. --- toggle.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/toggle.sh b/toggle.sh index 07a147c..4f1013c 100644 --- a/toggle.sh +++ b/toggle.sh @@ -4,6 +4,7 @@ if [ -z "$1" ] || [ -z "$2" ] ; then echo "Usage: sh toggle.sh 'Window Title' 'Path to program'" + exit 1 fi wid=`xdotool search --name "$1"`