RefDnD

Miscellaneous tools
Post Reply
Message
Author
stemsee

RefDnD

#1 Post by stemsee »

refdnd follows on from work done on a previous script of a desktp file router. This version is refined and extended.

The refdnd pane has six tabs.
Tab 1 is the desktop file router dnd (drag n drop) pane. The intention here is to be able to drag a directory which has a work scene; that is a set of files that you want to work on in one session These files can be images, video, music all of these will be routed to appropriate apps (defaults or playlist for mplayer for audio/video.) Docs to libreoffice, text to geany for example, and pdf to epdfview. Just prepare driectories with the files you want to work with.

tab 2 is a dnd pane for building lists/text documents
tab 3 shows additions dropped on tab2
tab 4 is a dnd pane that routes multiple media files to playlist and also to the next refs2 tab list view
tab 5 is refs2 list which is newly created each session. Use this to edit text and drop to dnd pane 1.

tab 6 is for new lists, save lists replace refs1 with refs2 and play next entry in mplayer playlist.

There is a tray icon with rightclick menu.

A playlist opens up which gets updated as media items are added/removed.
Multiple selections can be taken from this playlist and then select 'ok', then Options > Play next track, this will open mediaplayer with this new playlist. Options > play next can then be used to return to main playlist.
Attachments
xscreenshot-20170807T120226.png
(37.97 KiB) Downloaded 182 times
xscreenshot-20170807T120240.png
(35.8 KiB) Downloaded 168 times
refdnd.tar.gz
(9.06 KiB) Downloaded 124 times
Last edited by stemsee on Mon 07 Aug 2017, 11:06, edited 2 times in total.

stemsee

#2 Post by stemsee »

removed
Last edited by stemsee on Mon 07 Aug 2017, 10:58, edited 1 time in total.

stemsee

#3 Post by stemsee »

Updated so that now tracks can be directly selected from the yad playlist window (single or multiple).

There are now two scripts one for vlc the other for mplayer systems. I should add a checkbox option to select which and thus return to a single universal script.

mplayer variant
see update
Last edited by stemsee on Thu 16 Nov 2017, 16:04, edited 2 times in total.

stemsee

#4 Post by stemsee »

see update

stemsee

#5 Post by stemsee »

refdnd - vlc version

Drag and Drop directory with media and image/doc files etc (or single files- but not dirs and single files together (Wish i knew why not)!?!).

This is working quite nicely. And any images in the dir will also be played as a slideshow on the desktop background, before re-applying default image.

This is another way to operate vlc if it is on a different display/screen from the cursor.

One weakness of this script is that you will need to edit the options string so vlc uses a specific soundcard, otherwise default will be used.

Code: Select all

#!/bin/sh 
#refdnd reference or what-have-you list builder/editor 
#by stemsee, with code from step and MochiMoppel 2016
[ /tmp/f4 ] && rm -f /tmp/f4
if [ "$1" = reset ]; then
for i in `seq 1 1 20`
do
[ /tmp/list$i ] && rm -f /tmp/list$i.m3u
[ /tmp/dirlist$i ] && 	rm -f /tmp/dirlist$i
done
killall refdnd
exit 0
fi
slyd=`busybox which yad`
[[ ! -z "$slyd" ]] && cp "$slyd" "$slyd"7
is=`mount | grep -e '/initrd/mnt/dev_save'`
si=`mount | grep -e '/initrd/mnt/dev_ro2'`

if [[ -z "$is" && ! -z "$si" ]]; then
	path=/initrd/mnt/dev_ro2
else
	path=/initrd/mnt/dev_save
fi
export path
[[ /tmp/rmyn ]] && /tmp/rmyn
lf=$HOME/refs1.txt 
lf2=$HOME/refs2.txt 
lf3=$HOME/refs3.m3u
[[ ! /tmp/mplayerpipe ]] && mkfifo -m 755 /tmp/mplayerpipe
function other1fn () { #pdf
none1=`cat /tmp/list6.m3u`
if [[ ! -z "$none1" ]]; then
	while read line
	do
		/tmp/pidf
		masterpdfeditor "$line"
		pdfpid=$!
		task=`kill $pdfpid`
		echo "#!/bin/sh
		pdfpid=$pdfpid
		$task
		rm /tmp/pidf
		" > /tmp/pidf
		chmod 755 /tmp/pidf
		sed -i "s/$line//g" /tmp/list6.m3u
	done < /tmp/list6.m3u
fi
}
export -f other1fn
function other2fn () { #word/odt
none2=`cat /tmp/list7.m3u`
if [[ ! -z "$none2" ]]; then
while read line
do
	/opt/libreoffice*/program/soffice "$line" &
	rm -f /tmp/list7.m3u
done < /tmp/list7.m3u
fi
}
export -f other2fn
function modefn (){
	mode=Stretch
	export mode
}
export -f modefn
function dslfn (){
echo /usr/share/backgrounds/default.jpg >> /tmp/list16.m3u
while read line
do
nice --40 rox --RPC << EOF
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
 <env:Body xmlns="http://rox.sourceforge.net/SOAP/ROX-Filer">
  <SetBackdrop>
   <Filename>$line</Filename>
   <Style>Stretch</Style>
  </SetBackdrop>
 </env:Body>
</env:Envelope>
EOF
conky2 -x 10 -y 10 -t "$line" -f sans:size=14 -a top_middle &
sleep 4
killall conky2
sld=`cat /tmp/list16.m3u`
[[ -z "$sld" ]] && break
done < /tmp/list16.m3u
}
export -f dslfn
function other3fn () { #images
[[ /tmp/refpids ]] && . /tmp/refpids
none3=`cat /tmp/list8.m3u`
if [[ ! -z "$none3" ]]; then
cat /tmp/list8.m3u > /tmp/list16.m3u
bash -c dslfn &
	while read line
	do
		defaultimageviewer "$line"
				rm -f /tmp/list8.m3u
		exit
	done < /tmp/list8.m3u
fi
}
export -f other3fn
function other4fn () { #media
mpm=`busybox which vlc`
mply=`echo $mpm | grep 'mplayer'`
if [[ ! -z "$mpm" ]]; then
		options='--aout=alsa --alsa-audio-device="card 1: PCH [HDA Intel PCH], device 0: ALC233 Analog"'
fi
none4=`cat /tmp/list1.m3u`
if [[ -e /tmp/f4 ]]; then
if [[ ! -z "$none4" ]]; then
	mlt=/tmp/list1.m3u
	#conky -x 20 -y 20 -t "`cat /tmp/list1.m3u`" -f sans:size=14 -a top_middle &
	#cip=$!
	pkill vlc
	vlc --loop "$mlt" "$options"
	#rm -f "$mlt"
else
	#conky -x 20 -y 20 -t "`cat /root/list1.m3u`" -f sans:size=14 -a top_middle &
	#cip=$!
	[[ -f /root/list1.m3u ]] && vlc --loop /root/list1.m3u  #"$options"
fi
#kill $cip
	rm -f /tmp/f4
fi
}
export -f other4fn
function other5fn () { #text .sh files
none5=`cat /tmp/list9.m3u`
if [[ ! -z "$none5" ]]; then
while read line
do
	defaulttexteditor "$line"
done <  /tmp/list9.m3u
	rm -f /tmp/list9.m3u
fi
}
export -f other5fn
function other6fn () { #html files
[[ /tmp/refpids ]] && . /tmp/refpids
none6=`cat /tmp/list10.m3u`
if [[ ! -z "$none6" ]]; then
	defaultbrowser "`cat /tmp/list10.m3u | tr '\n' ' '`"
	rm /tmp/list10.m3u
fi
}
export -f other6fn
function other7fn () {
if [[ /tmp/list11.m3u ]]; then
	while read line
	do
		wine -e "$line" &
		sed -i "s/$line//g" /tmp/list11.m3u
	done < /tmp/list11.m3u
fi
}
export -f other7fn
function other8fn () {
none8=`cat /tmp/list12.m3u`
if [[ ! -z "$none8" ]]; then

	while read line
	do
		qjackctl -s 2> /dev/null &
		hydrogen -s "$line" &
		sed -i "s/$line//g" /tmp/list12.m3u
	done < /tmp/list12.m3u
fi
}
export -f other8fn
function other9fn () {
if [[ /tmp/list13.m3u ]]; then
	while read line
	do
		/opt/Ardour*/bin/ardour[1-19] -E "$line" &
		sed -i "s/$line//g" /tmp/list13.m3u
	done < /tmp/list13.m3u
fi
}
export -f other9fn
function other10fn () {
if [[ /tmp/list14.m3u ]]; then
	while read line
	do
		cp -f "$line" "$path"/FatHouse/zdrv_FatHouse64-S.sfs &
		sed -i "s/$line//g" /tmp/list14.m3u
	done < /tmp/list14.m3u
fi
}
export -f other10fn
function mplist () {
	./tmp/mplst
	killall yad7
	none4=`cat /tmp/list1.m3u`
	if [[ ! -z "$none4" ]]; then
		lfp=/tmp/list1.m3u
	else
		lfp=/root/list1.m3u
	fi
	tail -n 10000 "$lfp" | awk '{fflush();print;fflush()}' | rev | cut -f1 -d'/' | rev \
	| yad7 --window-icon="/usr/share/pixmaps/leafpad.png" --on-top  --title="Play List" \
	--dclick-action="bash -c control" --geometry=180x380-140+200 --list \
	--multiple --column="PlayList" | cut -f1 -d'|' > /tmp/dirlist8 &
	pid1=$!
	task='kill $mpid'
	echo "#!/bin/sh
	mpid=$pid1
	$task
	rm -f /tmp/mplst
	" > /tmp/mplst
	chmod 755 /tmp/mplst
	algo=`cat /tmp/dirlist8`
	if [[ ! -z "$algo" ]]; then
		killall vlc
		bash -c control
	fi
	exit 0
}
export -f mplist
bash -c mplist
function mediap () {
	lf3=$HOME/refs3.m3u
    STUFFMP="${0//file:\/\//}"
	printf %s\\\n "$STUFFMP" | awk '{fflush();print;fflush()}' | grep -e '.mov' -e \
	'.MP4' -e '.MP3' -e '.MPG' -e '.MOV' -e '.AVI' -e '.mpg' -e '.mpeg' -e '.mp3' -e '.mp4' -e \
	'.vob' -e '.avi' -e '.mkv'  -e '.flac' -e '.aac' -e '.wav' -e '.flv' -e '.ogg' -e '.3gp' -e '.dat' >> /tmp/list1.m3u
	printf %s\\\n "$STUFFMP" | awk '{fflush();print;fflush()}' >> $lf3
	[[ -f /tmp/vlcflag ]] && rm -f /tmp/vlcflag
	while read line #filter off dir lines
	do
	if [[ -d "$line" ]]; then
		ls "$line"/*/*/*/*/*/* > /tmp/dirlist1
		ls "$line"/*/*/*/*/* > /tmp/dirlist2
		ls "$line"/*/*/*/* > /tmp/dirlist3
		ls "$line"/*/*/* > /tmp/dirlist4
		ls "$line"/*/* > /tmp/dirlist5
		ls "$line"/* > /tmp/dirlist6
		sed -i "s/^/$line/g" /tmp/dirlist*
	fi
		sed -i "s/$line//g" "$lf3"
		for i in 1 2 3 4 5 6
		do
			while read line
			do
			chk=`cat /tmp/dirlist | grep "$line"`
			if [[ -z "$chk" ]]; then
				echo "$line" | awk '{fflush();print;fflush()}' >> /tmp/dirlist
			fi
			done < /tmp/dirlist$i
			rm -f /tmp/dirlist$i
		done
		sed -i "s/^/$line/g" /tmp/dirlist
	done < "$lf3"
	spawn=`cat /tmp/list1.m3u`
while read it #route lines by extension to lists
do
case "$it" in
	*.m4v|*.M4V|*.swf|*.SWF|*.flv|*.FLV|*.WMV|*.wmv|*.ogg|*.OGG|*.3GP|*.dat|*.DAT |*.3gp|*.mp3|*.mp4|*.MP4|*.VOB|*.AVI|*.mpg|*.MPG|*.mpeg\
	|*.MPEG|*.avi|*.vob|*.MKV|*.mkv|*.wav|*.WAV|*.pcm|*.PCM|*.flac|*.FLAC|*.wma|*.WMA|*.m4a|*.M4A|*.MP3|*.mov|*.MOV) echo "$it" \
	| awk '{fflush();print;fflush()}' >> /tmp/list1.m3u;; #for defaultmediaplayer list
	*.xml|*.XML|*.doc|*.DOC|*.docx|*.DOCX|*.odg|*.ODG|*.odt|*.ODT|*.odf|*.ODF) echo "$it" | awk '{fflush();print;fflush()}' >> /tmp/list7.m3u;; #defaultwordprocessor list
	*.pdf|*.PDF) echo "$it" >> /tmp/list6.m3u;; #defaultpdfviewer list
	*.jpg|*.JPG|*.png|*.PNG|*.bmp|*.BMP) echo "$it" | awk '{fflush();print;fflush()}' >> /tmp/list8.m3u;; #defaultimageviewer list
	*.html|*.htm|*.com|*.co.uk|*.org|*.ac.uk|www.*|ftp*|http*) echo "$it" | awk '{fflush();print;fflush()}' >> /tmp/list10.m3u;;
	*.exe|*.msi) echo "$it" | awk '{fflush();print;fflush()}' >> /tmp/list11.m3u;;
	*.h2song) echo "$it" | awk '{fflush();print;fflush()}' >> /tmp/list12.m3u;;
	*.ardour) echo "$it" | awk '{fflush();print;fflush()}' >> /tmp/list13.m3u;;
	*.aup|*.AUP) echo "$it" | awk '{fflush();print;fflush()}' >> /tmp/list15.m3u;;
	*.sfs) echo "$it" | awk '{fflush();print;fflush()}' >> /tmp/list14.m3u;;
	*) file "$it" | grep -e 'ASCII' | cut -f1 -d ':' | awk '{fflush();print;fflush()}' >> /tmp/list9.m3u;; #default text/script editor
esac
sed -i "s/$it//g" /tmp/dirlist
done < /tmp/dirlist
rm -f "$lf3"
rm -f /tmp/dirlist
		cat /tmp/list1.m3u > /tmp/list0.m3u
		sed 's/#####:TM.*//' /tmp/list0.m3u > /tmp/list1.m3u
	other2fn &
	other3fn &
	if [[ ! -f /tmp/f4 ]] ; then
		touch /tmp/f4
		other4fn &	
	fi
	other5fn &
	other6fn &
	other7fn &
	other8fn &
	other9fn &
	other10fn &
	if [[ -z "$spawn" ]]; then
		mply=`busybox which mplayer`
		#mply=`echo $mpm | grep -e 'mplayer'`
		mpm=`busybox which vlc`
		#if [[ -z "$mpm" ]]; then
		#defaultmediaplayer=mplayer
			#options=" -slave -input file=/tmp/mplayerpipe -playlist "
		if [[ ! -z "$mpm" ]]; then
			defaultmediaplayer="vlc --loop"
			options='--aout=alsa --alsa-audio-device="card 1: PCH [HDA Intel PCH], device 0: ALC233 Analog"'
		fi
		sleep 1
	fi
	check=`cat /tmp/list1.m3u`
	if [[ -z "$check" ]]; then
		rm -f /tmp/list1.m3u
	fi
	if [[ -f /tmp/vlcflag ]]; then
		exit 0
	fi
	bash -c mplist
	#killall vlc
	[[ ! -f /tmp/vlcflag ]] && touch /tmp/vlcflag
	[[ ! -f /tmp/vlcflag ]] && vlc /tmp/list1.m3u "$options"
	sed -i '1d' "$lfp"
	rm -f /tmp/vlcflag
	if [[ ! -e /tmp/flag ]]; then
		other1fn &
		touch /tmp/flag
	fi
	exit 0
}
export -f mediap
function control () {
	#bash -c mplist &
	lfp=/tmp/list1.m3u
	pmp=`cat /tmp/dirlist8`
	rm -f /tmp/dirlist8
[[ ! -z "$pmp" ]] && grep "$pmp"  /tmp/list1.m3u > /tmp/dirlist9.m3u
	sed 's/#####:TM.*//' "$lfp" > /tmp/format
	cat /tmp/format > "$lfp"
	rm -f /tmp/format
		mply=`busybox which mplayer`
		mpm=`busybox which vlc`
		if [[ ! -z "$mpm" ]]; then
			defaultmediaplayer="vlc --loop"
			options='--aout=alsa --alsa-audio-device="card 1: PCH [HDA Intel PCH], device 0: ALC233 Analog"'
		fi
	if [[ ! -z "$pmp" ]]; then
		mlt=/tmp/dirlist9.m3u
	else
		mlt=/tmp/list1.m3u
	fi
	[[ "$mlt" = /tmp/list1.m3u ]] && sed -i '1d' "$mlt"
	killall vlc
	sleep 1
	check=`cat /tmp/list1.m3u`
	if [[ -z "$check" && -z "$pmp" ]]; then
		rm -f /tmp/vlcflag
		bash -c mplist
		[[ -e /tmp/f4 ]] && rm -f /tmp/f4
		[[ -f /root/list1.m3u ]] && vlc --loop /root/list1.m3u #"$options"
		exit 0
	fi
	if [[ ! -z "$pmp" ]]; then
		mlt=/tmp/dirlist9.m3u
	else
		mlt=/tmp/list1.m3u
	fi
	bash -c mplist
	vlc --loop "$mlt" #"$options"
	exec /tmp/mplst &
exit 0
}
export -f control
function newplist () {
	rm -f /tmp/list*.m3u
	rm -f /tmp/dirlist
	rm -f ~/refs3.m3u
	rm -f /tmp/f4
	rm -f /root/list1.m3u
	bash -c mplist
exit 0
}
export -f newplist
function editor () { 
mv /tmp/xyp /tmp/pyx 
lf=$HOME/refs1.txt 
lf2=$HOME/refs2.txt 
[[ "$lf2" ]] && mv "$lf2" "$lf" 
refdnd & 
sleep 1 
/tmp/pyx 
} 
export -f editor 
function dostuff { 
    lf2=$HOME/refs2.txt 
    STUFF="${0//file:\/\//}" 
	printf %s\\\n "$STUFF" >> "$lf2"
#	conky -x 700 -y 400 -t "`printf %s\\\n $STUFF | tr ' ' '\n'`" -f sans:size=14 -a top &
} 
export -f dostuff 
function edit () {
	geany /tmp/list1.m3u
}
export -f edit
function save () { 
fix=$(date | awk '{print $3,$2,$4}') 
cp -f ~/refs1.txt ~/$fix-refs1.txt
cp -f  ~/refs2.txt ~/$fix-refs2.txt
cp -f /tmp/list1.m3u /root/list1.m3u
} 
export -f save 
function blank () {
lf=$HOME/refs1.txt 
lf2=$HOME/refs2.txt
mv /tmp/xyp /tmp/pyx 
rm -f "${lf}" 
rm -f "${lf2}" 
touch "${lf}" 
touch "${lf2}"
refdnd & 
sleep 1 
/tmp/pyx 
} 
export -f blank
if [ ! -f /tmp/rmyn ]; then
	yad --image /usr/share/pixmaps/dndmplayer.png \
	--text "End dndwidget" \
	--notification \
	--menu="New Session!rm -f /tmp/flag!/usr/share/pixmaps/document-open-folder.png|Stop play!killall vlc!/usr/share/pixmaps/dndmplayer.png\
	|Reset lists!refdnd reset!/usr/share/pixmaps/close.png|Reset Playlist!bash -c newplist!/usr/share/pixmaps/leafpad.png\
	|View playlist!bash -c mplist!/usr/share/pixmaps/leafpad.png\
	|Edit playlist!bash -c edit!/usr/share/pixmaps/leafpad.png|Close Tray!/tmp/rmyn!/usr/share/pixmaps/closer.png" \
	--command="refdnd" &
	note=$!
	task='kill $yadn'
	echo "#!/bin/sh
	yadn=$note
	$task
	rm -f /tmp/rmyn
	" > /tmp/rmyn
	chmod 755 /tmp/rmyn
fi
yad --plug=$$ --tabnum=2 --text="Drag-n-drop items/text here\nThey will be added to\n/root/refs1.txt list\n---" \
--dnd --command "bash -c 'printf %s\\\\n \"\${0//file:\/\//}\"'" >> "$lf" & 
yp=`echo $$` 
echo $$ 
task='kill $pid' 
echo "#!/bin/sh 
yp=$yp 
for pid in "`seq $((yp + 10)) 1 $((yp + 30))`" 
do 
$task 
done 
" > /tmp/xyp 
chmod 755 /tmp/xyp
tail -n 1000 -f "$lf" | awk '{fflush();print;fflush()}' | yad --plug=$$ --tabnum=3 --editable --listen --tail --text-info & 
yad --plug=$$ --tabnum=4 --text="Drag-n-drop edits from refs1\nOr refs2 / any source\nThey will create /root/refs2.txt\n---\n" \
--dnd --command "bash -c dostuff" > "$lf2" & 
yad --plug=$$ --tabnum=6 --form --field="Replace refs1 with refs2:fbtn" "bash -c editor" \
--field="'Start New' refs lists:fbtn" "bash -c blank" --field="Save Refs/Plist by date in /root:fbtn" "bash -c save"\
 --field="Play/Next Track:fbtn" "bash -c control" & 
tail -f "$lf2" | awk '{fflush();print;fflush()}' | yad --plug=$$ --tabnum=5 --editable --listen --tail --text-info &
yad --plug=$$ --tabnum=1 \
--text="\n This is a file router.

 Prepare a directory with links/files
 DragNDrop directory here\n Files will be routed to apps
 
 Media gets added to /tmp/list1.m3u\n Playlist opened by VLC media player" \
--listen --dnd --command "bash -c mediap" &
yad --window-icon=/usr/share/pixmaps/leafpad.png --geometry=80x80-80+280 \
--no-buttons --on-top --notebook --key=$$ --title="D'n'D Ref-lists & PlayMedia" \
--command "kill $YAD_PID" --tab="Player" --tab="DnD1" --tab="refs1" --tab-pos=bottom --tab="DnD2" --tab="refs2" --tab="Save" &

stemsee

#6 Post by stemsee »

Tidy up
Attachments
refdnd.fake.gz
(12.69 KiB) Downloaded 158 times

Post Reply