Forum général.général Liens mailto: dans Firefox vers Thunderbird

Posté par  .
Étiquettes :
0
19
sept.
2004
Bon(jour|soir)
J'ai TB 0.8 , FF 0.9.3 , KDE 3.2, gentoo linux 2.6.8.1.

J'ai défini dans ~/.mozilla/firefox/default.xyz/user.js
user_pref("network.protocol-handler.app.mailto", "/home/djax/bin/mailto.sh");


/home/djax/bin/mailto.sh contient

#!/bin/bash
if pgrep -u `whoami` thunderbird-bin > /dev/null
then
thunderbird -remote "mailto(`echo $1 | cut --bytes=8-`)"
else
thunderbird $1
fi


Mais quand je clique sur un mailto:, j'ai ce message d'erreur:

fgrep: /usr/lib/MozillaThunderbird/defaults/pref/thunderbird.js: No such file or directory
/usr/lib/MozillaThunderbird/mozilla-xremote-client: Error: Failed to find a running server.
No running windows found
Error: No running window found

Un germanophone a le même problème, mais personne ne lui a répondu:
http://groups.google.com/groups?hl=fr&lr=&ie=UTF-8&thre(...)

J'ai essayé aussi d'installer mozdev comme conseiller sur certains sites, mais il ne se trouve pas dans mon panneau d'extension, et je n'arrive pas à le configurer.

Si qq1 arrive à ouvrir le composeur de mail de TB depuis un lien mailto dans FF, merci de me dire comment (il|elle) fait.
  • # Trouver une instance Thunderbird...

    Posté par  (site web personnel) . Évalué à 2.

    Je me demandais pourquoi tu faisais un pgrep et pas :
    mozilla-thunderbird -remote 'ping()'
    la réponse c'est ça ne marche pas... enfin chez moi (Tbird 0.8.2)

    Si jamais ça marche chez toi ça te permettra de trouver s'il y a déjà un Tbird sans utiliser de pgrep... sinon mon post ne sert vraiment à rien.
    • [^] # Re: Trouver une instance Thunderbird...

      Posté par  . Évalué à 1.

      Non, ça ne va pas mieux.
      ça me demande de choisir un profile, je n'ai que default, je clique start tb, et il se plaint que le profile default est déjà utilisé. Si je modifie mon user.js pour /usr/bin/thunderbird (qui est un lien symbolique vers mozilla-launcher , j'ai le même phénomène)


      Le TB 0.8.2 est déjà sorti?
      • [^] # Re: Trouver une instance Thunderbird...

        Posté par  (site web personnel) . Évalué à 1.

        Pardon, 0.8-2 (2ème version du paquet 0.8) et pas 0.8.2

        Bizarre qu'il te demande le profil.

        Je viens de trouver que mon erreur était due à un mozilla-thunderbird (le script sh) bogué (note pour plus tard : le corriger).
        Si je fais dans un terminal :
        /usr/lib/mozilla-thunderbird/mozilla-thunderbird-xremote-client 'mailto(foo@bar.com)' || mozilla-thunderbird mailto:foo@bar.com

        Ca marche !
        Peut-être peux tu élaborer qqch là-dessus
        • [^] # Re: Trouver une instance Thunderbird...

          Posté par  . Évalué à 2.

          Lorsque je fais (TB déjà ouvert):
          djax@pc~$ /usr/lib/MozillaThunderbird/mozilla-xremote-client 'mailto(foo@bar.com)'
          ça me dit:

          /usr/lib/MozillaThunderbird/mozilla-xremote-client: Error: Failed to send command: 509 internal error

          Lorsque je fais
          djax@pc~$ thunderbird mailto:foo@bar.com
          ça me dit:

          fgrep: /usr/lib/MozillaThunderbird/defaults/pref/thunderbird.js: No such file or directory
          /usr/lib/MozillaThunderbird/mozilla-xremote-client: Error: Failed to find a running server.
          No running windows found

          Si je fais:
          djax@pc~$ /usr/lib/MozillaThunderbird/thunderbird-bin mailto:foo@bar.com
          ça me donne:

          /usr/lib/MozillaThunderbird/thunderbird-bin: error while loading shared libraries: /usr/lib/MozillaThunderbird/components/libgklayout.so: undefined symbol: JS_LookupPropertyWithFlags

          la comande:
          djax@pc~$ /usr/lib/MozillaThunderbird/thunderbird mailto:foo@bar.com m'ouvre le panneau pour choisir un profil.

          La commande montre bien que TB tourne:
          djax@pc~$ ps aux | grep thunder | grep -v grep

          djax 6697 0.0 0.2 2220 1028 ? S 09:37 0:00 /bin/bash /usr/bin/thunderbird
          djax 6708 1.1 9.6 79212 37160 ? S 09:37 0:46 /usr/lib/MozillaThunderbird/thunderbird-bin -mail
          djax 6712 0.0 9.6 79212 37160 ? S 09:37 0:00 /usr/lib/MozillaThunderbird/thunderbird-bin -mail
          djax 6713 0.0 9.6 79212 37160 ? S 09:37 0:03 /usr/lib/MozillaThunderbird/thunderbird-bin -mail
          djax 6715 0.0 9.6 79212 37160 ? S 09:37 0:00 /usr/lib/MozillaThunderbird/thunderbird-bin -mail
          djax 6737 0.0 9.6 79212 37160 ? S 09:37 0:00 /usr/lib/MozillaThunderbird/thunderbird-bin -mail
          djax 6749 0.0 9.6 79212 37160 ? S 09:38 0:01 /usr/lib/MozillaThunderbird/thunderbird-bin -mail
          djax 6769 0.0 9.6 79212 37160 ? S 09:47 0:00 /usr/lib/MozillaThunderbird/thunderbird-bin -mail
          djax 6770 0.0 9.6 79212 37160 ? S 09:47 0:01 /usr/lib/MozillaThunderbird/thunderbird-bin -mail
          djax 6772 0.0 9.6 79212 37160 ? S 09:47 0:01 /usr/lib/MozillaThunderbird/thunderbird-bin -mail
          djax 6773 0.0 9.6 79212 37160 ? S 09:47 0:00 /usr/lib/MozillaThunderbird/thunderbird-bin -mail
          djax 6774 0.0 9.6 79212 37160 ? S 09:47 0:00 /usr/lib/MozillaThunderbird/thunderbird-bin -mail
          djax 6775 0.0 9.6 79212 37160 ? S 09:47 0:00 /usr/lib/MozillaThunderbird/thunderbird-bin -mail
          djax 6786 0.0 9.6 79212 37160 ? S 09:58 0:00 /usr/lib/MozillaThunderbird/thunderbird-bin -mail
          djax 6787 0.0 9.6 79212 37160 ? S 09:58 0:00 /usr/lib/MozillaThunderbird/thunderbird-bin -mail
          djax 6789 0.0 9.6 79212 37160 ? S 09:58 0:00 /usr/lib/MozillaThunderbird/thunderbird-bin -mail


          djax@pc~$ file /usr/lib/MozillaThunderbird/thunderbird

          /usr/lib/MozillaThunderbird/thunderbird: Bourne shell script text executable

          djax@pc~$ file /usr/lib/MozillaThunderbird/thunderbird-bin

          /usr/lib/MozillaThunderbird/thunderbird-bin: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.4.1, dynamically linked (uses shared libs), stripped



          djax@pc~$ file /usr/lib/MozillaThunderbird/mozilla-xremote-client
          /usr/lib/MozillaThunderbird/mozilla-xremote-client: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.4.1, dynamically linked (uses shared libs), stripped


          djax@pc~$ file /usr/bin/thunderbird
          /usr/bin/thunderbird: symbolic link to `/usr/libexec/mozilla-launcher'

          djax@pc~$ file /usr/libexec/mozilla-launcher

          /usr/libexec/mozilla-launcher: Bourne-Again shell script text executable



          PS: Je suis sous X.org 6.7
          • [^] # Re: Trouver une instance Thunderbird...

            Posté par  (site web personnel) . Évalué à 2.

            Au vu de ces infos, j'ai l'impression que tu es aussi victime d'un pb dans les scripts de lancement (typiquement le error while loading shared libraries... un pb de chemin pour trouver les librairies qui sont dans /usr/lib/MozillaThunderbird/).

            Q1: quand tu lances TB en temps normal, il te demande un profil ?
            Q2: (si Q1 == oui) que fait /usr/lib/MozillaThunderbird/thunderbird -remote 'mailto(mailto:foo@bar.com)' ?

            Sinon, publie ton mozilla-launcher et ton /usr/lib/MozillaThunderbird/thunderbird ça peut être instructif.
            • [^] # Re: Trouver une instance Thunderbird...

              Posté par  . Évalué à 1.

              Q1: quand tu lances TB en temps normal, il te demande un profil ?
              Non, je le lance en cliquant sur un bouton qui appelle à /usr/bin/thunderbird
              
              Le mozilla-launcher:
              
              #!/bin/bash
              #
              # Copyright 1999-2004 Gentoo Technologies, Inc.
              # Distributed under the terms of the GNU General Public License v2
              # $Header: /var/cvsroot/gentoo-src/mozilla-launcher/mozilla-launcher,v 1.16 2004
              /08/05 22:07:10 agriffis Exp $
              
              # Set MOZILLA_NEWTYPE to "window" in your environment if you prefer
              # new windows instead of new tabs
              newtype=${MOZILLA_NEWTYPE:-"tab"}
              
              # Make sure necessary progs are in the PATH
              PATH=/usr/bin:/bin:/usr/X11R6/bin:$PATH
              
              main() {
                local args mozargs urls u i
                local candidates retval=0 remote_supports_dash_a zero=${0##*/}
              
                # Determine if we're called as firefox or mozilla and set up
                # variables appropriately
                which_browser || exit 1       # note: modifies $zero
              
                # Parse the command-line and set args, mozargs and urls
                parse_cmdline "$@" || exit 1
              
                # Make sure we'll get at least an empty window/tab
                # when nothing else is specified on the cmdline.
                if [[ $# -eq 0 ]]; then
                  if [[ $zero == ?hunderbird ]]; then
                    mozargs=-mail
                  else
                    urls=('')
                  fi
                fi
              
                # Set the candidates array with find_running
                find_running
              
                # Handle some special args.  We want to handle these ourselves so
                # that we can find the right window on the screen to target.
                set -- "${mozargs[@]}"
                while [[ $# -gt 0 ]]; do
                  case $1 in
                    -mail)    try_running 'xfeDoCommand(openInbox)' ;;
                    -compose) try_running 'xfeDoCommand(composeMessage)' ;;
                    -remote)  try_running "$2" && shift ;;
                  esac
                  [[ $? -eq 0 ]] && { shift; continue; }
                  # Error path: try_running failed, so prepend remaining mozargs to
                  # args and drop through to call the browser binary
                  args=("$@" "${args[@]}")
                  break
                done
              
                # If there's no running browser, or we've got args, start an
                # instance.
                if [[ ${#args[@]} -gt 0 ]] || ! try_running 'ping()'; then
                  # Assume the first url should just be tacked on the end.
                  try_start "${args[@]}" ${urls:+"${urls[0]}"}
                  set -- "${urls[@]}"; shift; urls=("$@")   # shift off the first url
                  candidates=$DISPLAY
                  args=()
              
                  # Handle case of multiple URLs by waiting for browser to map to
                  # the screen so that it can be found by $remote below
                  if [[ ${#urls[@]} -gt 0 ]]; then
                    if [[ -x /usr/bin/xtoolwait ]]; then
                      xtoolwait sleep 10      # hope it hasn't mapped yet
                    else
                      sleep 1
                      for ((i = 0; i < 40; i = i + 1)); do
                        try_running 'ping()' && break || sleep 0.25
                      done
                    fi
                  fi
                fi
              
                # Handle multiple URLs by looping over the xremote call
                for u in "${urls[@]}"; do
                  if [[ $u == mailto:* ]]; then
                    try_running "mailto(${u#mailto:})" || retval=$?
                  else
                    try_running "openURL($u,new-$newtype)" || retval=$?
                  fi
                done
              
                # Will only wait here if browser was started by this script
                if ! wait; then
                  retval=$?
                  echo "${mozbin##*/} exited with non-zero status ($?)" >&2
                fi
              
                exit $retval
              }
              
              which_browser() {
                # Support mozilla, mozilla-bin, firefox, firefox-bin, thunderbird,
                # thunderbird-bin!
                # This case statement does the setup for source-based browsers and
                # just drops through for binary-based browsers.
                case $zero in
                  *fox)
                    export MOZILLA_FIVE_HOME="/usr/lib/MozillaFirefox"
                    remote=$MOZILLA_FIVE_HOME/mozilla-xremote-client
                    mozbin=$MOZILLA_FIVE_HOME/firefox-bin
                    grepfor=Firefox-bin
                    prefs=$HOME/.phoenix
                    ;;
              
                  *mozilla)
                    export MOZILLA_FIVE_HOME="/usr/lib/mozilla"
                    remote=$MOZILLA_FIVE_HOME/mozilla-xremote-client
                    mozbin=$MOZILLA_FIVE_HOME/mozilla-bin
                    grepfor=Mozilla-bin
                    prefs=$HOME/.mozilla
                    ;;
              
                  *thunderbird)
                    export MOZILLA_FIVE_HOME="/usr/lib/MozillaThunderbird"
                    remote=$MOZILLA_FIVE_HOME/mozilla-xremote-client
                    mozbin=$MOZILLA_FIVE_HOME/thunderbird-bin
                    grepfor=Thunderbird-bin
                    prefs=$HOME/.thunderbird
                    ;;
              
                  *-bin)
                    unset mozbin  # just in case...
                    ;;            # but don't do anything yet
              
                  *)
                    echo "$0: unknown browser" >&2
                    return 1
                    ;;
                esac
              
                # Attempt to use -bin version if source version isn't available
                if [[ -n $mozbin && ! -f $mozbin ]]; then
                  unset mozbin        # it's bogus anyway
                  zero=${zero}-bin
                fi
              
                case $zero in
                  *fox-bin)
                    export MOZILLA_FIVE_HOME="/opt/firefox"
                    remote=$MOZILLA_FIVE_HOME/mozilla-xremote-client
                    mozbin=$MOZILLA_FIVE_HOME/firefox-bin
                    grepfor=Firefox-bin
                    prefs=$HOME/.phoenix
                    ;;
              
                  *mozilla-bin)
                    export MOZILLA_FIVE_HOME="/opt/mozilla"
                    remote=$MOZILLA_FIVE_HOME/mozilla-xremote-client
                    mozbin=$MOZILLA_FIVE_HOME/mozilla-bin
                    grepfor=Mozilla-bin
                    prefs=$HOME/.mozilla
                    ;;
              
                  *thunderbird-bin)
                    export MOZILLA_FIVE_HOME="/opt/thunderbird"
                    remote=$MOZILLA_FIVE_HOME/mozilla-xremote-client
                    mozbin=$MOZILLA_FIVE_HOME/thunderbird-bin
                    grepfor=Thunderbird-bin
                    prefs=$HOME/.thunderbird
                    ;;
                esac
              
                # Make sure we got something
                if [[ -z $mozbin || ! -f $mozbin ]]; then
                  echo "$0: can't find the browser :-(" >&2
                  return 1
                fi
              
                # Trim -bin from ${zero} for the sake of xremote -a programname
                zero=${zero%-bin}
              
                # Workaround thunderbird needing -a Thunderbird
                # See http://bugzilla.mozilla.org/show_bug.cgi?id=247754(...)
                if [[ $zero == thunderbird ]]; then
                  fgrep -q '"0.7"' ${MOZILLA_FIVE_HOME}/defaults/pref/thunderbird.js \
                    && zero=Thunderbird
                fi
              
                # Read the preferences directory from appreg
                # so that we can delete XUL.mfasl since it causes so many problems.
                # (This code works but is commented out since I'm not sure that we
                # actually need it)
                #if [[ -n $prefs && -r $prefs/appreg ]]; then
                #  prefs=$(strings $prefs/appreg 2>/dev/null | sed -n '/^directory$/{n;p;q}')
                #fi
              
                # Set LD_LIBRARY_PATH (also set in /etc/env.d/10*)
                export LD_LIBRARY_PATH=$MOZILLA_FIVE_HOME:$MOZILLA_FIVE_HOME/plugins${LD_LIBRA
              RY_PATH:+:$LD_LIBRARY_PATH}
              
                return 0
              }
              
              # parse_cmdline: set args, mozargs and urls, which are dynamically
              # scoped in main()
              parse_cmdline() {
                # Validate the args and extract the urls
                args=()         # general arguments
                mozargs=()      # arguments that we handle specifically
                urls=()         # urls to open
                while [[ $# -ne 0 ]] ; do
                  if [[ $1 == -* ]] ; then
                    case "${1#-}" in
                      height|width|CreateProfile|P|UILocale|contentLocale|edit|chrome)
                        args=("${args[@]}" "$1" "$2")
                        shift 2 ;;
                      mail|compose)
                        mozargs=("${mozargs[@]}" "$1")
                        shift 1 ;;
                      remote)
                        mozargs=("${mozargs[@]}" "$1" "$2")
                        shift 2 ;;
                      *)
                        args=("${args[@]}" "$1")
                        shift 1 ;;
                    esac
                  else
                    if [[ $1 == *://*/* ]]; then
                      urls=("${urls[@]}" "$1")
                    elif [[ $1 == *://* ]]; then
                      # as of mozilla_1.7_rc1 the url checking changed for xremote
                      # calls... now three slashes are required for urls, otherwise we
                      # get the following error from xremote:
                      #  Error: Failed to send command: 509 internal error
                      urls=("${urls[@]}" "$1/")
                    elif [[ $1 != *://* && $1 != /* && -e $1 ]]; then
                      # relative path to a file, transform to absolute path
                      urls=("${urls[@]}" "file://$PWD/$1")
                    elif [[ $1 != *:* && $1 == *@* ]]; then
                      # looks like an email address, prefix with mailto: so we can
                      # recognize it later.
                      urls=("${urls[@]}" "mailto:$1")
                    else
                      # no idea what this is!  just add it to urls and hope it works
                      urls=("${urls[@]}" "$1")
                    fi
                    shift
                  fi
                done
              
                return 0
              }
              
              # set_logname: make sure LOGNAME is set
              set_logname() {
                : ${LOGNAME:=$USER}
                : ${LOGNAME:=$(whoami)}
                export LOGNAME
              }
              
              # fake_user: fake user string on browser windows that should be found
              # by $remote.  This is a hack, but on the other hand, anything other
              # than patching the xremote source would be a hack.  This prevents
              # xremote from mixing up mozilla and firefox windows.
              fake_user() {
                local id retval=1
                set_logname
              
                # Find browser windows with a _MOZILLA_USER property and fake it
                for id in $(xwininfo -root -tree | awk -v gf="$grepfor" '$0~gf{print $1}'); do
                  if xprop -notype -id $id | grep -Fqx "_MOZILLA_USER = \"$LOGNAME\""; then
                    xprop -id $id -f _MOZILLA_USER 8s -set _MOZILLA_USER "${zero}-$LOGNAME"
                    retval=0
                  fi
                done
              
                return $retval
              }
              
              # unfake_user: remove the hackery done by fake_user
              unfake_user() {
                local id
                set_logname
              
                # Find browser windows with a fake _MOZILLA_USER and fix it
                for id in $(xwininfo -root -tree | awk -v gf="$grepfor" '$0~gf{print $1}'); do
                  xprop -notype -id $id | grep -Fqx "_MOZILLA_USER = \"${zero}-$LOGNAME\"" \
                  && xprop -id $id -f _MOZILLA_USER 8s -set _MOZILLA_USER "$LOGNAME"
                done
              }
              
              # find_running: sets the candidates array
              find_running() {
                local screens s
              
                # Try to start in an existing session; check all screens
                # with priority on the current screen
                screens=("$DISPLAY"
                  $(xdpyinfo | awk '
                    /^name of display:/ {
                      disp = substr($NF, 0, match($NF, /\.[^.]*$/)-1)
                    }
                    /^number of screens:/ {
                      for (i = 0; i < $NF; i++) {
                        this = sprintf("%s.%d", disp, i)
                        if (this != ENVIRON["DISPLAY"])
                          print this
                      }
                    }')
                  )
              
                # We used to check displays with xwininfo here but that isn't
                # necessary with the advent of fake_user and/or -a programname.
                # Instead just test for a running program if we're on a local
                # display.
                if [[ $DISPLAY != :* ]] || killall -0 ${mozbin##*/} &>/dev/null; then
                  candidates=("${screens[@]}")
                else
                  candidates=()
                fi
              }
              
              # try_running: try to use an existing browser to run a command
              try_running() {
                local s retval=2  # default == can't find an instance
              
                # Check for newer xremote which supports -a programname
                # which thankfully obviates fake_user
                if [[ -z $remote_supports_dash_a ]]; then
                  if $remote 2>&1 | grep -Fq '[-a '; then
                    remote_supports_dash_a=true
                  else
                    remote_supports_dash_a=false
                  fi
                fi
              
                # Try mozilla-xremote-client on each candidate screen.
                # Only use mozilla-xremote-client if we have no other args (which
                # must be passed to the browser binary).
                if [[ ${#candidates[@]} > 0 ]]; then
                  if $remote_supports_dash_a || [[ -n $MOZ_FORCE_FAKE_USER || \
                    ( $candidates == :* && -z $MOZ_NO_FAKE_USER ) ]]
                  then
                    # Attempt to find a target browser using either -a or fake_user
                    for s in "${candidates[@]}"; do
                      if $remote_supports_dash_a; then
                        DISPLAY=$s $remote -a ${zero} "$@"
                        retval=$?
                      elif DISPLAY=$s fake_user; then
                        LOGNAME="${zero}-$LOGNAME" DISPLAY=$s $remote "$@"
                        retval=$?
                        DISPLAY=$s unfake_user
                      fi
                      if [[ $retval -eq 0 ]]; then
                        candidates=("$s")       # for future calls
                        return 0
                      fi
                    done
                  else
                    # fake_user stuff takes prohibitively long on a remote
                    # display, so I guess this has the potential to exhibit the
                    # mozilla/firefox mixups for the 1% of users that are running
                    # both simultaneously from a remote machine.
                    for s in "${candidates[@]}"; do
                      DISPLAY=$s $remote "$@"
                      retval=$?
                      if [[ $retval -eq 0 ]]; then
                        candidates=("$s")       # for future calls
                        return 0
                      fi
                    done
                  fi
                fi
              
                # Might as well do this error interpretation here
                case $retval in
                  1) echo "Unable to connect to X server" >&2 ;;
                  2) echo "No running windows found" >&2 ;;
                  3) echo "Browser doesn't understand command" >&2 ;;
                  *) echo "Unknown error $retval from mozilla-xremote-client" >&2 ;;
                esac
              
                return $retval
              }
              
              # try_start: attempt to start a browser
              try_start() {
                # Delete XUL cache since it causes so many problems
                # (depends on commented code in which_browser)
                #[[ -f $prefs/XUL.mfasl ]] && rm -f $prefs/XUL.mfasl
                $mozbin "$@" &
              }
              
              # Call the main sub, which is defined at the top of this script
              main "$@"
              
              # vim:expandtab sw=2:
              
              /usr/lib/MozillaThunderbird/thunderbird
              #!/bin/sh
              #
              # The contents of this file are subject to the Netscape Public License
              # Version 1.0 (the "NPL"); you may not use this file except in
              # compliance with the NPL.  You may obtain a copy of the NPL at
              # http://www.mozilla.org/NPL/(...)
              #
              # Software distributed under the NPL is distributed on an "AS IS" basis,
              # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
              # for the specific language governing rights and limitations under the
              # NPL.
              #
              # The Initial Developer of this code under the NPL is Netscape
              # Communications Corporation.  Portions created by Netscape are
              # Copyright (C) 1998 Netscape Communications Corporation.  All Rights
              # Reserved.
              #
              
              ## $Id: mozilla.in,v 1.2.6.1 2004/07/24 23:58:06 bryner%brianryner.com Exp $
              ##
              ## Usage:
              ##
              ## $ mozilla [args]
              ##
              ## This script is meant to run the mozilla-bin binary from either
              ## mozilla/xpfe/bootstrap or mozilla/dist/bin.
              ##
              ## The script will setup all the environment voodoo needed to make
              ## the mozilla-bin binary to work.
              ##
              
              moz_pis_startstop_scripts()
              {
                MOZ_USER_DIR=".thunderbird"
                # MOZ_PIS_ is the name space for "Mozilla Plugable Init Scripts"
                # These variables and there meaning are specified in
                # mozilla/xpfe/bootstrap/init.d/README
                MOZ_PIS_API=2
                MOZ_PIS_MOZBINDIR="${dist_bin}"
                MOZ_PIS_SESSION_PID="$$"
                MOZ_PIS_USER_DIR="${MOZ_USER_DIR}"
                export MOZ_PIS_API MOZ_PIS_MOZBINDIR MOZ_PIS_SESSION_PID MOZ_PIS_USER_DIR
              
                case "${1}" in
                  "start")
                    for curr_pis in "${dist_bin}/init.d"/S* "${HOME}/${MOZ_USER_DIR}/init.d"/S* ; do
                      if [ -x "${curr_pis}" ] ; then
                        case "${curr_pis}" in
                          *.sh) .  "${curr_pis}"         ;;
                          *)       "${curr_pis}" "start" ;;
                        esac
                      fi
                    done
                    ;;
                  "stop")
                    for curr_pis in "${HOME}/${MOZ_USER_DIR}/init.d"/K* "${dist_bin}/init.d"/K* ; do
                      if [ -x "${curr_pis}" ] ; then
                        case "${curr_pis}" in
                          *.sh) . "${curr_pis}"        ;;
                          *)      "${curr_pis}" "stop" ;;
                        esac
                      fi
                    done
                    ;;
                  *)
                    echo 1>&2 "$0: Internal error in moz_pis_startstop_scripts."
                    exit 1
                    ;;
                esac
              }
              
              #uncomment for debugging
              #set -x
              
              moz_libdir=/usr/lib/thunderbird-0.8
              MRE_HOME=/usr/lib/mre/mre-0.8
              
              # Use run-mozilla.sh in the current dir if it exists
              # If not, then start resolving symlinks until we find run-mozilla.sh
              found=0
              progname="$0"
              curdir=`dirname "$progname"`
              progbase=`basename "$progname"`
              run_moz="$curdir/run-mozilla.sh"
              if test -x "$run_moz"; then
                dist_bin="$curdir"
                found=1
              else
                here=`/bin/pwd`
                while [ -h "$progname" ]; do
                  bn=`basename "$progname"`
                  cd `dirname "$progname"`
                  progname=`/bin/ls -l "$bn" | sed -e 's/^.* -> //' `
                  if [ ! -x "$progname" ]; then
                    break
                  fi
                  curdir=`dirname "$progname"`
                  run_moz="$curdir/run-mozilla.sh"
                  if [ -x "$run_moz" ]; then
                    cd "$curdir"
                    dist_bin=`pwd`
                    found=1
                    break
                  fi
                done
                cd "$here"
              fi
              if [ $found = 0 ]; then
                # Check default compile-time libdir
                if [ -x "$moz_libdir/run-mozilla.sh" ]; then
                  dist_bin="$moz_libdir"
                else
                  echo "Cannot find mozilla runtime directory. Exiting."
                  exit 1
                fi
              fi
              
              script_args=""
              moreargs=""
              debugging=0
              MOZILLA_BIN="${progbase}-bin"
              
              # The following is to check for a currently running instance.
              # This is taken almost verbatim from the Mozilla RPM package's launch script.
              MOZ_CLIENT_PROGRAM="$dist_bin/mozilla-xremote-client"
              check_running() {
                  "${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" 'ping()' 2>/dev/null >/dev/null
                  RETURN_VAL=$?
                  if [ $RETURN_VAL -eq 0 ]; then
                      echo 1
                      return 1
                  else
                      echo 0
                      return 0
                  fi
              }
              
              if [ "$OSTYPE" = "beos" ]; then
                mimeset -F "$MOZILLA_BIN"
              fi
              
              ALREADY_RUNNING=`check_running`
              
              ################################################################ Parse Arguments
              # If there's a command line argument but it doesn't begin with a -
              # it's probably a url.  Try to send it to a running instance.
              _USE_EXIST=0
              _NEW_WINDOW=
              _optOne="$1"
              case "${_optOne}" in
                      -*)
                              ;;
                      *)
                              _USE_EXIST=1
                              ;;
              esac
              
              _optOthers=
              _optLast=
              for i in "$@"; do
                      _optLast="${i}"
              done #last arg
              
              for i in "$@"; do
                      [ $i = ${_optLast} ] && break
                      _optOthers="${_optOthers} ${i}"
              done #others arg
              
              #???: needs check if othersopt begin with -* ?
              if [ `expr "${_optLast}" : '.*:/.*'` -eq 0 -a \( -f "${_optLast}" -o -d "${_optLast}" \) ]; then
                      # Last argument seems to be a local file/directory
                      # Check, if it is absolutely specified (ie. /home/foo/file vs. ./file)
                      # If it is just "relatively" (./file) specified, make it absolutely
                      [ `expr "${_optLast}" : '/.*'` -eq 0 ] && _optLast="file://`pwd`/${_optLast}"
              elif [ `expr "${_optLast}" : '.*:/.*'` -gt 0 -o -n "${_optOthers}" ]; then #???? like before...
                      _NEW_WINDOW=1
              fi
              ################################################################ Parse Arguments
              
              ########################################################################### Main
              if [ $ALREADY_RUNNING -eq 1 ]; then
                      # There's an instance already running. Use it.
                      # Any command line args passed in?
                      if [ $# -gt 0 ]; then
                              # There were "some" command line args.
                              if [ ${_USE_EXIST} -eq 1 ]; then
                                      # We should use an existing instance, as _USE_EXIST=$_USE_EXIST=-1
                                      _open_type="window"
                                      #_open_type="tab"
                                      _remote_cmd="openURL(${_optLast} , new-${_open_type})"
                                      "${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" "${_remote_cmd}"
                                      unset _remote_cmd _open_type
                                      exit $?
                              fi
                      else
                              # No command line args. Open new window/tab
                              #exec "${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" "xfeDoCommand(openBrowser)"
                              "${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" "xfeDoCommand(openInbox)"
                              exit $?
                      fi
              fi
              # Default action - no running instance or _USE_EXIST (${_USE_EXIST}) ! -eq 1
              ########################################################################### Main
              
              while [ $# -gt 0 ]
              do
                case "$1" in
                  -p | --pure | -pure)
                    MOZILLA_BIN="${MOZILLA_BIN}.pure"
                    shift
                    ;;
                  -g | --debug)
                    script_args="$script_args -g"
                    debugging=1
                    shift
                    ;;
                  -d | --debugger)
                    script_args="$script_args -d $2"
                    shift 2
                    ;;
                  *)
                    moreargs="$moreargs \"$1\""
                    shift 1
                    ;;
                esac
              done
              
              export MRE_HOME
              eval "set -- $moreargs"
              
              ## Start addon scripts
              moz_pis_startstop_scripts "start"
              
              if [ $debugging = 1 ]
              then
                echo $dist_bin/run-mozilla.sh $script_args $dist_bin/$MOZILLA_BIN "$@"
              fi
              "$dist_bin/run-mozilla.sh" $script_args "$dist_bin/$MOZILLA_BIN" "$@"
              exitcode=$?
              
              ## Stop addon scripts
              moz_pis_startstop_scripts "stop"
              
              exit $exitcode
              # EOF.
              
              • [^] # Re: Trouver une instance Thunderbird...

                Posté par  . Évalué à 1.

                Il semble que ce script-là marche pour moi:
                
                
                #!/bin/sh # export MOZILLA_FIVE_HOME=/usr/lib/MozillaThunderbird/ if [ $(ps aux | grep thunderbird | wc -l) -gt 4 ]; then echo "thunderbird is running (thunderbird est lance)"; $MOZILLA_FIVE_HOME/mozilla-xremote-client -a Thunderbird "mailto($1?subject=$2)" else echo "thunderbird is not running (thunderbird n'est pas lance)"; $MOZILLA_FIVE_HOME/thunderbird -P default -compose mailto:$1; fi
                Ce qui est traitre dans mozilla-xremote-client dit cela dans son "aide":
                Usage: mozilla-xremote-client [-a firefox|thunderbird|mozilla|any] [-u ] [-p ] COMMAND
                Mais si je tape  /usr/lib/MozillaThunderbird/mozilla-xremote-client -a thunderbird "mailto(toto@foo.bar)"
                on me répond :
                /usr/lib/MozillaThunderbird/mozilla-xremote-client: Error: Failed to find a running server.
                
                 alors que si je tape: /usr/lib/MozillaThunderbird/mozilla-xremote-client -a Thunderbird "mailto(toto@foo.bar)" ,
                 TB ouvre un composeur de message. Je ne sais pas à quel point ce n'est pas un bug.
                
                J'ai fait l'erreur de ne pas mettre mon /home/djax/bin/mailto.sh en executable, ce qui produisait l'erreur:
                
                fgrep: /usr/lib/MozillaThunderbird/defaults/pref/thunderbird.js: No such file or directory
                
                /usr/lib/MozillaThunderbird/mozilla-xremote-client: Error: Failed to find a running server.
                
                No running windows found
                
                
                C'était AMHA pas très parlant comme message d'erreur,
                 mais bon, c'est ma faute, donc je vais pas trop rouspéter :-).
                
  • # Un script qui marche

    Posté par  . Évalué à 1.

    Chez moi j'ai ça qui marche bien.
    #!/bin/sh
    export tb=/usr/bin/mozilla-thunderbird
    $tb -remote "mailto($1?subject=$2)" || exec $tb -P default -compose mailto:$1?subject=$2
    

Suivre le flux des commentaires

Note : les commentaires appartiennent à celles et ceux qui les ont postés. Nous n’en sommes pas responsables.