Commit 6f064ced authored by John Stowers's avatar John Stowers

Revert "Support AutostartCondition in AutostartManager"

This reverts commit 68ee4d51.

This causes infinite looping in the Nautilus desktop case. Revert
until I think of a clean way to prevent that.
parent 6b910cf7
......@@ -21,8 +21,6 @@ import tempfile
import shutil
import gtweak
from gtweak.gsettings import GSettingsSetting
from gtweak.gconf import GConfSetting
from gi.repository import GLib
......@@ -111,17 +109,11 @@ class AutostartManager:
return [os.path.join(d, "applications", self.desktop_filename) for d in dirs]
def get_autostart_condition(self):
for f in self._get_system_autostart_files():
if os.path.exists(f):
with open(f, 'r') as f:
for l in f.readlines():
if l.startswith("AutostartCondition="):
return l.split("=")[-1].strip()
return None
def uses_autostart_condition(self):
return self.get_autostart_condition() != None
for f in self._get_system_autostart_files():
if os.path.exists(f) and open(f).read().find("AutostartCondition=") != -1:
return True
return False
def is_start_at_login_enabled(self):
if os.path.exists(self._user_autostart_file):
......@@ -143,31 +135,15 @@ class AutostartManager:"Removing user autostart file %s" % self._user_autostart_file)
asc = self.get_autostart_condition()
if asc:
#AutostartCondition=GNOME /desktop/gnome/interface/accessibility
#AutostartCondition=GNOME3 if-session gnome-fallback
#AutostartCondition=GSettings org.gnome.desktop.background show-desktop-icons
method, value = asc.split(" ", 1)
try:"Changing AutostartCondition %s -> %s" % (method, update))
if method == "GSettings":
schema, key = value.split(" ")
GSettingsSetting(schema).set_boolean(key, update)
elif method == "GNOME":
GConfSetting(shema, bool).set_value(update)
raise Exception("Method not supported")
logging.warning("Autostart desktop file unsupported AutostartCondition (%s)" % asc, exc_info=True)
if update:
if (not self._desktop_file) or (not os.path.exists(self._desktop_file)):
logging.critical("Could not find desktop file: %s" % self._desktop_file)
if self.uses_autostart_condition():
logging.warning("Autostart desktop file uses AutostartCondition. Skipping")
return"Adding autostart %s" % self._user_autostart_file)
#copy the original file to the new file, but add the extra exec args
old = open(self._desktop_file, "r")
......@@ -188,7 +164,6 @@ class AutostartManager:
if __name__ == "__main__":
gtweak.DATA_DIR = "/usr/share"
gtweak.GSETTINGS_SCHEMA_DIR = "/usr/share/glib-2.0/schemas/"
logging.basicConfig(format="%(levelname)-8s: %(message)s", level=logging.DEBUG)
......@@ -202,14 +177,11 @@ if __name__ == "__main__":
d = AutostartManager("orca.desktop", "orca-autostart.desktop")
print d.desktop_filename, "uses autostartcondition", d.uses_autostart_condition()
print d.desktop_filename, "autostartcondition is:", d.get_autostart_condition()
print d.desktop_filename, "autostarts", d.is_start_at_login_enabled()
print d.desktop_filename, "autostarts", d.is_start_at_login_enabled()
d = AutostartManager("dropbox.desktop")
print d.desktop_filename, "uses autostartcondition", d.uses_autostart_condition()
print d.desktop_filename, "autostarts", d.is_start_at_login_enabled()
d = AutostartManager("nautilus.desktop", "nautilus-autostart.desktop")
print d.desktop_filename, "uses autostartcondition", d.uses_autostart_condition()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment