jump to navigation

Pidgin and X-chat plugins to execute a command on new messages February 14, 2010

Posted by GuySoft in Crictor, Hamakor, ITU, linux, open source, programming, python.
Tags: , , , , ,
trackback

Hi all,

A while ago, when I coded message alert plugins for pidgin and X-chat so each time I get a new message my bumble-b LED display would flash, so I thought I might release the code here for people to use.

Both plugins will execute a command of your choice when receiving a new message.

Thanks to Simo Mattila who wrote the base code for the pidgin plugin 🙂

  • Source code for the pidgin plugin
    • You will have to follow the README file and compile the plugin. Then place the created .so file in ~/.purple/plugins/ .
    • In the plugin menu there would be a configuration window to set the command.
  • Source code for the X-chat plugin
    • You will have to set the command inside the python file. Then copy it to ~/.xchat2/
    • The X-chat plugin also is able to return the name of the user that sent the message.

Here is a video of the X-chat plugin in action:

I hope to find more time to posts the things I am doing, but as usual, university takes up all my time. Stay tuned

Comments»

1. no one - February 22, 2010

Why are you linking to your home box if it isn’t stable and consistent?

GuySoft - February 23, 2010

Well I host it there because its comfortable, stable past 10 years.
About the insatiability you had yesterday, sorry about that, I did a server upgrade that went bad (apparently there is a dependency problem in Debian that breaks PHP5 when installing mumble-server).

2. Brian - March 2, 2010

I get:

Traceback (most recent call last):
File “/home/brian/.xchat2/newmassage_notify.py”, line 5, in
command_arguments=[command,”xchat”,topic]
NameError: name ‘topic’ is not defined
Error loading module /home/brian/.xchat2/newmassage_notify.py

GuySoft - March 2, 2010

Oh my, you are right!
I moved that line up for easy reading, not seeing it breaks the code!

Fixed, but there should be a way to make the configuring more firendly

3. xopek - March 7, 2010

That is in a file “/home/guy/stuff/scripts/matrix.py”?
I set command to “/usr/bin/notify-send” and has a received error:
====
Traceback (most recent call last):
File “/home/xopek/.xchat2/newmassage_notify.py”, line 31, in print_channel_msg_hilight_cb
notify(word[0], word[1], “critical”)
File “/home/xopek/.xchat2/newmassage_notify.py”, line 19, in notify
p = Popen(command_arguments)
File “/usr/lib/python2.6/subprocess.py”, line 621, in __init__
errread, errwrite)
File “/usr/lib/python2.6/subprocess.py”, line 1126, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
===
What a file not found?
===
$ which notify-send
/usr/bin/notify-send
===
What to do? 🙂

xopek - March 7, 2010

Sorry, has forgotten a say.
On CTCP action scripts is worked and notify showing but no error 🙂

GuySoft - March 8, 2010

might you be able to see what
print command_arguments
gives you?
If the file is there it should run.

4. Guillermo - March 12, 2010

the command-notification.so = command-notification.py ??

is posible return messages for the client?
who see the result of command?

thanks ..

GuySoft - March 12, 2010

1. There is only command-notification.so , the plugin is written in C, not python (the X-chat plugin is in python).
2. No, you can use autoreply plugin for that.
3. You are exacting a command on the machine running pidgin. Who ever sees it Depends what the commend does.

5. nnexxus - April 29, 2010

Hi ! Great plugin (I’m using the pidgin one), I’m actually surprised nobody coded this before, it’s really handy.

I would like to use your plugin as a mean to make my numlock LED blink when I have an unread message in pidgin. I’m using blinkd daemon and have binded a blink command using your plugin. The problem is that the LED keeps blinking even after I’ve read the message, since I cannot send another command to tell it to stop.

Would it be possible to modify the plugin so that another command can be executed when all messages have been read ? I’ve looked at your C code, but I’m not familiar with purple plugins, and I’m afraid I did not understand much…

GuySoft - April 30, 2010

Sure, go ahead 🙂
Also I might point out that my plugin is based off one that was used to blink laptop’s LEDs, but I can already tell you that its not the same commands for the numlock. I suggest you look at Ledcontrol (also available in package repositories), You might be able to get it to run without editing the plugin’s source.

nnexxus - April 30, 2010

Thanks, I already tried the ledcontrol plugin, with no luck. It does not seem to like my hardware. Besides, a modification of your plugin would be far more generic than ledcontrol.

I’ll try my luck messing with your code. If you have any pointers on what to modify/add, I’d appreciate the help.

6. nnexxus - April 30, 2010

Well, I managed to sort it out, I think. I’ve sent you a mail, maybe you could publish the new version of the plugin here ?

7. Pidgin : utiliser les LEDs du clavier pour notifier un nouveau message « Blog de Nnexxus - May 15, 2010

[…] précolombienne : n’hésitez pas à me remonter des bugs, ou à les poster directement chez Guy Sheffer, qui gère le […]

8. denidS - June 1, 2010

Thanks for this awesome plugin.
I was wondering if it’s it possible for the plugin to pass the new conversation to the notification command?

GuySoft - June 19, 2010

Yes you can do that. But there is a plugin for that already, so there is its kinda pointless.

9. gm - June 18, 2010

Nice function – is there any way to have the command access the sender and message text?

GuySoft - June 19, 2010

I am afraid not.
I am getting quite a few feature requests, seems to me there is call for a full blown advanced plugin for this.. I wish I had time for that.

10. peter - August 19, 2010

hi, why it doesnt work with finch? 😦

GuySoft - August 19, 2010

What is Finch?

peter - August 19, 2010

the console version of pidgin.
i’m just writing an own plugin which can be used by finch and pidgin.

GuySoft - August 20, 2010

Strange, if it loads the pidgin framework it should work.

peter - August 20, 2010

No, because you are using gtk for the ui.

11. gm - August 20, 2010

Peter, if you figure out how to pass the sender and message text to the external command, that’d be awesome.

12. kj6epl - August 21, 2010

How do you build the DLL for the windows version of pidgin?

GuySoft - August 21, 2010

I am not sure how, I only have linux machines here.
It should be possible.

13. jonasc - June 10, 2014

Stumbled upon this and it was nearly what I needed: I added the option to execute a different command on having seen every unseen message: https://gist.github.com/jonasc/65912c935eb374f35850

14. foobar - February 16, 2017

The code for the plugin can now be found at github:
https://github.com/jonasc/command-notification


Leave a reply to Brian Cancel reply