2
from gi.repository import Gio
8
APP_ID = 'pandorapandoracom'
10
def get_local_applications_path():
11
return os.path.join(glib.get_user_data_dir(), 'applications')
13
def update_desktop_file_exec_line():
14
local_applications_path = get_local_applications_path()
15
if not os.path.exists(local_applications_path) or not os.path.isdir(local_applications_path):
18
desktop_filename = os.path.join(local_applications_path, '{0}.desktop'.format(APP_ID))
19
if not os.path.exists(desktop_filename) or not os.path.isfile(desktop_filename):
23
desktop_file_content = open(desktop_filename).read()
24
if desktop_file_content.find('unity-webapps-runner') != -1:
25
updated_desktop_file_content = re.sub(r"Exec\s*=\s*unity-webapps-runner\s*-n\s*'([^\s]*)'.*%u",
26
r"Exec=webbrowser-app --chromeless --webapp='\1' --app-id='{0}'".format(APP_ID),
28
open(desktop_filename, "w+").write(updated_desktop_file_content)
30
print 'Error while upgrading the desktop file: ', str(e)
32
if __name__ == "__main__":
33
update_desktop_file_exec_line()