Add xdg-uninstall option to setup
This commit is contained in:
@@ -641,6 +641,64 @@ def xdgInstall():
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
##
|
||||||
|
# XDG Uninstallation (xdg-uninstall)
|
||||||
|
##
|
||||||
|
|
||||||
|
def xdgUninstall():
|
||||||
|
"""Will attempt to uninstall icons and make a launcher.
|
||||||
|
"""
|
||||||
|
print("")
|
||||||
|
print("XDG Uninstall")
|
||||||
|
print("=============")
|
||||||
|
print("")
|
||||||
|
|
||||||
|
exCode = subprocess.call(
|
||||||
|
["xdg-desktop-menu", "uninstall", "novelwriter.desktop"]
|
||||||
|
)
|
||||||
|
if exCode == 0:
|
||||||
|
print("Uninstalled menu desktop file")
|
||||||
|
else:
|
||||||
|
print(f"Error {exCode}: Could not uninstall menu desktop file")
|
||||||
|
|
||||||
|
sizeArr = ["16", "22", "24", "32", "48", "64", "96", "128", "256", "512"]
|
||||||
|
|
||||||
|
# App Icon
|
||||||
|
for aSize in sizeArr:
|
||||||
|
exCode = subprocess.call([
|
||||||
|
"xdg-icon-resource", "uninstall", "--noupdate",
|
||||||
|
"--context", "apps", "--size", aSize, "novelwriter"
|
||||||
|
])
|
||||||
|
if exCode == 0:
|
||||||
|
print(f"Uninstalled app icon size {aSize}")
|
||||||
|
else:
|
||||||
|
print(f"Error {exCode}: Could not uninstall app icon size {aSize}")
|
||||||
|
|
||||||
|
# Mimetype
|
||||||
|
for aSize in sizeArr:
|
||||||
|
exCode = subprocess.call([
|
||||||
|
"xdg-icon-resource", "uninstall", "--noupdate",
|
||||||
|
"--context", "mimetypes", "--size", aSize,
|
||||||
|
"application-x-novelwriter-project"
|
||||||
|
])
|
||||||
|
if exCode == 0:
|
||||||
|
print(f"Uninstalled mime icon size {aSize}")
|
||||||
|
else:
|
||||||
|
print(f"Error {exCode}: Could not uninstall mime icon size {aSize}")
|
||||||
|
|
||||||
|
# Update Cache
|
||||||
|
exCode = subprocess.call(["xdg-icon-resource", "forceupdate"])
|
||||||
|
if exCode == 0:
|
||||||
|
print("Updated icon cache")
|
||||||
|
else:
|
||||||
|
print(f"Error {exCode}: Could not update icon cache")
|
||||||
|
|
||||||
|
print("")
|
||||||
|
print("Done!")
|
||||||
|
print("")
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# WIN Installation (win-install, launcher)
|
# WIN Installation (win-install, launcher)
|
||||||
##
|
##
|
||||||
@@ -873,6 +931,7 @@ if __name__ == "__main__":
|
|||||||
" install.\n"
|
" install.\n"
|
||||||
" xdg-install Install launcher and icons for freedesktop systems. Run as root or \n"
|
" xdg-install Install launcher and icons for freedesktop systems. Run as root or \n"
|
||||||
" with sudo for system-wide install, or as user for single user install.\n"
|
" with sudo for system-wide install, or as user for single user install.\n"
|
||||||
|
" Running 'xdg-uninstall' will remove the icons.\n"
|
||||||
" win-install Install desktop and start menu icons for Windows systems.\n"
|
" win-install Install desktop and start menu icons for Windows systems.\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -932,6 +991,14 @@ if __name__ == "__main__":
|
|||||||
else:
|
else:
|
||||||
xdgInstall()
|
xdgInstall()
|
||||||
|
|
||||||
|
if "xdg-uninstall" in sys.argv:
|
||||||
|
sys.argv.remove("xdg-uninstall")
|
||||||
|
if hostOS == OS_WIN:
|
||||||
|
print("ERROR: Command 'xdg-uninstall' cannot be used on Windows")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
xdgUninstall()
|
||||||
|
|
||||||
if "win-install" in sys.argv:
|
if "win-install" in sys.argv:
|
||||||
sys.argv.remove("win-install")
|
sys.argv.remove("win-install")
|
||||||
if hostOS == OS_WIN:
|
if hostOS == OS_WIN:
|
||||||
|
|||||||
Reference in New Issue
Block a user