Ir para conteúdo
  • Cadastre-se

Mail e Growl, para quem cansou do GrowlMail


Gabriel M Couto

Posts Recomendados

Eu adoro o Growl, adoro as notificações unificadas. Na minha opinião, o Growl deveria estar embutido no OS X há anos. O OS X vai evoluindo, e com o tempo seus programas também.

O problema é que muitos programas nativos do sistema que poderiam fazer bom uso desse sistema de notificações. E para isso tu encontra programas na Web que estão dispostos a fazer isso. Na verdade, a própria equipe do Growl faz. Assim como o GrowlTunes funciona perfeito no iTunes, o GrowlMail funcionava no Mail.

Só que o Mail se tornou muito complexo, dificultando a adição de suporte via um aplicativo extra. Portanto, a equipe parou de desenvolver.

O projeto do GrowlMail foi tomado por um terceiro, e pelo visto tem sido atualizado por ele. O problema é que é complicado de achar a página de download, além de que a cada atualização do sistema, o programa para de funcionar.

Como eu não queria passar trabalho, fui ver o suporte dos dois aplicativos via AppleScript, e percebi que eu poderia desenvolver, eu mesmo, um Script que fizesse praticamente a mesma coisa... lindamente. E fiz.

Bom, a solução que criei pode não ser a mais elegante de todas... mas funciona perfeito pra mim. É bem fácil de instalar, pelo menos.

Baixe o meu script "IncomingMail" em AppleScript, e salve ele em algum lugar que não vá ser deletado, nem atrapalhar seu fluxo de trabalho.

Depois, abra o Mail, vá em Preferências, e clique na aba Regras:

Screen%20Shot%202011-10-15%20at%2004.24.58.png

Vá em adicionar regra e ajuste como na ilustração abaixo:

Screen%20Shot%202011-10-15%20at%2004.25.10.png

Eu preferi fazer com que o Script execute em todas as mensagens, já que ele automaticamente filtra apenas mensagens válidas que merecem notificação(apenas mensagens novas, que não estão na lixeira, nem são spam).

Note que na seção de executar ações, é importante selecionar a opção de rodar um AppleScript e selecionar o arquivo que você baixou lá no início do post.

As notificações ficarão parecidas com essa:

Screen%20Shot%202011-10-15%20at%2004.46.14.png

Você pode modificar o Script você mesmo para mudar a notificação como quiser.

Post original: http://couto.cc/post...-o-growl-ja-que

Link para o comentário
Compartilhar em outros sites

  • Respostas 6
  • Criado
  • Última resposta

Top Postadores Neste Tópico

Top Postadores Neste Tópico

Código do Script, a quem interessar possa:


-- IncomingMail v1.0, a replacement for GrowlMail
-- by Gabriel Couto
-- October 15, 2011
--
-- tested on Mail 5.1 on Mac OS X 10.7.2
-- truncates a string at max index
-- retrieved from http://www.salling.com/forums/viewtopic.php?p=1461#1461
on truncateString(txt, max)
set txtLength to (length of txt)
if txtLength > max then
set txt to (text 1 thru (max - 1) of txt) as string
end if
return txt
end truncateString
-- find and replaces text in a string
-- retrieved from http://foolsworkshop.com/applescript/2008/05/an-applescript-replace-text-method/
on replaceText(find, replace, subject)
set prevTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to find
set subject to text items of subject

set text item delimiters of AppleScript to replace
set subject to "" & subject
set text item delimiters of AppleScript to prevTIDs

return subject
end replaceText
-- Notify a message from Mail to Growl.
-- theMessage = a message from Mail suite
-- acceptAnyMessage = if it ignore message properties(read,junk,delete) and notify anyway
-- by Gabriel Couto
using terms from application "Mail"
on notifyMessage(theMessage, acceptAnyMessage)
tell theMessage
set msgRead to read status
set msgDeleted to deleted status
set msgJunk to junk mail status
end tell
if ((not msgRead) and (not msgDeleted) and (not msgJunk) or acceptAnyMessage) then
tell theMessage
set msgSender to sender
set msgSubject to subject
set msgSubject to msgSubject as string
set msgSubject to (my (truncateString(msgSubject, 32))) & "..."
set msgContent to content
set msgContent to msgContent as string
-- truncates to work with smaller text
set msgContent to my (truncateString(msgContent, 300))
-- removes 'return'
set msgContent to my (replaceText(return, " ", msgContent))
-- removes '\n'
set msgContent to my (replaceText("
", " ", msgContent))
-- removes '\r'
set msgContent to my (replaceText("
", " ", msgContent))
-- removes '\t'
set msgContent to my (replaceText(" ", " ", msgContent))
-- removes multiple spaces
set msgContent to my (replaceText(" ", " ", msgContent))
-- truncates for final size
set msgContent to (my (truncateString(msgContent, 150))) & "..."
end tell
tell application "Growl"
register as application "Mail" all notifications {"NewMessage"} default notifications {"NewMessage"} icon of application "Mail.app"
notify with name "NewMessage" title msgSender description (msgSubject & return & return & msgContent) application name "Mail"
end tell
end if
end notifyMessage
end using terms from
-- this is on the purpose for test notification with selected messages on Mail, will work with any selected messages
-- the code is the same of the one called by the Mail on the rules
tell application "Mail"
set temp to selection
set theMessage to first item of temp
-- set theMessage to (item 1 of (messages of inbox whose id is equal to 11991))
my notifyMessage(theMessage, true)
end tell
-- mail function called when your rule is activated
using terms from application "Mail"
on perform mail action with messages theSelectedMessages for rule theRule
repeat with a from 1 to count theSelectedMessages
set theMessage to (item a of theSelectedMessages)
my notifyMessage(theMessage, false)
end repeat
end perform mail action with messages
end using terms from
[/CODE]

Link para o comentário
Compartilhar em outros sites

To postando o script que só mostra o assunto e o E-mail de quem está enviando.

Nem mudei nome nem nada, pq qm fez foi o Gabriel e o q eu fiz foi tirar uma variavel só


-- IncomingMail v1.0, a replacement for GrowlMail
-- by Gabriel Couto
-- October 15, 2011
--
-- tested on Mail 5.1 on Mac OS X 10.7.2
-- truncates a string at max index
-- retrieved from http://www.salling.com/forums/viewtopic.php?p=1461#1461
on truncateString(txt, max)
set txtLength to (length of txt)
if txtLength > max then
set txt to (text 1 thru (max - 1) of txt) as string
end if
return txt
end truncateString
-- find and replaces text in a string
-- retrieved from http://foolsworkshop.com/applescript/2008/05/an-applescript-replace-text-method/
on replaceText(find, replace, subject)
set prevTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to find
set subject to text items of subject

set text item delimiters of AppleScript to replace
set subject to "" & subject
set text item delimiters of AppleScript to prevTIDs

return subject
end replaceText
-- Notify a message from Mail to Growl.
-- theMessage = a message from Mail suite
-- acceptAnyMessage = if it ignore message properties(read,junk,delete) and notify anyway
-- by Gabriel Couto
using terms from application "Mail"
on notifyMessage(theMessage, acceptAnyMessage)
tell theMessage
set msgRead to read status
set msgDeleted to deleted status
set msgJunk to junk mail status
end tell
if ((not msgRead) and (not msgDeleted) and (not msgJunk) or acceptAnyMessage) then
tell theMessage
set msgSender to sender
set msgSubject to subject
set msgSubject to msgSubject as string
set msgSubject to (my (truncateString(msgSubject, 32))) & "..."
set msgContent to content
set msgContent to msgContent as string
-- truncates to work with smaller text
set msgContent to my (truncateString(msgContent, 300))
-- removes 'return'
set msgContent to my (replaceText(return, " ", msgContent))
-- removes '\n'
set msgContent to my (replaceText("
", " ", msgContent))
-- removes '\r'
set msgContent to my (replaceText("
", " ", msgContent))
-- removes '\t'
set msgContent to my (replaceText(" ", " ", msgContent))
-- removes multiple spaces
set msgContent to my (replaceText(" ", " ", msgContent))
-- truncates for final size
set msgContent to (my (truncateString(msgContent, 150))) & "..."
end tell
tell application "GrowlHelperApp"
register as application "Mail" all notifications {"NewMessage"} default notifications {"NewMessage"} icon of application "Mail.app"
notify with name "NewMessage" title msgSender description (msgSubject & return & return) application name "Mail"
end tell
end if
end notifyMessage
end using terms from
-- this is on the purpose for test notification with selected messages on Mail, will work with any selected messages
-- the code is the same of the one called by the Mail on the rules
tell application "Mail"
set temp to selection
set theMessage to first item of temp
-- set theMessage to (item 1 of (messages of inbox whose id is equal to 11991))
my notifyMessage(theMessage, true)
end tell
-- mail function called when your rule is activated
using terms from application "Mail"
on perform mail action with messages theSelectedMessages for rule theRule
repeat with a from 1 to count theSelectedMessages
set theMessage to (item a of theSelectedMessages)
my notifyMessage(theMessage, false)
end repeat
end perform mail action with messages
end using terms from
[/CODE]

abrasssssssss

Link para o comentário
Compartilhar em outros sites

  • 5 meses depois...

Atualizado versão 1.1

Se você não sabe o que é o IncomingMail, ou quer saber como instalar, ver o post original:

http://tmblr.co/ZPZqmwAhjMU7

O que mudou desde a última versão:

  • Melhoramento na remoção de caracteres “brancos” na notificação, impedindo que ocorram notificações enormes.
  • Ao truncar uma string, é colocado reticências no final da string… para dar um senso de continuidade.

Download da versão 1.1: http://api.cld.me/1X1J170f0a200o3t1Y2s/download/IncomingMail.scpt

Link para o comentário
Compartilhar em outros sites

Participe do debate

Você pode postar agora e se registrar depois. Se você tem uma conta, entre agora para postar com ela.

Visitante
Responder este tópico…

×   Você colou conteúdo com formatação.   Remover formatação

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Limpar editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.



×
×
  • Criar Novo...