From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 208.118.235.0/24 X-Spam-Status: No, score=-2.3 required=3.0 tests=AWL,BAYES_00, RCVD_IN_DNSWL_BLOCKED shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: dtas-all@80x24.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 37C641FA5D for ; Tue, 19 May 2015 08:18:39 +0000 (UTC) Received: from localhost ([::1]:44386 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YucjW-0005g6-Bi for dtas-all@80x24.org; Tue, 19 May 2015 04:18:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60665) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YucjU-0005fq-4G for dtas-all@nongnu.org; Tue, 19 May 2015 04:18:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YucjP-0004ZJ-Mw for dtas-all@nongnu.org; Tue, 19 May 2015 04:18:36 -0400 Received: from dcvr.yhbt.net ([64.71.152.64]:49395) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YucjP-0004Yq-Gf for dtas-all@nongnu.org; Tue, 19 May 2015 04:18:31 -0400 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C7F071FA5C; Tue, 19 May 2015 08:18:29 +0000 (UTC) From: Eric Wong To: Subject: [PATCH] dtas-console: bind "o" to display time in absolute seconds Date: Tue, 19 May 2015 08:18:28 +0000 Message-Id: <1432023508-2539-1-git-send-email-e@80x24.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 64.71.152.64 Cc: Eric Wong X-BeenThere: dtas-all@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dtas-all-bounces+dtas-all=80x24.org@nongnu.org Sender: dtas-all-bounces+dtas-all=80x24.org@nongnu.org It can be useful to display time as absolute seconds to ease arithmetic for tracking files. --- Documentation/dtas-console.txt | 1 + bin/dtas-console | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Documentation/dtas-console.txt b/Documentation/dtas-console.txt index 55b0bde..2547036 100644 --- a/Documentation/dtas-console.txt +++ b/Documentation/dtas-console.txt @@ -33,6 +33,7 @@ Key bindings are inspired partially by mplayer(1) - 'f'/'F' - decrease/increase ReplayGain fallback_gain value - 'r'/'R' - cycle forward/backwards through ReplayGain modes - 'q'/Ctrl-C - exit dtas-console +- 'o' - toggle display between HH:MM:SS and absolute seconds # ENVIRONMENT diff --git a/bin/dtas-console b/bin/dtas-console index 9fa4d09..a98244b 100755 --- a/bin/dtas-console +++ b/bin/dtas-console @@ -14,6 +14,7 @@ rescue LoadError abort "please install the 'curses' RubyGem to use #$0" end +tsec = false se = DTAS::Sigevent.new trap(:WINCH) { se.signal } w = DTAS::UNIXClient.new @@ -30,8 +31,12 @@ else rg_mode_i = 0 end -def update_tfmt(prec) - prec == 0 ? '%H:%M:%S' : "%H:%M:%S.%#{prec}N" +def update_tfmt(prec, tsec) + if tsec + prec == 0 ? '%_8s' : "%_8s.%#{prec}N" + else + prec == 0 ? '%H:%M:%S' : "%H:%M:%S.%#{prec}N" + end end trap(:INT) { exit(0) } trap(:TERM) { exit(0) } @@ -40,7 +45,7 @@ trap(:TERM) { exit(0) } prec_nr = 1 prec_step = (0..9).to_a prec_max = prec_step.size - 1 -tfmt = update_tfmt(prec_step[prec_nr]) +tfmt = update_tfmt(prec_step[prec_nr], tsec) events = [] interval = 1.0 / 10 ** prec_nr @@ -209,6 +214,7 @@ begin when "<" then c.req_ok("tl prev") when "!" then may_fail(c.req("cue prev"), events) when "@" then may_fail(c.req("cue next"), events) + when "o" then tfmt = update_tfmt(prec_step[prec_nr], tsec = !tsec) when " " c.req("play_pause") when "r" # cycle through replaygain modes @@ -219,13 +225,13 @@ begin when "p" # lower precision of time display if prec_nr >= 1 prec_nr -= 1 - tfmt = update_tfmt(prec_step[prec_nr]) + tfmt = update_tfmt(prec_step[prec_nr], tsec) interval = 1.0 / 10 ** prec_nr end when "P" # increase precision of time display if prec_nr < prec_max prec_nr += 1 - tfmt = update_tfmt(prec_step[prec_nr]) + tfmt = update_tfmt(prec_step[prec_nr], tsec) interval = 1.0 / 10 ** prec_nr end when 27 # TODO readline/edit mode? -- EW