Skip to content

Commit

Permalink
updated mpdev
Browse files Browse the repository at this point in the history
1. create_services: create XDG_RUNTIME_DIR as /run/user/$uid
2. songi: fixed last_played when song has never been played
  • Loading branch information
mbhangui committed Jan 17, 2025
1 parent c590d55 commit a97cbe9
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 4 deletions.
8 changes: 6 additions & 2 deletions create_service.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# $Id: create_service.in,v 1.29 2023-06-30 10:16:44+05:30 Cprogrammer Exp mbhangui $
# $Id: create_service.in,v 1.30 2025-01-17 11:55:20+05:30 Cprogrammer Exp mbhangui $
#

check_update_if_diff()
Expand Down Expand Up @@ -92,7 +92,8 @@ add_service()
check_update_if_diff $servicedir/$service_name/variables/PATH "/bin:/usr/bin:@prefix@/bin:$home/.mpdev:/usr/local/bin:/opt/local/bin"
check_update_if_diff $servicedir/$service_name/variables/HOME "$home"
if [ "$SYSTEM" = "Linux" ] ; then
check_update_if_diff $servicedir/$service_name/variables/XDG_RUNTIME_DIR "$home"
t_uid=$(getent passwd $user|cut -d: -f3)
check_update_if_diff $servicedir/$service_name/variables/XDG_RUNTIME_DIR "/run/user/$t_uid"
fi
fi
mkdir -p $home/.mpdev
Expand Down Expand Up @@ -288,6 +289,9 @@ while test $# -gt 0; do
done
#
# $Log: create_service.in,v $
# Revision 1.30 2025-01-17 11:55:20+05:30 Cprogrammer
# create XDG_RUNTIME_DIR as /run/user/$uid
#
# Revision 1.29 2023-06-30 10:16:44+05:30 Cprogrammer
# added --lcdfifo argument to create LCD_FIFO env variable
#
Expand Down
3 changes: 3 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ Release 1.1 Start 30/06/2022 End --/--/----
28. karma.in: fixes for MacOS
- 23/12/2024
29. player.in: do not downgrade karma on pause song
- 17/01/2025
30. create_services: create XDG_RUNTIME_DIR as /run/user/$uid
31. songi: fixed last_played when song has never been played

* Thu Jun 30 2022 18:32:58 IST Manvendra Bhangui <[email protected]> 1.0-1.1%{?dist}
Release 1.0 Start 02/03/2020 End 30/06/2022
Expand Down
75 changes: 73 additions & 2 deletions songi.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# $Id: songi.in,v 1.7 2024-04-04 20:51:29+05:30 Cprogrammer Exp mbhangui $
# $Id: songi.in,v 1.8 2025-01-17 12:13:54+05:30 Cprogrammer Exp mbhangui $
#

get_mpd_conf_value()
Expand Down Expand Up @@ -53,12 +53,23 @@ display_info()
last_played="never"
else
t2=$(date +%s)
extra_days=0
extra_days_func $t1
diff=$(echo $t1 $t2 | awk '{printf("%d\n", $2-$1)}')
days=$(echo $diff | awk '{printf("%d\n", $1/86400)}')
years=$(expr $days / 365)
days=$(expr $days % 365)
if [ $extra_days -gt 0 ] ; then
days=$(expr $days - 1)
fi
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"
if [ $years -eq 0 ] ; then
last_played="$(date --date=@"$t1")\n Last Played = $days days $hours hr $mins min $secs sec"
else
last_played="$(date --date=@"$t1")\n Last Played = $years years $days days $hours hr $mins min $secs sec"
fi
fi
# duration
t1=$(sed -n 6p < $out | awk '{print $3}')
Expand All @@ -76,6 +87,63 @@ display_info()
/bin/rm -f $out
}

extra_days_func()
{
t1=$1
t2=$(date +%s)
y1=$(date --date="@$t1" +%Y)
m1=$(date --date="@$t1" +%m)
y2=$(date --date="@$t2" +%Y)
m2=$(date --date="@$t2" +%m)
year=$y1
first_flag=1
extra_days=0
while true
do
leap_year=0
is_century=$(expr $year % 100)
if [ $is_century -eq 0 ] ; then
is_400=$(expr $year % 400)
if [ $is_400 -eq 0 ] ; then
leap_year=1
fi
else
is_4=$(expr $year % 4)
if [ $is_4 -eq 0 ] ; then
leap_year=1
fi
fi
if [ $leap_year -eq 1 ] ; then
if [ $first_flag -eq 1 ] ; then
d1=$(date --date="@$t1" +%d)
if [ $m1 -eq 2 -a $d1 -lt 29 ] ; then
extra_days=$(expr $extra_days + 1)
elif [ $m1 -eq 1 ] ; then
extra_days=$(expr $extra_days + 1)
fi
first_flag=0
else
extra_days=$(expr $extra_days + 1)
fi
fi
if [ $year -eq $y2 ] ; then
if [ $leap_year -eq 1 ] ; then
d2=$(date --date="@$t2" +%d)
if [ $m2 -eq 2 -a $d2 -gt 28 ] ; then
extra_days=$(expr $extra_days + 1)
elif [ $m2 -gt 2 ] ; then
extra_days=$(expr $extra_days + 1)
fi
fi
break
fi
year=$(expr $year + 1)
if [ $year -gt $y2 ] ; then
break
fi
done
}

if [ $# -eq 0 ] ; then
uri=$(mpc current -f %file%)
if [ -z "$uri" ] ; then
Expand Down Expand Up @@ -131,6 +199,9 @@ do
done
#
# $Log: songi.in,v $
# Revision 1.8 2025-01-17 12:13:54+05:30 Cprogrammer
# display last played in years, days, hours, minutes, seconds
#
# Revision 1.7 2024-04-04 20:51:29+05:30 Cprogrammer
# fixed last_played when song has never been played
#
Expand Down

0 comments on commit a97cbe9

Please sign in to comment.