Re: Problem displaying text/html mime attachments (solved)

2007-01-20 Thread Stefano Sabatini
On date Saturday 2007-01-20 12:20:36 -0700, Bob Proulx muttered:
> Stefano Sabatini wrote:
> > # textual session
> > if [ -z "display" ]; then
> 
> This will never be true.  You meant to say the following there.
> 
>   if [ -z "$DISPLAY" ]; then
> 

Yes, you're right, thanks!
--
Stefano


Re: Problem displaying text/html mime attachments (solved)

2007-01-20 Thread Bob Proulx
Stefano Sabatini wrote:
> # textual session
> if [ -z "display" ]; then

This will never be true.  You meant to say the following there.

  if [ -z "$DISPLAY" ]; then

Bob


Re: Problem displaying text/html mime attachments (solved)

2007-01-17 Thread Stefano Sabatini
On date Wednesday 2007-01-17 09:55:33 -0500, Kyle Wheeler muttered:
> On Wednesday, January 17 at 03:34 PM, quoth Stefano Sabatini:
> >When I try to view a text/html attachment I get from my browser a
> >similiar message:
> >
> >File "/home/sds/tmp/muttIVsHqg" not found.
> >Check the location of the file and try again.
> >
> >I checked for the named file and I effectively couldn't find it.
> >I have no auto_view commands in my muttrc and have this line in my 
> >~/.mailcap:
> >
> >text/html; /usr/bin/epiphany --new-tab %s
> 
> Mutt deletes the temporary file whenever the helper program exits, so 
> that temporary files don't build up and lay around. If epiphany is 
> just sending the URL to the "master" program and exiting, then that's 
> what's going on.
> 
> The solution is to do something like make a script to copy the 
> temporary file elsewhere, or to make the helper program not exit right 
> away, or to make mutt think there will be something to view (e.g. add 
> "copiousoutput" to your mailcap file).

So thanks Kyle you're right.

I've tried both the copiousoutput solution (mutt will wait for the
user to press a key while displaying an empty pager until the user
will press the exit key, mutt will delete the temporary file and the
browser won't be able to display it anymore), and this (somehow
circonvoluted, but more closed to what I want since I don't want to
change the usual mailcap behaviour) scripting solution.

Now I have in my mailcap:
text/html; ~/bin/web-browse %s

and in ~/bin/web-browse:

#! /bin/bash
file=$1

# textual session
if [ -z "display" ]; then
links $file
exit $?
fi

# graphical session
# if this script is run by mutt (the parent process is mutt)
if  ps -u $USER -o pid,command | grep -q "$PPID *mutt"; then
tmp_file=~/tmp/mutt-$$-$(date +%s)
mv $file $tmp_file
file=$tmp_file
fi

if ps -u $USER -o command | grep -q "sawfish"; then
sawfish-client -q -e "(select-workspace web-workspace-num)"
epiphany --new-tab $file
else
epiphany --new-tab $file
fi

In this way the script will mv the HTML file in a temporary file
with a unique name and exit, while epiphany will continue to see the
file (mutt will try to delete the original file which doesn't exist
anymore, but it seems without complaining).

The temporary file will be then automatically cleaned by a periodic
cron script.

Cheers
-- 
Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)