Lirc

Aus Digiwiki

Wechseln zu: Navigation, Suche

Inhaltsverzeichnis

Lirc allgemein

Ich habe mir nun doch einen billigen USB IR Empfänger (IRDA!=IR Empfänger im Wellenbereich von Standartfernbedienungen) gekauft,also mangels eines Seriellen Ports mir keinen selbst gebaut. Für diejenigen, die noch Computer mit Seriellem Port verwenden: Es finden sich haufenweise einfache Anleitungen zum Bau serieller IR-Empfänger im Internet.

Egal für welchen IR Empfänger/Sender man sich entscheidet: an LIRC (Linux Infra Red Control) führt wohl kein Weg vorbei. Mit Lirc lassen sich Programme starten, steuern (direct (mplayer) oder indirect (z.B. amarok über dcop)) und Lirc kann sogar als Mouse Interface funktionieren. Bis auf letzteres geht das ganze problemlos mit fast jeder Fernbedienung.

Lirc installieren

Source Code bekommt man auf der lirc Seite. Oder über CVS mit

cvs -z8 -d:pserver:anonymous@lirc.cvs.sourceforge.net:/cvsroot/lirc co lirc

Nach Anleitung ( http://www.lirc.org/cvs.html ):

cd lirc
./autogen.sh
./setup.sh

Treiber auswählen (Der Treiber den mein USB-IR Stick verwendet nennt sich lirc_igorplugusb)

make
sudo make install

...testen und einrichten: http://www.lirc.org/html/install.html#testing

Probleme

Alle Events doppelt

Lirc sendet bei mir jeden Event doppelt. Sowohl bei irecord, irexec, als auch irw. In Lirc habe ich keine Lösung gefunden, allerdings ignoriere ich mit Bash (in /etc/lircrc) einfach alle identischen events innerhalb einer gewissen Zeitspanne nach jedem Tastendruck

Device heißt /dev/lirc0 statt /dev/lirc

Wie schon der der Titel andeutet, heißt das bereitgestellte Device /dev/lirc0 statt /dev/lirc. Das hat die Auswirkung, dass lircd abstürzt beim Zugriff von z.B. irexec. Das richtige Device in die /etc/lirc/hardware.conf einzutragen hat bei mir nicht funktioniert. Also muss lircd bei mir jedes mal mit lircd -d /dev/lirc0 gestartet werden

EigeneKonfiguration

Thinkpad als Stereoanlage
Thinkpad als Stereoanlage

Tatatataaa:

Der I(BM) Pott Shuffle - natürlich mit Fernbedienung

/etc/lircd.conf

für meine Sony Fernbedienungen RM-S103 und RM-D720 (File auf der Lirc Seite für RM-S103 hat nur teilweise funktioniert)

begin remote

  name RM-S103
  bits           12
  flags SPACE_ENC
  eps            30
  aeps          100

  header       2411   496
  one          1297   501
  zero          699   501
  gap          44993
  toggle_bit_mask 0x0

      begin codes
	  power                   0xA81
          surround                0xFC6
          muting                   0x281
          dbfb                    0x8C6
          cd>>                    0x8D1
          cd<<                    0x0D1
          cd>                     0xA41
          cd_stop                  0x1D1
          tuner+                  0x096
          tuner-                  0x896
          shift                   0xCD6
          dskip                   0x7D1
          tapeb<<                 0xD8E
          tapeb>>                 0x38E
          tapeb_pause             0x98E
          tapeb<                  0xC41
	  tapea_stop               0x1C1
          tapea>                   0xC41
          tapea<                   0xC41
          tapea>>                  0x2C1
          tapea<<                  0xCC1
	  dat                         0x621
	  tapeb_stop               0x18E
	  tapeb_rec                0x78E
      end codes

end remote

begin remote
  name  RM-D720
  bits           11
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       2362   635
  one          1163   635
  zero          564   635
  ptrail       1163
  gap          44970
  toggle_bit      0

      begin codes
          CONTINUE                 0x5C8
          SHUFFLE                  0x568
          PROGRAM                  0x7C8
          1                        0x008
          2                        0x408
          3                        0x208
          4                        0x608
          5                        0x108
          6                        0x508
          7                        0x308
          8                        0x708
          9                        0x088
          >10                      0x728
          10                       0x028
          CLEAR                    0x788
          TIME                     0x0A8
          CHECK                    0x588
          REPEAT                   0x1A8
          A<->B                    0x2A8
          FADER                    0x7D8
          PLAY                     0x268
          PAUSE                    0x4E8
          STOP                     0x0E8
          SEEK_PREV                0x068
          SEEK_NEXT                0x468
          +                        0x248
          SEEK_BACK                0x668
          SEEK_FWD                 0x168
          -                        0x648
      end codes

end remote

/etc/lircrc

/etc/lircrc for use with my irexec_scripts_amarok

# lircrc
#########################################################
####           RM-S103
#########################################################
begin
    prog = irexec
    remote = RM-S103
    button = tapeb_stop
    config =  echo "tapeb_stop pressed"; irexec_scripts_amarok -clear &
    repeat = 100000000
    delay=100000000
end
begin
    prog = irexec
    remote = RM-S103
    button = muting
    config =  echo "muting pressed"; irexec_scripts_amarok -pause &
    repeat = 100000000
    delay=100000000
end
begin
    prog = irexec
    remote = RM-S103
    button = cd>
    config =  echo "cd_play pressed"; irexec_scripts_amarok -play &
    repeat = 100000000
    delay=100000000
end
begin
    prog = irexec
    remote = RM-S103
    button = cd>>
    config =  echo "cd>> pressed";irexec_scripts_amarok -next &
    repeat = 10
    delay=5
end
begin
    prog = irexec
    remote = RM-S103
    button = cd<<
    config = echo "cd<< pressed";irexec_scripts_amarok -prev &
    repeat = 10
    delay=5
end
begin
    prog = irexec
    remote = RM-S103
    button = cd_stop
    config =  echo "cd_stop pressed"; irexec_scripts_amarok -stop &
    repeat = 100000000
    delay=100000000
end
begin
    prog = irexec
    remote = RM-S103
    button = dskip
    config = echo "dskip pressed";irexec_scripts_amarok -shuffle &
    repeat = 100000000
    delay=100000000
end
begin
    prog = irexec
    remote = RM-S103
    button = tapeb_rec
    config = echo "tapeb_rec pressed";irexec_scripts_amarok -add-random &
    repeat = 100000000
    delay=100000000
end
begin
    prog = irexec
    remote = RM-S103
    button = tapeb_pause
    config = echo "tapeb_pause pressed";irexec_scripts_amarok -add-latest &
    repeat = 100000000
    delay=100000000
end
begin
    prog = irexec
    remote = RM-S103
    button = dbfb
    config = echo "dbfb pressed";irexec_scripts_amarok -add-more-from-artist &
    repeat = 100000000
    delay=100000000
end
begin
    prog = irexec
    remote = RM-S103
    button = surround
    config =echo "surround pressed";irexec_scripts_amarok -read-track &
    repeat = 100000000
    delay=100000000
end

#########################################################
####           RM-D720
#########################################################
begin
    prog = irexec
    remote = RM-D720
    button = CLEAR
    config =  echo "CLEAR pressed on remote 2"; irexec_scripts_amarok -clear &
    repeat = 100000000
    delay=100000000
end
begin
    prog = irexec
    remote = RM-D720
    button = PAUSE
    config =  echo "PAUSE pressed on remote 2"; irexec_scripts_amarok -pause &
    repeat = 100000000
    delay=100000000
end
begin
    prog = irexec
    remote = RM-D720
    button = PLAY
    config =  echo "PLAY pressed on remote 2"; irexec_scripts_amarok -play &
    repeat = 10
    delay=5
end
begin
    prog = irexec
    remote = RM-D720
    button = SEEK_NEXT
    config =  echo "SEEK_NEXT pressed on remote 2";irexec_scripts_amarok -next &
    repeat = 10
    delay=5
end
begin
    prog = irexec
    remote = RM-D720
    button = SEEK_PREV
    config = echo "SEEK_PREV pressed on remote 2";irexec_scripts_amarok -prev &
    repeat = 10
    delay=5
end
begin
    prog = irexec
    remote = RM-D720
    button = SEEK_FWD
    config =  echo "SEEK_FWD pressed on remote 2";irexec_scripts_amarok -forward &
    repeat = 10
    delay=5
end
begin
    prog = irexec
    remote = RM-D720
    button = SEEK_BACK
    config = echo "SEEK_BACK pressed on remote 2";irexec_scripts_amarok -back &
    repeat = 10
    delay=5
end
begin
    prog = irexec
    remote = RM-D720
    button = +
    config =  echo "SEEK_FWD pressed on remote 2";irexec_scripts_amarok -vol+ &
    repeat = 10
    delay=5
end
begin
    prog = irexec
    remote = RM-D720
    button = -
    config = echo "SEEK_BACK pressed on remote 2";irexec_scripts_amarok -vol- &
    repeat = 10
    delay=5
end
begin
    prog = irexec
    remote = RM-D720
    button = STOP
    config =  echo "STOP pressed on remote 2"; irexec_scripts_amarok -stop &
    repeat = 100000000
    delay=100000000
end
begin
    prog = irexec
    remote = RM-D720
    button = TIME
    config =  echo "TIME pressed on remote 2"; irexec_scripts_amarok -bedtime &
    repeat = 100000000
    delay=100000000
end
begin
    prog = irexec
    remote = RM-D720
    button = SHUFFLE
    config = echo "SHUFFLE pressed on remote 2";irexec_scripts_amarok -shuffle &
    repeat = 100000000
    delay=100000000
end
begin
    prog = irexec
    remote = RM-D720
    button = REPEAT
    config = echo "REPEAT pressed on remote 2";irexec_scripts_amarok -repeat &
    repeat = 100000000
    delay=100000000
end
begin
    prog = irexec
    remote = RM-D720
    button = PROGRAM
    config = echo "PROGRAM pressed on remote 2";irexec_scripts_amarok -add-random &
    repeat = 100000000
    delay=100000000
end
begin
    prog = irexec
    remote = RM-D720
    button = CONTINUE
    config = echo "CONTINUE pressed on remote 2";irexec_scripts_amarok -add-latest &
    repeat = 100000000
    delay=100000000
end
begin
    prog = irexec
    remote = RM-D720
    button = A<->B
    config = echo "A<->B pressed on remote 2";irexec_scripts_amarok -add-more-from-artist &
    repeat = 100000000
    delay=100000000
end
begin
    prog = irexec
    remote = RM-D720
    button = CHECK
    config =echo "surround pressed on remote 2";irexec_scripts_amarok -read-track &
    repeat = 100000000
    delay=100000000
end


Amarok remote script

Ein Script, dass ich zur Fernsteuerung von Amarok geschrieben habe (liegt bei mir unter /usr/local/bin/irexec_scripts_amarok )

Anmerkungen: -dieser Code ist ausschließlich in übernächtigten Zustand entstanden,was eine Vorahnung auf die Qualität geben dürfte. -es war nicht beabsichtigt, dass dieses Script mal mehr als 30 Zeilen lang wird, sonst hätte ich es sicher nicht in Bash geschrieben.

#!/bin/bash
#The Idea for using Festival was Taken from the Amarok lircd page. My code can be regarded as Public Domain.
#
#I didn't expect the script to get that big. If I had, I wouldn't have used bash for writing it.
#
#For those who want to extend the script some additional Information:
#
#1. I use a Semaphore File for every use of festival while Amarok is playing.
#   This prevents the audience from voice gibberish, and furthermore the volume gets restored to the correct value
#
#2. Lirc Recognizes events multiple times. I didn't find a way to stop that in lirc, so I hat to do it in this Script.
#   The time when valid event is produced, is stored in a different File for every Event.
#
#3. Amarok offers a lot of features using the dcop interface.
#   Sadly adding Tracks from your collection isn't directly a part of that.
#   I use "dcop amarok collection query" to ask the database (SQLite) to return the tracks I want
#   (like more from the same artist, random tracks, or newest tracks).
#   The SQLite Syntax should AFAIK be Part of any other SQL Syntax.
#
#4. If you happen to make changed that improve the Features, Code, ... whatever in this script, feel free to contact me.
#
# Author: Roland Plass
### Mail: stuff@digitalhalo.de
#### Web: wiki.digitalhalo.de
#########################################################################################################################


tmpdir="/tmp/irexec-$(whoami)/"

#festival requires package festival from debian. festivalsay is an own script than changes the reader and voice volume
voice_out_cmd="festivalsay";
voice_semaphore=$tmpdir"lirc_amarok_voice_semaphore";

#ogg123 requires package music123 in Debian
tracks_added_sound_cmd="ogg123 /usr/share/sounds/KDE_Dialog_Appear.ogg"
shuffle_sound_cmd="ogg123 /usr/share/sounds/KDE_Chimes_3.ogg"
clear_playlist_cmd="ogg123 /usr/share/sounds/KDE_Dialog_Disappear.ogg"


if [ ! -e $tmpdir ]; then
	mkdir $tmpdir
fi
case $1 in
#Pause Amarok
	"-pause"|"pause")
		dcop amarok player pause
		;;
#Start Playing
	"-play"|"play")
		tmpfile=$tmpdir"lirc_amarok_start";
		time_between_2_hits=2000000000
		ctime=$(date +%s%N);
		if [ -e $tmpfile ] && [ $(($ctime-$(cat $tmpfile))) -lt $time_between_2_hits ]; then
			echo "play command was given, but might not be finished yet";
		else
			if [ -n "$(pidof amarokapp)" ]; then
				echo $ctime > $tmpfile &
				echo "amarok is already running" &
				if "$(dcop amarok player isPlaying)" ; then
					echo "amarok is already playing";
				else dcop amarok player play &
				fi
			else 
				echo $ctime > $tmpfile &
				echo "starting amarok";
				amarok;
				#No need for the semaphore stuff here - we are just starting amarok, so music will not make the voice inhearable
				$($voice_out_cmd "Please feed Music");
			fi
		fi
		;;
#Stop playing
	"-stop"|"stop")
		tmpfile=$tmpdir"lirc_amarok_stop";
		time_for_force_kill=5
		ctime=$(date +%s);
		if [ -e $tmpfile ] && [ $(($ctime-$(cat $tmpfile))) -eq $time_for_force_kill ]; then 
			echo $ctime > $tmpfile;
			(echo "Button pressed 5 seconds";
			if [ -n "$(pidof amarokapp)" ]; then
				echo "killing amarok" &
				#No need for the semaphore stuff here - we just killed amarok anyway
				$($voice_out_cmd "Good Night" ) &
				killall -9 amarokapp &
			fi);
		elif [ -e $tmpfile ] && [ $(($ctime-$(cat $tmpfile))) -lt $time_for_force_kill ]; then
			dcop amarok player stop;
		else echo $ctime > $tmpfile
			dcop amarok player stop;
		fi
		;;
#Time for bed
	"-bed-time"|"bed-time"|"-bedtime"|"bedtime")
	time_wait_maximum=20000000000;
	sleepstatus=$tmpdir"lirc_amarok_sleep_status";
	sleepdelay=1200
	feedbacksteps=600
	ctime=$(date +%s%N);
	chtime=$(date +%M%s);
	if [ ! -e $voice_semaphore ] || [ ! -n "$(cat $voice_semaphore)" ] || [ $(($ctime-$(cat $voice_semaphore))) -gt $time_wait_maximum ]; then
		echo $ctime > $voice_semaphore &
		if [ -n "$(cat $sleepstatus)" ]; then
			#leave sleepstatus
			sleepfile="$(cat $sleepstatus)"
			echo ""> $sleepfile
			echo ""> $sleepstatus
			(prev_volume=`dcop amarok player getVolume`;
			dcop amarok player setVolume `expr $prev_volume / 3`;
			$($voice_out_cmd "Sleep prevented! ");
			dcop amarok player setVolume $prev_volume;
			echo "" > $voice_semaphore )&
		else
			#go to bed
			sleepfile=$sleepstatus"_"$chtime
			echo $sleepfile > $sleepstatus
			echo $chtime > $sleepfile
			(prev_volume=`dcop amarok player getVolume`;
			dcop amarok player setVolume `expr $prev_volume / 3`;
			$($voice_out_cmd "Sleep in $(($sleepdelay/60)) Minutes!");
			dcop amarok player setVolume $prev_volume;
			echo "" > $voice_semaphore )&
			(for ((i=$sleepdelay;i>0;i=$i-$feedbacksteps));do
				echo "0 -$i"
				if [ $sleepdelay -gt $feedbacksteps ]; then
					echo "1 -$i"
					if [ $(($i%$feedbacksteps)) -gt 1  ]; then
						echo "2 -$i"
						sleep $(($i%$feedbacksteps));
						i=$(($i-$i%$feedbacksteps))
						if [ -n "$(cat $sleepstatus)" ];then
							echo "$(cat $sleepstatus)"
							echo "$sleepfile";
							if [ ! "$(cat $sleepstatus)" == "$sleepfile" ]; then
							echo "test"
								echo "newer sleepfile found";
								break;
								
							fi
						else
							echo "no sleep";
							break;
						fi
						echo "Sleep in $(($i/60)) Minutes! ";
					fi
					echo "3 -$i"
					sleep $feedbacksteps;
					if [ -n "$(cat $sleepstatus)" ];then
						if [ ! "$(cat $sleepstatus)" == "$sleepfile" ]; then
						echo "test2"
							echo "newer sleepfile found";
							break;
							echo "test"
						fi
					else
						echo "no sleep";
						break;
					fi
					echo "Sleep in $(($i/60)) Minutes! ";
				else
					echo "4  -$i"
					sleep $i
					if [ -n "$(cat $sleepstatus)" ];then
						if [ ! "$(cat $sleepstatus)" == "$sleepfile" ]; then
						echo "test2"
							echo "newer sleepfile found";
							break;
							echo "test"
						fi
					else
						echo "no sleep";
						break;
					fi
				fi
				if [ $sleepdelay -gt 0 ]; then
					echo "5 -$i"
					echo "good night";
					killall -9 amarokapp;
					echo ""> $sleepfile
					echo ""> $sleepstatus
					break;
				fi
				#warten bis nix mehr durchgesagt wird, dann verbleibende Zeit ansagen
				(ctime=$(date +%s%N);
				while [ -e $voice_semaphore ] && [ -n "$(cat $voice_semaphore)" ] && [ $(($ctime-$(cat $voice_semaphore))) -lt $time_wait_maximum ]; do
					sleep 1;
				done
				echo $ctime > $voice_semaphore &
				prev_volume=`dcop amarok player getVolume`;
				dcop amarok player setVolume `expr $prev_volume / 3`;
				$($voice_out_cmd "Sleep in $(($i/60)) Minutes! ");
				dcop amarok player setVolume $prev_volume;
				echo "" > $voice_semaphore )&
			done)&
		fi
	else echo "festival is probably not finished";
	fi
	;;
#next song
	"-next"|"next")
		tmpfile=$tmpdir"lirc_amarok_cdnext";
		time_between_2_hits=1000000000
		ctime=$(date +%s%N);
		(if [ -e $tmpfile ] && [ $(($ctime-$(cat $tmpfile))) -lt $time_between_2_hits ]; then
			echo "hit occured too fast";
		else echo $ctime > $tmpfile &
			(dcop amarok player next);
		fi) &
	;;
#previous song
	"-previous"|"previons"|"-prev"|"prev")
		tmpfile=$tmpdir"lirc_amarok_cdprev";
		time_between_2_hits=1000000000
		ctime=$(date +%s%N);
		(if [ -e $tmpfile ] && [ $(($ctime-$(cat $tmpfile))) -lt $time_between_2_hits ]; then
			echo "hit occured too fast";
		else echo $ctime > $tmpfile &
			(dcop amarok player prev);
		fi) &
	;;
#seek forward
	"-forward"|"forward")
		tmpfile=$tmpdir"lirc_amarok_forward";
		time_between_2_hits=500000000
		ctime=$(date +%s%N);
		(if [ -e $tmpfile ] && [ $(($ctime-$(cat $tmpfile))) -lt $time_between_2_hits ]; then
			echo "hit occured too fast";
		else echo $ctime > $tmpfile &
			(dcop amarok player seekRelative 15);
		fi) &
	;;
#seek back
	"-back"|"back")
		tmpfile=$tmpdir"lirc_amarok_back";
		time_between_2_hits=500000000
		ctime=$(date +%s%N);
		(if [ -e $tmpfile ] && [ $(($ctime-$(cat $tmpfile))) -lt $time_between_2_hits ]; then
			echo "hit occured too fast";
		else echo $ctime > $tmpfile &
			(dcop amarok player seekRelative -15);
		fi) &
	;;
#Volume +
	"-vol-up"|"vol-up"|"-volume-up"|"volume-up"|"-vol+"|"vol+"|"-volume+"|"volume+")
		tmpfile=$tmpdir"lirc_amarok_vol_up";
		time_between_2_hits=500000000
		ctime=$(date +%s%N);
		(if [ -e $tmpfile ] && [ $(($ctime-$(cat $tmpfile))) -lt $time_between_2_hits ]; then
			echo "hit occured too fast";
		else echo $ctime > $tmpfile &
			(dcop amarok player setVolumeRelative 10);
		fi) &
	;;
#Volume -
	"-vol-down"|"vol-down"|"-volume-down"|"volume-down"|"-vol-"|"vol-"|"-volume-"|"volume-")
		tmpfile=$tmpdir"lirc_amarok_vol_down";
		time_between_2_hits=500000000
		ctime=$(date +%s%N);
		(if [ -e $tmpfile ] && [ $(($ctime-$(cat $tmpfile))) -lt $time_between_2_hits ]; then
			echo "hit occured too fast";
		else echo $ctime > $tmpfile &
			(dcop amarok player setVolumeRelative -10);
		fi) &
	;;
#Repeat
	"-repeat"|"repeat")
		time_wait_maximum=20000000000
		ctime=$(date +%s%N);
		if [ ! -e $voice_semaphore ] || [ ! -n "$(cat $voice_semaphore)" ] || [ $(($ctime-$(cat $voice_semaphore))) -gt $time_wait_maximum ]; then
			echo $ctime > $voice_semaphore &
			if [ "$(dcop amarok player repeatPlaylistStatus)" == true ]; then
				dcop amarok player enableRepeatPlaylist false;
				dcop amarok player enableRepeatTrack true;
				
				(prev_volume=`dcop amarok player getVolume`;
				dcop amarok player setVolume `expr $prev_volume / 3`;
				$($voice_out_cmd "Repeat Song!");
				dcop amarok player setVolume $prev_volume;
				echo "" > $voice_semaphore;)&
			elif [ "$(dcop amarok player repeatTrackStatus)" == true ]; then
				dcop amarok player enableRepeatPlaylist false;
				dcop amarok player enableRepeatTrack false;
				
				(prev_volume=`dcop amarok player getVolume`;
				dcop amarok player setVolume `expr $prev_volume / 3`;
				$($voice_out_cmd "Repeat Nothing!");
				dcop amarok player setVolume $prev_volume;
				echo "" > $voice_semaphore;)&
			else
				dcop amarok player enableRepeatPlaylist true
				
				(prev_volume=`dcop amarok player getVolume`;
				dcop amarok player setVolume `expr $prev_volume / 3`;
				$($voice_out_cmd "Repeat List!");
				dcop amarok player setVolume $prev_volume;
				echo "" > $voice_semaphore;)&
			fi
		else echo "festival is probably not finished";
		fi
		;;
#Clear Playlist
	"-clear-playlist"|"clear-playlist"|"-clear"|"clear")
		$($clear_playlist_cmd) &
		dcop amarok playlist clearPlaylist
		;;
#Shuffle Playlist
	"-shuffle"|"shuffle")
		tmpfile=$tmpdir"lirc_amarok_shuffle";
		time_between_2_hits=5000000000;
		ctime=$(date +%s%N);
		if [ -e $tmpfile ] && [ $(($ctime-$(cat $tmpfile))) -lt $time_between_2_hits ]; then
			echo "shuffling probably not finished";
		else 
			echo "$(date +%s%N)" > $tmpfile &
			$($shuffle_sound_cmd) &
			dcop amarok playlist shufflePlaylist &
		fi &
		;;
#add more from same artist
	"-more-from-artist"|"more-from-artist"|"-more"|"more"|"-add-more-from-artist"|"add-more-from-artist")
		tmpfile=$tmpdir"lirc_amarok_more";
		tmp_tracks=$tmpdir"lirc_amarok_track_clipboard";
		tracks_to_add=5;
		time_between_2_hits=5000000000;
		ctime=$(date +%s%N);
		if [ -e $tmpfile ] && [ $(($ctime-$(cat $tmpfile))) -lt $time_between_2_hits ]; then
			echo "adding tracks is probably not finished";
		else echo $ctime > $tmpfile &
			(artist="$(dcop amarok player artist)"
			$($tracks_added_sound_cmd) &
			echo "`dcop amarok collection query "select devices.lastmountpoint||'/'||a from (select tags.url as a, tags.deviceid as b,abs(random()% 1000000) as c from tags where tags.artist=(select artist.id from artist where artist.name='$artist')),devices where devices.id =b order by c"`"|sed "s/ /\\\\ /g">$tmp_tracks;
			i=0;
			while read ctrack;do
				if [ $i -lt $tracks_to_add ]; then
					dcop amarok playlist queueMedia "$ctrack";
					echo "$ctrack";
				else break;
				fi
				i="$(($i+1))";
			done < $tmp_tracks;
			rm $tmp_tracks);
		fi&
		;;
#add latest tracks
	"-add-latest"|"add-latest")
		tmpfile=$tmpdir"lirc_amarok_add_latest";
		tmp_tracks=$tmpdir"lirc_amarok_track_clipboard";
		tracks_to_add=10;
		time_between_2_hits=5000000000;
		ctime=$(date +%s%N);
		if [ -e $tmpfile ] && [ $(($ctime-$(cat $tmpfile))) -lt $time_between_2_hits ]; then
			echo "adding tracks is probably not finished";
		else echo $ctime> $tmpfile &
			$($tracks_added_sound_cmd) &
			(echo "`dcop amarok collection query "select devices.lastmountpoint||'/'||a from (select tags.url as a, tags.deviceid as b,tags.createdate as c from tags),devices where devices.id =b order by c desc"`"|sed "s/ /\\\\ /g">$tmp_tracks;
			i=0;
			while read ctrack;do
				if [ $i -lt $tracks_to_add ]; then
					dcop amarok playlist addMedia "$ctrack";
					echo "$ctrack";
				else break;
				fi
				i="$(($i+1))";
			done < $tmp_tracks;
			rm $tmp_tracks);
		fi&
		;;
#add random tracks
	"-add-random"|"add-random")
		tmpfile=$tmpdir"lirc_amarok_add_random";
		tmp_tracks=$tmpdir"lirc_amarok_track_clipboard";
		tracks_to_add=25;
		time_between_2_hits=5000000000;
		ctime=$(date +%s%N);
		if [ -e $tmpfile ] && [ $(($ctime-$(cat $tmpfile))) -lt $time_between_2_hits ]; then
			echo "adding Tracks proabaly not finished"
		else echo $ctime > $tmpfile &
			$($tracks_added_sound_cmd) &
			(echo "`dcop amarok collection query "select devices.lastmountpoint||'/'||a from (select tags.url as a, tags.deviceid as b,abs(random()%1000000) as c from tags ),devices where devices.id =b order by c"`"|sed "s/ /\\\\ /g">$tmp_tracks;
			i=0;
			while read ctrack;do
				if [ $i -lt $tracks_to_add ]; then
					dcop amarok playlist addMedia "$ctrack";
					echo "$ctrack";
				else break;
				fi
				i="$(($i+1))";
			done < $tmp_tracks;
			rm $tmp_tracks);
		fi &
		;;
#read Artist and Trackname and say it with program $voice_out_cmd
	"-read-track"|"read-track")
		time_wait_maximum=20000000000
		ctime=$(date +%s%N);
		if [ ! -e $voice_semaphore ] || [ ! -n "$(cat $voice_semaphore)" ] || [ $(($ctime-$(cat $voice_semaphore))) -gt $time_wait_maximum ]; then
			echo $ctime > $voice_semaphore &
			(prev_volume=`dcop amarok player getVolume`;
			dcop amarok player setVolume `expr $prev_volume / 3`;
			$($voice_out_cmd "$(dcop amarok player artist;echo '!   '; dcop amarok player title)");
			dcop amarok player setVolume $prev_volume
			echo "" > $voice_semaphore )&
		else echo "festival is probably not finished";
		fi
		;;
	*)
		if [ ! -e $1 ]&&[ ! $1 == "help" ]&&[ ! $1 == "-help" ]&&[ ! $1 == "--help" ]; then
			echo "Option \"$1\" does not exist" ;
		fi
		echo "This is a script for remote amarok control"
		echo "        Usage: $0" "[-option]"
		echo "           or: $0" "[option]"
		echo "Please read the scripts case statements for possible options"
		echo ""
		;;
esac

festival configuration stuff

Festival ist eine text2speech engine (recht cool sich damit den aktuellen track ansagen zu lassen)

dazu meine scripte und Konfigurationsdateien

/usr/local/bin/festivalsay perl script for using different voice

#!/usr/bin/perl -w

my $words=$ARGV[0];

open FESTIVAL, '|/usr/bin/festival --pipe';

$voice="(voice_rab_diphone)";
$text="(SayText \"".$words."\")";

print FESTIVAL "$voice";
print FESTIVAL "$text";

close FESTIVAL;

/etc/festival.scm

;; Any site-wide Festival initialization can be added to this file.
;; It is marked as a configuration file, so your changes will be saved
;; across upgrades of the Festival package.

;;Play with Pulseaudio
(Parameter.set 'Audio_Required_Format 'snd)
(Parameter.set 'Audio_Command "paplay $FILE --client-name=festival --volume=65536")
(Parameter.set 'Audio_Method 'Audio_Command)

;;louder!
(set!  default_after_synth_hooks
        (list
          (lambda (utt)
            (utt.wave.rescale utt 1.33 t))))
Persönliche Werkzeuge