* [sup-talk] Libnotify popups with sup
@ 2010-01-17 17:13 Anirudh Sanjeev
2010-01-17 18:10 ` Ben Gamari
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Anirudh Sanjeev @ 2010-01-17 17:13 UTC (permalink / raw)
To: sup-talk
[-- Attachment #1.1: Type: text/plain, Size: 658 bytes --]
Hi,
I want to write a small hook to sup to use libnotify and show a small
popup whenever email comes from specific sources.
I need to be able to mention a list of email addresses of people who's
emails are important to me and need to be notified of, and the other
ones I can just ignore.
I don't know any ruby, but I'm sure that this isn't something too
difficult to implement. I am not sure how to use the hooks and the API
in them. I guess I have to use a hook that is executed when the email is
received, but I'm not sure how to get the exact text of the email
address.
Any suggestions on how to go about doing this would be awesome!
Thanks,
Anirudh
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
[-- Attachment #2: Type: text/plain, Size: 140 bytes --]
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [sup-talk] Libnotify popups with sup
2010-01-17 17:13 [sup-talk] Libnotify popups with sup Anirudh Sanjeev
@ 2010-01-17 18:10 ` Ben Gamari
2010-01-17 18:19 ` Cameron Matheson
2010-01-17 18:20 ` Ben Gamari
2 siblings, 0 replies; 4+ messages in thread
From: Ben Gamari @ 2010-01-17 18:10 UTC (permalink / raw)
To: sup-talk
Excerpts from Anirudh Sanjeev's message of Sun Jan 17 12:13:12 -0500 2010:
> Hi,
>
> I want to write a small hook to sup to use libnotify and show a small
> popup whenever email comes from specific sources.
>
You mean something like this? It was a little flaky when I last used it,
but it did work.
- Ben
# libnotify notifications
# Requires libnotify-bin package
notify_cmd = "/usr/bin/notify-send -i /usr/share/icons/Human?/scalable/emblems/emblem-mail.svg"
if num >= 1
notify_summary = "sup found #{num_inbox}/#{num} new message"
notify_summary << "s" if num > 1
notify_body = ""
from_and_subj.each do |f,s|
f.gsub! /\(.*\)/, ''
f.gsub! /<.*>/, ''
f.strip!
s.slice! 0..20
s << "..."
notify_body << "▶ #{f} : #{s}\n"
end
if notify_body.length > 100
notify_body.slice! 0..100
notify_body << "\n..."
end
cmd = "#{notify_cmd} '#{notify_summary}' '#{notify_body}'"
Logger.warn cmd
system cmd
else
#system "#{notify_cmd} 'sup status' 'No new email (yet)'"
end
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [sup-talk] Libnotify popups with sup
2010-01-17 17:13 [sup-talk] Libnotify popups with sup Anirudh Sanjeev
2010-01-17 18:10 ` Ben Gamari
@ 2010-01-17 18:19 ` Cameron Matheson
2010-01-17 18:20 ` Ben Gamari
2 siblings, 0 replies; 4+ messages in thread
From: Cameron Matheson @ 2010-01-17 18:19 UTC (permalink / raw)
To: sup-talk
Excerpts from Anirudh Sanjeev's message of Sun Jan 17 10:13:12 -0700 2010:
> I want to write a small hook to sup to use libnotify and show a small
> popup whenever email comes from specific sources.
>
> I need to be able to mention a list of email addresses of people who's
> emails are important to me and need to be notified of, and the other
> ones I can just ignore.
>
> I don't know any ruby, but I'm sure that this isn't something too
> difficult to implement. I am not sure how to use the hooks and the API
> in them. I guess I have to use a hook that is executed when the email is
> received, but I'm not sure how to get the exact text of the email
> address.
You can see the hooks (and the variables they expose) by running sup -l.
I think you want the after-poll hook. Something like this might work
(I'm modifying my after-poll.rb slightly)
require 'cgi'
notify_addresses = %w(
someguy@example.com
otherguy@example.com
)
from_and_subj.each do |m|
next if notify_addresses.select { |a| m[0].include? a }.empty?
msg = CGI.escapeHTML(m.join "\n")
system("notify-send", "-t", "10000", "New E-Mail", msg)
end
(the HTML escaping is necessary for notify-send to work, otherwise you
just get a blank popup).
Cam
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [sup-talk] Libnotify popups with sup
2010-01-17 17:13 [sup-talk] Libnotify popups with sup Anirudh Sanjeev
2010-01-17 18:10 ` Ben Gamari
2010-01-17 18:19 ` Cameron Matheson
@ 2010-01-17 18:20 ` Ben Gamari
2 siblings, 0 replies; 4+ messages in thread
From: Ben Gamari @ 2010-01-17 18:20 UTC (permalink / raw)
To: sup-talk
Excerpts from Anirudh Sanjeev's message of Sun Jan 17 12:13:12 -0500 2010:
> Hi,
>
> I want to write a small hook to sup to use libnotify and show a small
> popup whenever email comes from specific sources.
>
You mean something like this? It was a little flaky when I last used it,
but it did work.
- Ben
# libnotify notifications
# Requires libnotify-bin package
notify_cmd = "/usr/bin/notify-send -i /usr/share/icons/Human?/scalable/emblems/emblem-mail.svg"
if num >= 1
notify_summary = "sup found #{num_inbox}/#{num} new message"
notify_summary << "s" if num > 1
notify_body = ""
from_and_subj.each do |f,s|
f.gsub! /\(.*\)/, ''
f.gsub! /<.*>/, ''
f.strip!
s.slice! 0..20
s << "..."
notify_body << "M-b~VM-6 #{f} :
end
if notify_body.length > 100
notify_body.slice! 0..100
notify_body << "\n..."
end
cmd = "#{notify_cmd} '#{notify_summary}' '#{notify_body}'"
Logger.warn cmd
system cmd
else
#system "#{notify_cmd} 'sup status' 'No new email (yet)'"
end
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-01-25 20:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-17 17:13 [sup-talk] Libnotify popups with sup Anirudh Sanjeev
2010-01-17 18:10 ` Ben Gamari
2010-01-17 18:19 ` Cameron Matheson
2010-01-17 18:20 ` Ben Gamari
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox