11#!/usr/bin/env python
22
33
4- # probono 11-2010
4+ # probono 11-2010, 04-2013, 07-2016
55
66
77import os , sys , subprocess , hashlib , urllib , tempfile , shutil
@@ -40,9 +40,9 @@ def __init__(self, path):
4040 self .path = os .path .normpath (os .path .abspath (path ))
4141 self .path_md5 = hashlib .md5 ('file://' + urllib .quote (self .path )).hexdigest ()
4242 self .is_appimage = False
43- self .iconfile_path = os .path .expanduser ('~/.thumbnails/normal/' ) + self .path_md5 + '.png'
44- desktopfiles_location = xxdg .BaseDirectory .xdg_data_home + "/applications/appimage/"
45- self .desktopfile_path = desktopfiles_location + self .path_md5 + ".desktop" # TODO: factor out
43+ self .iconfile_path = os .path .expanduser ('~/.cache/ thumbnails/normal/' ) + self .path_md5 + '.png'
44+ desktopfiles_location = xxdg .BaseDirectory .xdg_data_home + "/applications/" # Subdirectory does not work on GNOME 3
45+ self .desktopfile_path = desktopfiles_location + "appimage-" + self .path_md5 + ".desktop" # TODO: factor out
4646
4747 def check_whether_is_appimage (self ):
4848 "Checks whether the file is an AppImage. TODO: Speed up by not using file"
@@ -91,10 +91,14 @@ def install_desktop_integration(self, parentifthreaded=None):
9191 print "* Installing %s" % (self .desktopfile_path )
9292 #f = open(desktopfile_path, "w")
9393 f = tempfile .NamedTemporaryFile (delete = False )
94- f .write (self .get_file (self .get_desktop_filename ()))
94+ string = self .get_file (self .get_desktop_filename ()).replace ("X-GNOME-FullName" , "X-AppImage-Original-GNOME-FullName" ).replace ("Name[" , "X-AppImage-Original-Name[" ) # Don't use localized names, since we want the filename as the name
95+ print string
96+ f .write (string )
9597 f .close ()
9698 desktop = xxdg .DesktopEntry .DesktopEntry ()
9799 desktop .parse (f .name )
100+ desktop .set ("X-AppImage-Original-Name" , desktop .get ("Name" ))
101+ desktop .set ("Name" , os .path .basename (self .path ))
98102 desktop .set ("X-AppImage-Original-Exec" , desktop .get ("Exec" ))
99103 desktop .set ("X-AppImage-Original-Icon" , desktop .get ("Icon" ))
100104 try :
@@ -112,8 +116,9 @@ def install_desktop_integration(self, parentifthreaded=None):
112116 os .chmod (f .name , 0755 )
113117 print self .desktopfile_path
114118 shutil .move (f .name , self .desktopfile_path ) # os.rename fails when tmpfs is mounted at /tmp
115- if os .env ("KDE_SESSION_VERSION" ) == "4" :
116- timesavers .run_shell_command ("kbuildsycoca4" ) # Otherwise KDE4 ignores the menu
119+ if "KDE_SESSION_VERSION" in os .environ :
120+ if os .environ ["KDE_SESSION_VERSION" ] == "4" :
121+ timesavers .run_shell_command ("kbuildsycoca4" ) # Otherwise KDE4 ignores the menu
117122
118123 def uninstall_desktop_integration (self ):
119124 if os .path .isfile (self .desktopfile_path ):
0 commit comments