summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2008-03-02 10:45:28 -0500
committerDana Jansens <danakj@orodu.net>2008-03-02 11:08:57 -0500
commita291ba6019f0cd2e679a302312b50da5769c2790 (patch)
tree2d9e2fa85850a8b0027cbf717e7f78caa9eb91ff
parent664b0b4e943ba4d410168817dcff953804b44253 (diff)
some modifications to xdg-autostart based on suggestions from the PyXDG maintainer
-rw-r--r--tools/xdg-autostart/Makefile4
-rwxr-xr-xtools/xdg-autostart/xdg-autostart43
2 files changed, 25 insertions, 22 deletions
diff --git a/tools/xdg-autostart/Makefile b/tools/xdg-autostart/Makefile
new file mode 100644
index 00000000..cfc46539
--- /dev/null
+++ b/tools/xdg-autostart/Makefile
@@ -0,0 +1,4 @@
+all clean install:
+ $(MAKE) -C ../.. -$(MAKEFLAGS) $@
+
+.PHONY: all clean install
diff --git a/tools/xdg-autostart/xdg-autostart b/tools/xdg-autostart/xdg-autostart
index 95ee5f51..7648d8c4 100755
--- a/tools/xdg-autostart/xdg-autostart
+++ b/tools/xdg-autostart/xdg-autostart
@@ -64,7 +64,7 @@ def main(argv=sys.argv):
# run them !
environments = argv[1:]
for autofile in files:
- if list: autofile.list(environments)
+ if list: autofile.display(environments)
else: autofile.run(environments)
class AutostartFile:
@@ -80,10 +80,10 @@ class AutostartFile:
def __str__(self):
return self.path + " : " + self.de.getName()
- def isexecfile(path):
+ def _isexecfile(path):
return os.access(path, os.X_OK)
- def findFile(self, path, search, match_func):
+ def _findFile(self, path, search, match_func):
# check empty path
if not path: return None
# check absolute path
@@ -96,13 +96,13 @@ class AutostartFile:
candidate = os.path.join(dirname, path)
if (match_func(candidate)): return candidate
- def alert(self, str, info=False):
+ def _alert(self, str, info=False):
if info:
print "\t ", str
else:
print "\t*", str
- def showInEnvironment(self, envs, verbose=False):
+ def _showInEnvironment(self, envs, verbose=False):
default = not self.de.getOnlyShowIn()
noshow = False
force = False
@@ -117,49 +117,48 @@ class AutostartFile:
for i in self.de.getOnlyShowIn():
if s: s += ", "
s += i
- self.alert("Excluded by: OnlyShowIn (" + s + ")")
+ self._alert("Excluded by: OnlyShowIn (" + s + ")")
if default and noshow and not force:
s = ""
for i in self.de.getOnlyShowIn():
if s: s += ", "
s += i
- self.alert("Excluded by: NotShowIn (" + s + ")")
+ self._alert("Excluded by: NotShowIn (" + s + ")")
return (default and not noshow) or force
- def shouldRun(self, envs, verbose=False):
+ def _shouldRun(self, envs, verbose=False):
if not self.de.getExec():
- if verbose: self.alert("Excluded by: Missing Exec field")
+ if verbose: self._alert("Excluded by: Missing Exec field")
return False
if self.de.getHidden():
- if verbose: self.alert("Excluded by: Hidden")
+ if verbose: self._alert("Excluded by: Hidden")
return False
if self.de.getTryExec():
- if not self.findFile(self.de.getTryExec(), os.getenv("PATH"),
- self.isexecfile):
- if verbose: self.alert("Excluded by: TryExec (" +
- self.de.getTryExec() + ")")
+ if not self._findFile(self.de.getTryExec(), os.getenv("PATH"),
+ self._isexecfile):
+ if verbose: self._alert("Excluded by: TryExec (" +
+ self.de.getTryExec() + ")")
return False
- if not self.showInEnvironment(envs, verbose):
+ if not self._showInEnvironment(envs, verbose):
return False
return True
- def list(self, envs):
- running = False
- if self.shouldRun(envs):
+ def display(self, envs):
+ if self._shouldRun(envs):
print "[*] " + self.de.getName()
else:
print "[ ] " + self.de.getName()
- self.alert("File: " + self.path, info=True)
+ self._alert("File: " + self.path, info=True)
if self.de.getExec():
- self.alert("Executes: " + self.de.getExec(), info=True)
- self.shouldRun(envs, True)
+ self._alert("Executes: " + self.de.getExec(), info=True)
+ self._shouldRun(envs, True)
print
def run(self, envs):
here = os.getcwd()
if self.de.getPath():
os.chdir(self.de.getPath())
- if self.shouldRun(envs):
+ if self._shouldRun(envs):
args = ["/bin/sh", "-c", "exec " + self.de.getExec()]
os.spawnv(os.P_NOWAIT, args[0], args);
os.chdir(here)