#!/bin/bash
#                       /usr/local/bin/mixxxing
#  http://crystalfaeries.net/posix/bin/mixxxing
# celeste:crystalfaery 2016-08-15 06:33:57+00:00
# List which files are open in mixxx
# (either being played or queued to play next)
# because for the currently playing song,
# while mixxx does show the file metadata,
# it provides no way to discover the file path/name
# or to delete the file, therefore, this yields
# the necessary file handle with which to delete
# the currently playing song.

# This is launched by user cronjob on reboot:
# @reboot	/usr/local/bin/mixxxing

# and watched by watchlogs by doing this:
# echo /var/log/mixxxing.log >> ~/.monitor.txt
# watchlogs

# and logrotate via /etc/logrotate.d/mixxxing
#	/var/log/mixxxing.log {
#		daily
#		missingok
#		rotate 32
#		compress
#		notifempty
#	}

# CONFIGURATION
library=/home/raid/audio	# where did we configure mixxx's library?

while sleep 1m
do
	for file in $(lsof -u `whoami` -l -n | grep mixxx | sed 's/^.* //g' | grep ${library} | sort -u)
	do
		grep "${file}" /var/log/mixxxing.log > /dev/null
		if [ $? -ne 0 ]
			then echo "`/usr/local/bin/now`	${file}" >> /var/log/mixxxing.log
		fi
	done
done


syntax highlighted by Code2HTML, v. 0.9.1