Python Nautilus script

Michel Leunen michel at nospam.please
Mon Sep 15 15:21:16 EDT 2008


Hi,

I'm trying to write a python script for Nautilus.
To get the list of files selected in the Nautilus right pane, you use 
the $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS environment variable which is 
normally available to the script. Actually, it works with bash scripts 
but not with python scripts

import os
files = os.environ['NAUTILUS_SCRIPT_SELECTED_FILE_PATHS'].splitlines()

gives a:

File "<stdin>", line 1, in <module>
   File "/usr/lib/python2.5/UserDict.py", line 22, in __getitem__
     raise KeyError(key)
KeyError: 'NAUTILUS_SCRIPT_SELECTED_FILE_PATHS'

Fredrik Lundh explained me that all environment variables are not 
accessible from subprocesses of an application.

So my question is how can I get the Nautilus selected files in a python 
script?

Thanks,
Michel
-- 
Michel Leunen
http://linux.leunen.com



More information about the Python-list mailing list