@@ -577,14 +577,6 @@ def xdgInstall():
577577 else :
578578 print (f"Error { exCode } : Could not install menu desktop file" )
579579
580- exCode = subprocess .call (
581- ["xdg-desktop-icon" , "install" , "--novendor" , "./novelwriter.desktop" ]
582- )
583- if exCode == 0 :
584- print ("Installed icon desktop file" )
585- else :
586- print (f"Error { exCode } : Could not install icon desktop file" )
587-
588580 print ("" )
589581
590582 # Install MimeType
@@ -643,6 +635,68 @@ def xdgInstall():
643635 else :
644636 print (f"Error { exCode } : Could not update icon cache" )
645637
638+ # Clean up
639+ if os .path .isfile ("./novelwriter.desktop" ):
640+ os .unlink ("./novelwriter.desktop" )
641+
642+ print ("" )
643+ print ("Done!" )
644+ print ("" )
645+
646+ return
647+
648+ ##
649+ # XDG Uninstallation (xdg-uninstall)
650+ ##
651+
652+ def xdgUninstall ():
653+ """Will attempt to uninstall icons and make a launcher.
654+ """
655+ print ("" )
656+ print ("XDG Uninstall" )
657+ print ("=============" )
658+ print ("" )
659+
660+ exCode = subprocess .call (
661+ ["xdg-desktop-menu" , "uninstall" , "novelwriter.desktop" ]
662+ )
663+ if exCode == 0 :
664+ print ("Uninstalled menu desktop file" )
665+ else :
666+ print (f"Error { exCode } : Could not uninstall menu desktop file" )
667+
668+ sizeArr = ["16" , "22" , "24" , "32" , "48" , "64" , "96" , "128" , "256" , "512" ]
669+
670+ # App Icon
671+ for aSize in sizeArr :
672+ exCode = subprocess .call ([
673+ "xdg-icon-resource" , "uninstall" , "--noupdate" ,
674+ "--context" , "apps" , "--size" , aSize , "novelwriter"
675+ ])
676+ if exCode == 0 :
677+ print (f"Uninstalled app icon size { aSize } " )
678+ else :
679+ print (f"Error { exCode } : Could not uninstall app icon size { aSize } " )
680+
681+ # Mimetype
682+ for aSize in sizeArr :
683+ exCode = subprocess .call ([
684+ "xdg-icon-resource" , "uninstall" , "--noupdate" ,
685+ "--context" , "mimetypes" , "--size" , aSize ,
686+ "application-x-novelwriter-project"
687+ ])
688+ if exCode == 0 :
689+ print (f"Uninstalled mime icon size { aSize } " )
690+ else :
691+ print (f"Error { exCode } : Could not uninstall mime icon size { aSize } " )
692+
693+ # Update Cache
694+ exCode = subprocess .call (["xdg-icon-resource" , "forceupdate" ])
695+ if exCode == 0 :
696+ print ("Updated icon cache" )
697+ else :
698+ print (f"Error { exCode } : Could not update icon cache" )
699+
646700 print ("" )
647701 print ("Done!" )
648702 print ("" )
@@ -881,6 +935,7 @@ def innoSetup():
881935 " install.\n "
882936 " xdg-install Install launcher and icons for freedesktop systems. Run as root or \n "
883937 " with sudo for system-wide install, or as user for single user install.\n "
938+ " Running 'xdg-uninstall' will remove the icons.\n "
884939 " win-install Install desktop and start menu icons for Windows systems.\n "
885940 )
886941
@@ -932,11 +987,6 @@ def innoSetup():
932987 # General Installers
933988 # ==================
934989
935- if "launcher" in sys .argv :
936- sys .argv .remove ("launcher" )
937- print ("The 'launcher' command has been replaced by 'xdg-install'." )
938- sys .exit (1 )
939-
940990 if "xdg-install" in sys .argv :
941991 sys .argv .remove ("xdg-install" )
942992 if hostOS == OS_WIN :
@@ -945,6 +995,14 @@ def innoSetup():
945995 else :
946996 xdgInstall ()
947997
998+ if "xdg-uninstall" in sys .argv :
999+ sys .argv .remove ("xdg-uninstall" )
1000+ if hostOS == OS_WIN :
1001+ print ("ERROR: Command 'xdg-uninstall' cannot be used on Windows" )
1002+ sys .exit (1 )
1003+ else :
1004+ xdgUninstall ()
1005+
9481006 if "win-install" in sys .argv :
9491007 sys .argv .remove ("win-install" )
9501008 if hostOS == OS_WIN :
0 commit comments