Very neat trick, looking at your fortune file, what does the following
line do? Grab text from a web resource?

(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))


On Thu, Sep 2, 2010 at 1:17 PM, LuKreme <[email protected]> wrote:
> On 1-Sep-2010, at 20:17, Macs R We wrote:
>>
>> On Sep 1, 2010, at 6:07 PM, LuKreme wrote:
>>
>>> Overall, I prefer mail.app and have taken the time to get around some of 
>>> its limitations. For example, I don't like how mail.app handles signatures, 
>>> so I wrote a script that uses fortune to generate a random signature for me 
>>> out of a plain text fortune file.
>>
>> Share?
>
> Sure. There's a couple of parts to it. First, you need to get fortune 
> installed (I installed it originally via ports, but I keep the binaries for 
> it in $HOME/bin/). Remember you will need the fortune executable and the 
> strfile executable.
>
> Create your fortune file. I have mine up for easy stealing at 
> http://home.kreme.com/mysigs.txt it's around a thousand entries to date 
> culled from an eclectic field: some are comedians, some are geeks, some are 
> philosophers, some are songs, some are movie quotes. Heck, some I made up 
> myself. There's more than a fair lot of Discworld, fair warning. If you 
> haven't worked with a fortune file, take a look at it, as the formatting is 
> important and stfile will not work properly with a malformed file, and it 
> won't give you an error either. Google 'man strfile' for details.
>
> Then you need to make the fortune data file using strfile.
>
> % ~/strfile /path/to/signatures
>
> I use a shell script and a launchagent to do the magic, they set a signature 
> in Mail.app named "Fortune" ever few seconds to a random sig. You can change 
> the interval of the launchagent to whatever you want if you want the 
> signatures to change less often. I would very strongly recommend not going 
> below 12 seconds, however. OS X does not like things that try to fire 'too 
> often' and its definition of too often is 10 seconds, and it's a rather loose 
> 10 seconds. 11 doesn't always work, 12 does.
>
> cerebus:~ kreme$ cat $HOME/bin/randsig
> #!/bin/bash
> SIGHOME="$HOME/.signature"
> $HOME/bin/fortune $HOME/mysigs > $SIGHOME
>
> MAIL=`ps -U"$USER" -co command | grep "\bMail\b"`
>
> # Don't bother setting mail's random sig if mail is not running for my user 
> name
> if [ "$MAIL" ]; then
>
> # I did this as two steps as a troubleshooting step, then left it.
> # It seems something else I used wanted the escaped signature too
>
>     cat $SIGHOME | sed -e 's/"/\\"/g' > $HOME/.mail_signature
>     MYSIG="$(<$HOME/.mail_signature)"
>     osascript <<EOF
>          tell application "Mail" to set content of signature "Fortune" to "-- 
> " & return & "$MYSIG"
> EOF
> fi
>
> This COULD be simpler, but I use $HOME/.signature for slrn as well. I tried 
> to use it for ThunderBird, but it would only read the signature file once at 
> launch.
>
> Then here's the launchagent that calls the above script:
>
> cerebus:~ kreme$ cat ~/Library/LaunchAgents/com.kreme.home.randsig.plist
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
> "http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
> <plist version="1.0">
> <dict>
>        <key>KeepAlive</key>
>        <false/>
>        <key>Label</key>
>        <string>com.kreme.home.randsig</string>
>        <key>ProgramArguments</key>
>        <array>
>                <string>/Users/kreme/bin/randsig</string>
>        </array>
>        <key>RunAtLoad</key>
>        <true/>
>        <key>StartInterval</key>
>        <integer>12</integer>
> </dict>
> </plist>
>
> hnever you make edits to the mysig file, you have to rerun strfile or else it 
> all goes pear shaped.
>
> --
> "It's like those French have a different word for *everything*" - Steve
> Martin
>
>
> _______________________________________________
> MacOSX-talk mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/macosx-talk
>



-- 
Best Regards,

John Musbach
_______________________________________________
MacOSX-talk mailing list
[email protected]
http://www.omnigroup.com/mailman/listinfo/macosx-talk

Reply via email to