Fix bug where .desktop file can't be made due to missing autostart directory

Added a check for ~/.config/autostart/ If if doesn't exist, make it.
This commit is contained in:
AltF4 2014-01-04 20:13:51 -07:00
parent c74a5198c5
commit f09333305b

View File

@ -52,6 +52,7 @@ startup_active_label = "✓ Start Automatically"
startup_inactive_label = "Start Automatically"
home_path = os.path.expanduser("~")
startup_path = home_path+'/.config/autostart/pinger.desktop'
startup_dir = home_path+'/.config/autostart/'
parser = argparse.ArgumentParser()
parser.add_argument("-t", "--target", help="Target to PING against. (IP / Hostname / Domain name). Defaults to 4.2.2.2")
@ -135,6 +136,8 @@ class Pinger:
Gtk.main_quit()
def create_autostart(self, widget, data=None):
if not os.path.exists(startup_dir):
os.makedirs(startup_dir)
with open(startup_path,'w') as f:
f.write("[Desktop Entry]\r\n"
"Type=Application\r\n"