Notices


Reply
Thread Tools
Posts: 187 | Thanked: 345 times | Joined on Nov 2009
#1
Here's a simple method of controlling your home desktop computer or HTPC from your n900 using the desktop command execution widget. It looks like this:



For those who don't know what MPD is: It's the most awesome music library player around, believe me. MPD is a backend with billions of frontends for it:

General:
http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki
List of clients:
http://mpd.wikia.com/wiki/Clients

And the simplest MPD client is "mpc", a simple command line client. This is what we're gonna use for our remote control widgets. Here's the set of simple scripts used. Mind that you need to change your IP (192.168.1.2) and port (21337) to whatever your mpd server uses. Also, remember that you might have to allow clients from outside into your mpd server by commenting out 'bind_to_address "127.0.0.1"' in your mpd.conf.

repeat:
Code:
mpc -h 192.168.1.2 -p 21337 repeat | tail -n 1 | sed -e 's/vol.*repeat: //;s/random.*//'
random:
Code:
mpc -h 192.168.1.2 -p 21337 random | tail -n 1 | sed -e 's/vol.*random: //;s/single.*//
prev:
Code:
mpc -h 192.168.1.2 -p 21337 prev > /dev/null 2>&1
toggle:
Code:
mpc -h 192.168.1.2 -p 21337 toggle | sed -n 's/\\[//;s/\\].*//;2p'
next:
Code:
mpc -h 192.168.1.2 -p 21337 next > /dev/null 2>&1
playing now:
Code:
mpc -h 192.168.1.2 -p 21337 -f "%artist% - %album%: %title%" | head -n 1
If you don't want to type all this in, you can edit your ~/.desktop_cmd_exec file and edit the following things. Mind, that if you screw this up all your desktop command execution widgets will likely be broken and you'll have to start over. So you might wanna back up the file first. If you do however screw this up, don't come here whining.

Add this to the end of c_titles:
Code:
Toggle;Next;Prev;Now playing;Random;Repeat:;
Add this to the end of c_commands:
Code:
mpc -h 192.168.1.2 -p 21337 toggle | sed -n 's/\\[//\;s/\\].*//\;2p';mpc -q -h 192.168.1.2 -p 21337 next;mpc -q -h 192.168.1.2 -p 21337 prev;mpc -h 192.168.1.2 -p 21337 -f "%artist% - %album%: %title%" | head -n 1;mpc -h 192.168.1.2 -p 21337 random | tail -n 1 | sed -e 's/vol.*random: //\;s/single.*//';mpc -h 192.168.1.2 -p 21337 repeat | tail -n 1 | sed -e 's/vol.*repeat: //\;s/random.*//'
So now you can control your player from anywhere around.
__________________
Author of:
  • The "Alarmed" scheduling and automation app. (Supports alarms, switching profiles, resetting the GPRS counter, setting custom commands to go off, cron syntax and much more. GUI and CLI).
  • "Reaction face-off", a two-player puzzle/knowledge/reaction game.
  • "ytcli", a simple but effective command line youtube client which allows you to play videos from the CLI instantly or download videos on a queue.
 
Posts: 13 | Thanked: 4 times | Joined on Dec 2009 @ France
#2
You can use "-q" to silent output and then can remove the /dev/null redirection.
 

The Following User Says Thank You to afrinc For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 12:35.