1 # Author: Skippy the Kangoo <Skippythekangoo AT yahoo DOT fr>
2 # This script manages basic controls of mpd (play/pause, next song, previous song, increase volume, decrease volume, display current song)
3 # Usage: /mpd toggle|next|prev|volume_up|volume_down|status
4 # Released under GNU GPL v2 or newer
9 weechat
.register ('mpd', '0.0.2', '', 'mpd control script')
11 weechat
.add_command_handler('mpd', 'mpd', 'mpd control', 'toggle|next|prev|volume_up|volume_down|status', '', 'toggle|next|prev|volume_up|volume_down|status')
13 def toggle (server
, args
,):
15 return weechat
.PLUGIN_RC_OK
17 def next (server
, args
,):
19 return weechat
.PLUGIN_RC_OK
21 def prev (server
, args
,):
23 return weechat
.PLUGIN_RC_OK
25 def volume_up (server
, args
,):
26 popen('mpc volume +10')
27 return weechat
.PLUGIN_RC_OK
29 def volume_down (server
, args
,):
30 volume_down
= popen('mpc volume -10')
31 return weechat
.PLUGIN_RC_OK
33 def status (server
, args
,):
34 status
= popen('mpc').readline().rstrip()
35 weechat
.print_infobar(3, status
)
36 return weechat
.PLUGIN_RC_OK
38 def mpd(server
, args
):
40 largs
= args
.split(" ")
49 weechat
.command("/help mpd")
50 return weechat
.PLUGIN_RC_OK
54 if largs
[0] == 'toggle':
55 toggle(" ".join(largs
[1:]), inchan
)
56 elif largs
[0] == 'next':
57 next(" ".join(largs
[1:]), inchan
)
58 elif largs
[0] == 'prev':
59 prev(' '.join(largs
[1:]), inchan
)
60 elif largs
[0] == 'volume_up':
61 volume_up(' '.join(largs
[1:]), inchan
)
62 elif largs
[0] == 'volume_down':
63 volume_down(' '.join(largs
[1:]), inchan
)
64 elif largs
[0] == 'status':
65 status(" ".join(largs
[1:]), inchan
)
66 return weechat
.PLUGIN_RC_OK