You are not logged in.
SSH Music Controller
Information:
* Written in python
* Allows you to play, pause, skip forward, skip backwards, and stop a song on a remote computer
* Adjust volume on a remote computer
Screenshot:
Known bugs:
* If the song ends and goes on to the next song, the line of text that displays the current song doesn't change. A workaround is to press play.
Currently supported music players:
* ncmpcpp
Dependencies for client machine (controlling the music):
* python (official repos)
* wxpython (official repos)
Dependencies for remote machine (playing the music):
* one of the supported music players from above
Installation (this requires git):
1) First, clone the files from my github:
$ git clone git://github.com/itsbrad212/sshmc.git
2) Run the install script on the client machine as root
# ./install.sh
3) Edit /usr/share/sshmc/sshmc.py to set the IP address of the remote machine, the SSH port to use, and the user to login as
4) You're done! You should now be able to launch the application by executing the sshmc command from wherever you choose.
Configuration:
* Edit /usr/share/sshmc/sshmc.py to set the IP address of the remote machine, the SSH port to use, and the user to login as
Footnotes:
* Please report any bugs so I can fix them
* If you would like support for your music player, just ask
* I am using keychain so I am not prompted with an SSH password. I strongly reccomend using this, or using a public key.
Changelog:
* Added an install script and icons (7/23/10)
* Removed need for amixer-wrapper [falconindy] (7/25/10)
Last edited by cesura (2010-07-25 19:06:53)
Offline
Very handy, but can you try to support mpd?
Offline
A few points:
* You've left yourself hardcoded in def PlaySong. On line 91:
os.system("ssh -p 22 brad@192.168.1.72 'ncmpcpp play'")
* A separate user based config file would be good to have rather than editing the script itself.
* I don't understand the need for the C wrapper on amixer when a python function would suffice to read and parse the output.
* Consider adopting, updating, and using python-mpdclient. It would allow you to do a lot more things solely in Python rather than constantly forking and calling the OS. ...I suppose at that point, you're moving towards a more full fledged MPD client.
Offline
A few points:
* You've left yourself hardcoded in def PlaySong. On line 91:
os.system("ssh -p 22 brad@192.168.1.72 'ncmpcpp play'")
* A separate user based config file would be good to have rather than editing the script itself.
* I don't understand the need for the C wrapper on amixer when a python function would suffice to read and parse the output.
* Consider adopting, updating, and using python-mpdclient. It would allow you to do a lot more things solely in Python rather than constantly forking and calling the OS. ...I suppose at that point, you're moving towards a more full fledged MPD client.
Crap...thanks for those tips falconindy. I had removed that hardcoded portion, but I forgot to commit the changes I'll definitely check out python-mpdclient.
Also, about the C wrapper: It's all I could find at the moment. If you, myself, or someone else could find/write something in python, I'll be happy to replace amixer-wrapper. I will most likely make a seperate config file as well. This release was an sort of an alpha.
Last edited by cesura (2010-07-25 17:36:20)
Offline
I'm pretty noobish with Python, but I hacked this together from bits and pieces of my other misguided adventures:
#!/usr/bin/env python
import commands
def GetVolume():
amixout = [line.lstrip() for line in commands.getoutput("amixer sget PCM").split('\n')]
for line in amixout:
if line.startswith("Front Left"):
print line.split(' ')[3]
GetVolume()
Last edited by falconindy (2010-07-25 18:31:03)
Offline
I'm pretty noobish with Python, but I hacked this together from bits and pieces of my other misguided adventures:
#!/usr/bin/env python import commands def GetVolume(): amixout = [line.lstrip() for line in commands.getoutput("amixer sget PCM").split('\n')] for line in amixout: if line.startswith("Front Left"): print line.split(' ')[3] GetVolume()
Thanks However...
print line.split(' ')[3]
should be changed to:
print line.split(' ')[4]
(at least on my machine). I'll add something to remove the "[", "]", and "%" characters and repost.
Offline
Updated function:
#!/usr/bin/env python
import commands
def GetVolume():
amixout = [line.lstrip() for line in commands.getoutput("amixer sget PCM").split('\n')]
for line in amixout:
if line.startswith("Front Left"):
return int(line.split(' ')[4].strip("[]%"))
print GetVolume()
Last edited by cesura (2010-07-25 19:08:10)
Offline
I don't see why that's needed:
Sample output from amixer:
Simple mixer control 'PCM',0
Capabilities: pvolume cvolume penum
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: Playback 0 - 100 Capture 0 - 100
Front Left: Playback 55 [55%] [-18.00dB] Capture 55 [55%] [-18.00dB]
Front Right: Playback 55 [55%] [-18.00dB] Capture 55 [55%] [-18.00dB]
Is there a case when the number directly after playback won't match the number wrapped in brackets? If there is, no need to call replace 3 times...
return int(line.split(' ')[4].strip("[]%"))
Offline
Offline
The commands module is deprecated in Python 2 and removed in Python 3. You should be using subprocess:
subprocess.Popen(['amixer', 'sget', 'PCM'], stdout = subprocess.PIPE).stdout.read()
Last edited by JohannesSM64 (2010-07-25 21:46:29)
Offline