Project

General

Profile

audacious-sidmon.sh

Script to run instead of audacious that will advance SID playback - Daniel Bedrenko, November 03, 2014 20:00

 
1
#!/bin/bash
2

    
3
/usr/bin/audacious -t &>> $HOME/tmp/audacious-out.log &
4

    
5
# Desired length SIDs should play for, in seconds
6
SONG_LENGTH=80
7

    
8
# How often the monitor should check the state of the player
9
MONITOR_FREQ=20
10

    
11
# If Audacious already running, toggle play and exit this script.
12
CUR_FILE="`audtool --current-song-filename`"
13
if [[ "$CUR_FILE" != 'No song playing.' ]]; then
14
	exit 0
15
fi
16

    
17
# Var holds whether audacious is running or not
18
IS_RUNNING=1
19

    
20
until [[ $IS_RUNNING -ne 1 ]]; do
21

    
22
	echo 'sleeping...'
23
	sleep $MONITOR_FREQ
24

    
25
	# Get currently played filename and determine it's extension
26
	CUR_FILE="`audtool --current-song-filename`"
27
	CUR_FILE_EXT="${CUR_FILE##*.}"
28

    
29
	# In case of multi-track SIDs, whose filenames show up with '?'s in Audacious
30
	CUR_FILE_EXT="${CUR_FILE_EXT%%\?*}"
31

    
32
	# If SID file has played over the specified song length limit, 
33
	# advance playlist
34
	if [[ $CUR_FILE_EXT == 'sid' ]]; then
35
		SECS_PLAYED="`audtool --current-song-output-length-seconds`"
36
		echo $SECS_PLAYED
37
		if [[ $SECS_PLAYED -gt $SONG_LENGTH ]]; then
38
			audtool --playlist-advance
39
		fi
40
	fi
41

    
42
	# Check if audacious is still running
43
	if [[ "$CUR_FILE" == 'No song playing.' ]]; then
44
		IS_RUNNING=0
45
	fi
46
done