ME="xdg-autostart"
VERSION="1.0"
-from xdg import BaseDirectory
-from xdg.DesktopEntry import DesktopEntry
-from xdg.Exceptions import ParsingError
import os, glob, sys
+try:
+ from xdg import BaseDirectory
+ from xdg.DesktopEntry import DesktopEntry
+ from xdg.Exceptions import ParsingError
+except ImportError:
+ print
+ print "ERROR:", ME, "requires PyXDG to be installed"
+ print
+ sys.exit(1)
def main(argv=sys.argv):
if "--help" in argv[1:]:
if list: autofile.list(environments)
else: autofile.run(environments)
-class AutostartFile():
+class AutostartFile:
def __init__(self, path):
self.path = path
self.filename = os.path.basename(path)
if self.de.getPath():
os.chdir(self.de.getPath())
if self.shouldRun(envs):
- print "Running autostart file: " + self.path
- os.system(self.de.getExec());
+ args = ["/bin/sh", "-c", "exec " + self.de.getExec()]
+ os.spawnv(os.P_NOWAIT, args[0], args);
os.chdir(here)
def show_help():
print " --version Show version and copyright information"
print
print "ENVIRONMENT specifies a list of environments for which to run autostart"
- print "applications for. If none are specified, only applications which do not "
+ print "applications. If none are specified, only applications which do not "
print "limit themselves to certain environments will be run."
print
print "ENVIRONMENT can be one or more of:"