Python Nautilus script

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


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/", line 22, in __getitem__
     raise KeyError(key)

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 

Michel Leunen

More information about the Python-list mailing list