From d73dbf76c1c8bcd1493b73662a636bb3c9a23c20 Mon Sep 17 00:00:00 2001 From: Manvendra Bhangui Date: Sat, 30 Mar 2024 08:37:29 +0530 Subject: [PATCH] updated songi 1. display last played in days, hours, mins, secs ago 2. updated description in RPM spec and debian control --- debian/control.in | 10 ++++++++-- doc/ChangeLog | 2 ++ mpdev.spec.in | 8 +++++++- songi.in | 35 +++++++++++++++++++++++++++++------ 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/debian/control.in b/debian/control.in index 6ada088..fa37418 100644 --- a/debian/control.in +++ b/debian/control.in @@ -15,7 +15,8 @@ Description: MPD Event Watcher using mpd's idle command and execs user defined script on event changes. . * Uses mpd's idle mode. - * Calls user $HOME/bin/player + * Calls user scripts in $HOME/.mpdev (player, playpause, output, mixer, + lcd_display) * Sets special environment variables to pass data to the hooks. * Optional support for scrobbling to last.fm, libre.fm through external scripts * Included scripts: @@ -25,6 +26,11 @@ Description: MPD Event Watcher - player + saves song data to a sqlite database + tracks play count of songs, artist, albums and genres. - + helps chose songs based on listening habits using mpdplaylist + + helps choose songs based on listening habits using mpdplaylist playlist generator + synchronizes rompr, stats and mpd's sticker db + - mixer + + prints volume control value + - lcd_display + + prints song information to a host running lcdDaemon for + display on a display with Hitachi HD44780 controller diff --git a/doc/ChangeLog b/doc/ChangeLog index 0d616a5..3c09a0d 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -39,6 +39,8 @@ Release 1.1 Start 30/06/2022 End --/--/---- 20. playpause: pass RATING, PLAYCOUNT env variable to lcd_display - 04/07/2023 21. karma: added --love option to mark scrobble as loved +- 26/03/2024 +22. songi: display last played in days, hours, mins, secs ago * Thu Jun 30 2022 18:32:58 IST Manvendra Bhangui 1.0-1.1%{?dist} Release 1.0 Start 02/03/2020 End 30/06/2022 diff --git a/mpdev.spec.in b/mpdev.spec.in index f308972..61562fa 100644 --- a/mpdev.spec.in +++ b/mpdev.spec.in @@ -51,7 +51,8 @@ mpdev is a daemon, written in C, that watches a Music Player Daemon events, using mpd's idle command and execs user defined script on event changes. * Uses mpd's idle mode. - * Calls user scripts in $HOME/.mpdev (player, playpause, output) + * Calls user scripts in $HOME/.mpdev (player, playpause, output, mixer, + lcd_display) * Sets special environment variables to pass data to the hooks. * Optional support for scrobbling to last.fm, libre.fm through external scripts * Included scripts: @@ -64,6 +65,11 @@ using mpd's idle command and execs user defined script on event changes. + helps chose songs based on listening habits using mpdplaylist playlist generator + synchronizes stats and mpd's sticker db + - mixer + + prints volume control value + - lcd_display + + prints song information to a host running lcdDaemon for + display on a display with Hitachi HD44780 controller %prep %autosetup diff --git a/songi.in b/songi.in index 5afb69e..f239497 100644 --- a/songi.in +++ b/songi.in @@ -1,6 +1,9 @@ #!/bin/sh # # $Log: songi.in,v $ +# Revision 1.6 2024-03-26 19:24:12+05:30 Cprogrammer +# display last played in days, hours, mins, secs ago +# # Revision 1.5 2022-06-20 01:07:30+05:30 Cprogrammer # use directories set in ./configure # @@ -17,7 +20,7 @@ # Initial revision # # -# $Id: songi.in,v 1.5 2022-06-20 01:07:30+05:30 Cprogrammer Exp mbhangui $ +# $Id: songi.in,v 1.6 2024-03-26 19:24:12+05:30 Cprogrammer Exp mbhangui $ # get_mpd_conf_value() @@ -45,10 +48,10 @@ locate_file() display_info() { turi=`echo $1|sed -e "s{'{''{g"` - Q="SELECT play_count," - Q="$Q datetime(last_played, 'unixepoch', 'localtime')," + out=$(mktemp -t mpdevXXXXXXXXXX) + Q="SELECT title,play_count,last_played," Q="$Q rating, karma, duration," - Q="$Q artist, album, title, track, genre," + Q="$Q artist, album, track, genre," Q="$Q date, composer, performer, disc," Q="$Q datetime(date_added, 'unixepoch', 'localtime')," Q="$Q datetime(last_modified, 'unixepoch', 'localtime')" @@ -56,8 +59,28 @@ display_info() sqlite3 -noheader -line -batch $stats_file "$Q" | sed \ -e 's{.*datetime(date_added.*){ Date Added{g' \ -e 's{.*datetime(last_modified.*){Last Updated{g' \ - -e 's{.*datetime(last_played.*){ Last Played{g' \ - -e 's{ {{g' + -e 's{ {{g' > $out + t1=$(sed -n 3p < $out | awk '{print $3}') + t2=$(date +%s) + diff=$(echo $t1 $t2 | awk '{printf("%d\n", $2-$1)}') + days=$(echo $diff | awk '{printf("%d\n", $1/86400)}') + hours=$(echo $diff | awk '{printf("%d\n", ($1%86400)/3600)}') + mins=$(echo $diff | awk '{printf("%d\n", ($1%3600)/60)}') + secs=$(echo $diff | awk '{printf("%d\n", $1%60)}') + last_played="$(date --date=@"$t1")\n Last Played = $days days $hours hr $mins min $secs sec ago" + t1=$(sed -n 6p < $out | awk '{print $3}') + hours=$(echo $t1 | awk '{printf("%d\n", ($1%86400)/3600)}') + mins=$(echo $t1 | awk '{printf("%d\n", ($1%3600)/60)}') + secs=$(echo $t1 | awk '{printf("%d\n", $1%60)}') + if [ "$hours" = "0" ] ; then + duration="$mins min $secs sec ($t1)" + else + duration="$hours hr $mins min $secs sec ($t1)" + fi + sed \ + -e "s{last_played.*{Last Played = $last_played{g" \ + -e "s{duration.*{Duration = $duration{g" < $out + /bin/rm -f $out } if [ $# -eq 0 ] ; then