# HG changeset patch # User paulb # Date 1127814770 0 # Node ID 8302c45842c4330896eaa2f9d8b5d15a462340fb # Parent 228f0d640f42ca393e525294bfa4eacd5b0f64d1 [project @ 2005-09-27 09:52:49 by paulb] Improved DESKTOP_LAUNCH opening by using the shell and by quoting URLs. Added examples of DESKTOP_LAUNCH which should not break the implementation. diff -r 228f0d640f42 -r 8302c45842c4 README.txt --- a/README.txt Mon Sep 26 12:09:52 2005 +0000 +++ b/README.txt Tue Sep 27 09:52:50 2005 +0000 @@ -8,3 +8,10 @@ ROX-Filer Supports file opening using "rox " but not URL opening. + +Usage of the DESKTOP_LAUNCH environment variable: + +DESKTOP_LAUNCH="kdialog --msgbox" Should present any opened URLs in + their entirety in a message box. +DESKTOP_LAUNCH="test\ this" Should run the "test this" program to + open URLs. diff -r 228f0d640f42 -r 8302c45842c4 desktop.py --- a/desktop.py Mon Sep 26 12:09:52 2005 +0000 +++ b/desktop.py Tue Sep 27 09:52:50 2005 +0000 @@ -16,6 +16,7 @@ import os import sys import subprocess +import commands def get_desktop(): @@ -56,7 +57,8 @@ Suggested values for 'desktop' are "standard", "KDE", "GNOME", "Mac OS X", "Windows" where "standard" employs a DESKTOP_LAUNCH environment variable to - open the specified 'url'. + open the specified 'url'. DESKTOP_LAUNCH should be a command, possibly + followed by arguments, and must have any special characters shell-escaped. The process identifier of the "opener" (ie. viewer, editor, browser or program) associated with the 'url' is returned by this function. If the @@ -70,9 +72,8 @@ # Start with desktops whose existence can be easily tested. if (desktop is None or desktop == "standard") and is_standard(): - # NOTE: This may not handle sophisticated commands properly. - cmd = os.environ["DESKTOP_LAUNCH"].split() - cmd.append(url) + arg = "".join([os.environ["DESKTOP_LAUNCH"], commands.mkarg(url)]) + return subprocess.Popen(arg, shell=1).pid elif (desktop is None or desktop == "Windows") and detected == "Windows": # NOTE: This returns None in current implementations.