Fandom

Music Player Daemon Community Wiki

Hack:mpd

525pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

import weechat
from os import popen

weechat.register ('mpd', '0.0.2', , 'mpd control script')

weechat.add_command_handler('mpd', 'mpd', 'mpd control', 'toggle|next|prev|volume_up|volume_down|status', , 'toggle|next|prev|volume_up|volume_down|status')

def toggle (server, args,):
	popen('mpc toggle')
	return weechat.PLUGIN_RC_OK

def next (server, args,):
	popen('mpc next')
	return weechat.PLUGIN_RC_OK

def prev (server, args,):
	popen('mpc prev')
	return weechat.PLUGIN_RC_OK

def volume_up (server, args,):
	popen('mpc volume +10')
	return weechat.PLUGIN_RC_OK

def volume_down (server, args,):
	volume_down = popen('mpc volume -10')
	return weechat.PLUGIN_RC_OK

def status (server, args,):
	status = popen('mpc').readline().rstrip()
	weechat.print_infobar(3, status)
	return weechat.PLUGIN_RC_OK

def mpd(server, args):

	largs = args.split(" ")    

	#strip spaces
	while  in largs:
		largs.remove()
	while ' ' in largs:
		largs.remove(' ')

	if len(largs) ==  0:
		weechat.command("/help mpd")
		return weechat.PLUGIN_RC_OK
	else:
		inchan = False

	if largs[0] == 'toggle':
		toggle(" ".join(largs[1:]), inchan)
	elif largs[0] == 'next':
		next(" ".join(largs[1:]), inchan)
	elif largs[0] == 'prev':
		prev(' '.join(largs[1:]), inchan)
	elif largs[0] == 'volume_up':
		volume_up(' '.join(largs[1:]), inchan)
	elif largs[0] == 'volume_down':
		volume_down(' '.join(largs[1:]), inchan)
	elif largs[0] == 'status':
		status(" ".join(largs[1:]), inchan)
	return weechat.PLUGIN_RC_OK

Also on Fandom

Random Wiki