Hi all,
If you use a remote control (with lircd and irexec), here are two interesting features.
(I don't explain here the installation and configuration of lirc and irexec)
- the 1st: Screen OFF / screen ON with a unique key (interesting if you use a direct screen or the HDMI output)
- the 2nd: Toggle between a Radios Playlist and a Music Playlist with a unique key
(when you listen to your music, you can switch to your favorite radio and return to the exact position of your music)
-1- Screen OFF / screen ON with a unique key
-----------------------------------------------------------
The screen status (Off) is saved in /tmp directory
Extract of '/etc/lirc/irexec.lircrc' (for me the key is 'INFO'):
If necessary create the directory '/home/pi/my_shells (with correct permissions 755),
and copy the code below (with correct permissions 755)
Content of shell script '/home/pi/my_shells/screenOnOff.sh'
-2- Toggle between a Radios Playlist and a Music Playlist with a unique key
----------------------------------------------------------------------------------------------------
First of all, save a playlist with your favorite radios (!! playlist name must be: 'My Radios')
Associate a key with the shell script: toggle_radios_vs_musics_playlist.sh
Extract of '/etc/lirc/irexec.lircrc' (for me the key is 'TUNER_BAND'):
If necessary create the directory '/home/pi/my_shells (with correct permissions 755),
and the directory '/home/pi/my_shells/tmp (with correct permissions 777).
Copy the code below (with correct permissions 755)
Content of shell script '/home/pi/my_shells/toggle_radios_vs_musics_playlist.sh' :
Didier
If you use a remote control (with lircd and irexec), here are two interesting features.
(I don't explain here the installation and configuration of lirc and irexec)
- the 1st: Screen OFF / screen ON with a unique key (interesting if you use a direct screen or the HDMI output)
- the 2nd: Toggle between a Radios Playlist and a Music Playlist with a unique key
(when you listen to your music, you can switch to your favorite radio and return to the exact position of your music)
-1- Screen OFF / screen ON with a unique key
-----------------------------------------------------------
The screen status (Off) is saved in /tmp directory
Extract of '/etc/lirc/irexec.lircrc' (for me the key is 'INFO'):
Code:
begin
prog = irexec
button = INFO
config = /home/pi/my_shells/screenOnOff.sh
repeat = 0
end
If necessary create the directory '/home/pi/my_shells (with correct permissions 755),
and copy the code below (with correct permissions 755)
Content of shell script '/home/pi/my_shells/screenOnOff.sh'
Code:
#!/bin/sh
#
# screen On / screen Off
#
if [ -f /tmp/screenOff ]
then
xset -display :0.0 dpms force on
rm -f /tmp/screenOff
else
xset -display :0.0 dpms force off
touch /tmp/screenOff
fi
-2- Toggle between a Radios Playlist and a Music Playlist with a unique key
----------------------------------------------------------------------------------------------------
First of all, save a playlist with your favorite radios (!! playlist name must be: 'My Radios')
Associate a key with the shell script: toggle_radios_vs_musics_playlist.sh
Extract of '/etc/lirc/irexec.lircrc' (for me the key is 'TUNER_BAND'):
Code:
begin
prog = irexec
button = TUNER_BAND
config = /home/pi/my_shells/toggle_radios_vs_musics_playlist.sh
repeat = 0
end
If necessary create the directory '/home/pi/my_shells (with correct permissions 755),
and the directory '/home/pi/my_shells/tmp (with correct permissions 777).
Copy the code below (with correct permissions 755)
Content of shell script '/home/pi/my_shells/toggle_radios_vs_musics_playlist.sh' :
Code:
#!/bin/sh
########################################################################
#
# Toggle between Radios playlist and Musics playlist
# (this script must be installed in directory: /home/pi/my_shells with correct permissions (chmod 755)
# (the directory /home/pi/my_shells/tmp must exist with correct permissions (chmod 777)
#
########################################################################
# check if radios playlist
mpc status | grep "/0:00 (0%)" -q # a radio have always 0 sec in total time
if [ $? -eq 0 ]
then
# Radios PLaylist : save the current radio
mpc status | grep "%)" > /home/pi/my_shells/tmp/current_radio
cat /home/pi/my_shells/tmp/current_radio | sed 's%^[^#]*#\([0-9]*\)/.*$%\1%' > /home/pi/my_shells/tmp/current_radio_number
# Toggle to previous musics playlist with the last track position
number=`cat /home/pi/my_shells/tmp/current_music_number`
percent=`cat /home/pi/my_shells/tmp/current_music_percent`
random=`cat /home/pi/my_shells/tmp/current_music_random`
mpc clear; mpc random $random; mpc load 'Current Playlist'; mpc play $number; mpc seek $percent
else
# Musics Playlist : save the current musics playlist with current position and random status
mpc rm 'Current Playlist'
mpc save 'Current Playlist'
mpc status | grep "%)" > /home/pi/my_shells/tmp/current_music
mpc status | grep " random: o" > /home/pi/my_shells/tmp/current_random
cat /home/pi/my_shells/tmp/current_music | sed 's%^[^#]*#\([0-9]*\)/.*$%\1%' > /home/pi/my_shells/tmp/current_music_number
cat /home/pi/my_shells/tmp/current_music | sed 's/^[^(]*(\([0-9]*%\).*$/\1/' > /home/pi/my_shells/tmp/current_music_percent
cat /home/pi/my_shells/tmp/current_random | sed 's/^.*random: \([^ ]*\) .*$/\1/' > /home/pi/my_shells/tmp/current_music_random
# Toggle to Radios Playlist 'My Radios' with the last radio (force Random On to authorize looping playlist)
number=`cat /home/pi/my_shells/tmp/current_radio_number`
mpc clear; mpc random off; mpc load 'My Radios'; mpc play $number
fi
Didier