From a584ef4261d3c4967b73b8c8cdb19c951e472336 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sat, 17 Mar 2007 12:51:25 +0000 Subject: Added weempd.py script --- scripts/python/weempd.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 scripts/python/weempd.py (limited to 'scripts') diff --git a/scripts/python/weempd.py b/scripts/python/weempd.py new file mode 100644 index 000000000..db7396593 --- /dev/null +++ b/scripts/python/weempd.py @@ -0,0 +1,40 @@ +#Author: Pablo Escobar +#What it does: This script shows the currently played song in mpd +#Usage: /weempd - Displays the songname +#Released under GNU GPL v2 or newer + +#/usr/bin/python +#coding: utf-8 + +import weechat +import re +import codecs +from os import popen + +weechat.register ('weempd', '0.01', '', """mpd-weechat current song script (usage: /weempd)""") +weechat.add_command_handler ('weempd', 'show_it_to_them') + +default = { + "msg_head": "is playing", + "msg_tail": "with mpd", + "spacer": "★", + "colour_title": "C12", + "colour_spacer": "C08", +} + +for k, v in default.items(): + if not weechat.get_plugin_config(k): + weechat.set_plugin_config(k, v) + +def show_it_to_them(server, args): + spacer = weechat.get_plugin_config("spacer") + msg_tail = weechat.get_plugin_config("msg_tail") + msg_head = weechat.get_plugin_config("msg_head") + colour_title = weechat.get_plugin_config("colour_title") + colour_spacer = weechat.get_plugin_config("colour_spacer") + tempinfo = popen('mpc').readline().rstrip() + all = '/me ' + msg_head + ' %' + colour_spacer + spacer + ' %' + colour_title + tempinfo + ' %' + colour_spacer + spacer + " %C00" + msg_tail + weechat.command(all) + return 0 + + -- cgit debian/1.2.3+git2.25.1-1-2-gaceb0