As well as slrn you'll need xmms
or the Beep Media Player
(BMP), and the
xmms-infopipe
plugin. xmms-infopipe 1.3 needs patching before it will work with Beep
Media Player, follow the instructions carefully to compile it as it can be
tricky (worked fine for me). If you've not heard of BMP before, it's very good
and worth trying. Think xmms for gtk+2. I'll assume you can compile &
install / apt-get / emerge / urpmi / whatever these apps.
#!/bin/bash ## mp3sig.sh, a small signature generator ## ## script including current song. ## # Add newlines, sigdash, name, Linux user number echo -e "\n\n-- \nAndrew Preater\nLinux user #238547" # Optionally add system uptime using uptime script # echo -e "Uptime: `uptime.proc.sh`\r" # If music is playing, add title of the current song if [ -p /tmp/xmms-info ] then echo -e "Now playing:\c" grep Title: /tmp/xmms-info | cut -f 2 -d : fi # endFlavour to taste to include your name and whatever other info you like. The script first echos information I want in the sig: a few newlines; a properly-formatted sigdash; name; Linux user number; then if /tmp/xmms-info is a named pipe it greps the Title: line and cuts the field containing the song title. This assumes your audio files are properly tagged. Note: my slrn normally inserts a few newlines at the end of the quoted article text and before the signature, so I've mimicked this behaviour here.
Example output:
$ mp3sig.sh -- Andrew Preater Linux user #238547 Now playing: Basement Jaxx - Get Me Off
#!/bin/bash
## uptime.proc.sh ##
## small script to show system uptime: days, hours, and minutes ##
let upSeconds="$(awk '{ print $1 }' /proc/uptime | cut -f1 -d ".")"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
if [ "${days}" -ne "0" ]
then
echo -n "${days} days"
fi
echo -n " ${hours}:${mins}"
# end
Example output:
$ uptime.proc.sh 8 days 23:59
set post_editor_command "FILE='%s'; mp3sig.sh >> $FILE; vim '+set filetype=mail' +%d $FILE"'%s' is the temporary file created when you compose an article. This post_editor_command calls mp3sig.sh and appends the output to the temporary file, which is then edited using Vim and afterwards handed back to slrn for posting as normal. I borrowed this approach from Nicholas Avenell - thanks!
If you've set a signature in slrn, comment it out from your .slrnrc and make sure ~/.signature doesn't exist. I use mp3sig.sh to create the whole signature — sigdash and all — so you can bypass slrn's usual method. The problem with this is that if you decided to abandon an article without editing it, slrn still asks if you wish to post because the temporary file has been modified by appending the sig. I know I could get around this by calling mp3sig.sh in post_editor_command, redirecting the output to a file, and using this as my signature. But I don't want to, so don't mail me to tell me to. :)
I use "+set filetype=mail" in my slrnrc because for me, around Vim 6.1 and Mandrake 9.1 colourisation of slrn's temporary files broke. This was a quick fix back then, but I kept it. I don't set a textwidth for Vim in my .slrnrc, rather I keep that in my .vimrc:
au FileType mail set tw=70So there you are!
| Send email: preater--at--zworg.com | Last modified: 2007-03-08 22:26:47 GMT |
|