Moode Forum
[Moode 6.4.2] Report result of mpc commands to local UI - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7)
+--- Thread: [Moode 6.4.2] Report result of mpc commands to local UI (/showthread.php?tid=2206)



[Moode 6.4.2] Report result of mpc commands to local UI - zebons - 02-23-2020

Hi,

I'd like to manage the random play button with my remote. I notice the random button on the UI correspond with a 'mpc consume' command. So I affect that command to a remote's button and it works. However the UI doesn't reflect that action. How can I do to have an UI that reflect the mpc status ?
I think that I'd not use direct mpc commands but is there another solution (scripts or command to simulate the clic on the display button) ?
Thanks


RE: [Moode 6.4.2] Report result of mpc commands to local UI - zebons - 02-24-2020

I found a solution for the random play button. I wrote the following script and affect it to a button of my remote.

Code:
#!/bin/bash
SQLDB=/var/local/www/db/moode-sqlite3.db

RESULT=$(sqlite3 $SQLDB "select value from cfg_system where param='ashuffle'")

if [[ $RESULT == '1' ]]; then
   # ashuffle (random play) to ON set to 0 (OFF)
    $(sqlite3 $SQLDB "update cfg_system set value='0' where param='ashuffle'")
    /usr/bin/mpc consume OFF
else
   # ashuffle (random play) to OFF set to 1 (ON)
    $(sqlite3 $SQLDB "update cfg_system set value='1' where param='ashuffle'")
    /usr/bin/mpc consume ON
fi

exit 0



RE: [Moode 6.4.2] Report result of mpc commands to local UI - TheOldPresbyope - 02-24-2020

@zebons

Nice.

Regards,
Kent


RE: [Moode 6.4.2] Report result of mpc commands to local UI - zebons - 03-02-2020

I create another script for adding current song to a playlist with a remote.
I have a Samsung BN59 like remote with numeric touch from 0 to 9 and I use it to launch playlist (named playlist0 to playlist9).
So when touch the 5 button for example, it clear, add and play the playlist 5. I wanted to be able to add a listen song to a specific playlist. It's the purpose of that script which do :
- verify that a number is passed as parameter (playlist to update)
- verify if the playlist file exist and create if necessary
- search the file name of the current song in the currentsong.txt file
- verify if thjat file isn't already store in that playlist
- add the current file playing at the end of the playlist
Code:
#!/bin/bash
CurrentFile=/var/local/www/currentsong.txt
PlayList=/var/lib/mpd/playlists/playlist
#  verif argument number playlist passed
if [ -n "$1" ]  
then
 fileout=$PlayList$1".m3u"
 # verif if playlist file exists
 if [ ! -f $fileout ];then
    # file doesn't exist => created empty
     touch $fileout
 fi
 #  read currentsong.txt to retrieve the current file playing
 while read -r ligne
 do       
   if  [ ${ligne:0:5}=='file=' ]
   then
     file=${ligne:5}
     # read the playlist file to see if the song file is already stored in the playlist
     while read -r ligne_pl
     do      
       if [ "$ligne_pl" = "$file" ]
         then
           # already stored => nothing to do        
           exit 0;
       fi
     done < $fileout
     # current file not found in the playlist
     # add current file at the end of the playlist and exit
     echo $file  >> $fileout    
     exit 0
   fi      
 done < $CurrentFile
else
 echo "Usage: `basename $0` [num_playlist]"  
fi
exit 0

The script is affected  to a combination of 2 buttons on my remote control (for me PRE-CH + Numeric button corresponding to the playlist choosen).

my irexec file for updating the playlist 5 as example :
Code:
begin
prog = irexec
button = KEY_P
button = KEY_5
config = sudo /home/pi/scripts/CurrenttoPlaylist.sh 5
repeat = 0
flags = quit
end



and to load the playlist (that part must be after the previous one as the KEY_5 is in case in the 2 parts) :

Code:
begin
prog = irexec
button = KEY_5
config = mpc clear; mpc load playlist5; mpc play
repeat = 0
flags = quit
end


 
May be it can help someone Smile
Enjoy Cool


RE: [Moode 6.4.2] Segnala il risultato dei comandi mpc all'interfaccia utente locale - neuronestanco - 03-15-2021

hi, I'm new to the forum; I know that this thread is a bit old but I hope you can help me: I tried to copy your script in a new file and I created the link for its launch in lircrc but it doesn't work when I activate the key combination of my choice; perhaps the syntax of the script needs to be changed but unfortunately I am not able; could you help me ? i have a xiaomi box tv remote control which has no numbers like your samsung remote, but only keys; I would like that when I click the KEY_HOME + KEY_OK key the current song is saved at the end of the Favorites.m3u playlist; obviously if the playlist doesn't exist yet, the script has to create it. that's all, I hope you will help me. thank you !