From a3c4d7c7b6473b989c62c82615f1a8a3af669c55 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Fri, 2 Apr 2021 15:37:55 +0200 Subject: [PATCH 1/4] Remove desktop icon for xdg install --- setup.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/setup.py b/setup.py index d6983c0ca..821634b2a 100755 --- a/setup.py +++ b/setup.py @@ -577,14 +577,6 @@ def xdgInstall(): else: print(f"Error {exCode}: Could not install menu desktop file") - exCode = subprocess.call( - ["xdg-desktop-icon", "install", "--novendor", "./novelwriter.desktop"] - ) - if exCode == 0: - print("Installed icon desktop file") - else: - print(f"Error {exCode}: Could not install icon desktop file") - print("") # Install MimeType @@ -932,11 +924,6 @@ def innoSetup(): # General Installers # ================== - if "launcher" in sys.argv: - sys.argv.remove("launcher") - print("The 'launcher' command has been replaced by 'xdg-install'.") - sys.exit(1) - if "xdg-install" in sys.argv: sys.argv.remove("xdg-install") if hostOS == OS_WIN: From b391d47a400a38b150b5a2e3c9f41883d6c8036a Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Fri, 2 Apr 2021 15:50:20 +0200 Subject: [PATCH 2/4] Add xdg-uninstall option to setup --- setup.py | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/setup.py b/setup.py index 821634b2a..9b7d019cf 100755 --- a/setup.py +++ b/setup.py @@ -641,6 +641,64 @@ def xdgInstall(): 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) ## @@ -873,6 +931,7 @@ def innoSetup(): " install.\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" + " Running 'xdg-uninstall' will remove the icons.\n" " win-install Install desktop and start menu icons for Windows systems.\n" ) @@ -932,6 +991,14 @@ def innoSetup(): else: 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: sys.argv.remove("win-install") if hostOS == OS_WIN: From 3a48a124e294de2b65e20baf38042fcb73f03e60 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Fri, 2 Apr 2021 16:02:40 +0200 Subject: [PATCH 3/4] Linux tests 3.6 and 3.7 should also push to codecov --- .github/workflows/test_linux_3.6.yml | 6 +++++- .github/workflows/test_linux_3.7.yml | 6 +++++- setup.py | 4 ++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_linux_3.6.yml b/.github/workflows/test_linux_3.6.yml index 5f99496ea..a13d7c11b 100644 --- a/.github/workflows/test_linux_3.6.yml +++ b/.github/workflows/test_linux_3.6.yml @@ -26,8 +26,12 @@ jobs: pip install --upgrade pip pip install -r requirements.txt pip install pytest-timeout + pip install pytest-cov pip install pytest-qt + pip install codecov - name: Run Tests run: | export QT_QPA_PLATFORM=offscreen - pytest -v --timeout=60 + pytest -v --cov=nw --timeout=60 + - name: Upload to Codecov + uses: codecov/codecov-action@v1 diff --git a/.github/workflows/test_linux_3.7.yml b/.github/workflows/test_linux_3.7.yml index f057beb66..1b323b9ce 100644 --- a/.github/workflows/test_linux_3.7.yml +++ b/.github/workflows/test_linux_3.7.yml @@ -26,8 +26,12 @@ jobs: pip install --upgrade pip pip install -r requirements.txt pip install pytest-timeout + pip install pytest-cov pip install pytest-qt + pip install codecov - name: Run Tests run: | export QT_QPA_PLATFORM=offscreen - pytest -v --timeout=60 + pytest -v --cov=nw --timeout=60 + - name: Upload to Codecov + uses: codecov/codecov-action@v1 diff --git a/setup.py b/setup.py index 9b7d019cf..022a1247a 100755 --- a/setup.py +++ b/setup.py @@ -635,6 +635,10 @@ def xdgInstall(): else: print(f"Error {exCode}: Could not update icon cache") + # Clean up + if os.path.isfile("./novelwriter.desktop"): + os.unlink("./novelwriter.desktop") + print("") print("Done!") print("") From 96fb892465e8f964b662715f9406c88b17a232f0 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Fri, 2 Apr 2021 16:13:18 +0200 Subject: [PATCH 4/4] Update docs --- docs/source/int_started.rst | 3 ++- docs/source/setup_linux.rst | 13 +++++++++++++ setup/README.md | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/source/int_started.rst b/docs/source/int_started.rst index 385f99fc4..28609c713 100644 --- a/docs/source/int_started.rst +++ b/docs/source/int_started.rst @@ -109,13 +109,14 @@ you're running novelWriter from the source code, a local copy of this documentat generated. It requires the following Python packages on Debian and Ubuntu. * ``python3-sphinx`` +* ``python3-sphinx-rtd-theme`` * ``python3-sphinxcontrib.qthelp`` Or from PyPi: .. code-block:: console - pip install sphinx sphinxcontrib-qthelp + pip install sphinx sphinx-rtd-theme sphinxcontrib-qthelp The documentation can then be built from the ``docs`` folder in the source code by running: diff --git a/docs/source/setup_linux.rst b/docs/source/setup_linux.rst index 7ce99afa4..cf3ee5802 100644 --- a/docs/source/setup_linux.rst +++ b/docs/source/setup_linux.rst @@ -95,3 +95,16 @@ all users, run the script with the ``sudo`` command. .. tip:: All options of the setup script can be listed with: ``./setup.py help``. + + +Uninstalling Icons +================== + +The steps taken by the ``xdg-install`` step can be reversed by running: + +.. code-block:: console + + ./setup.py xdg-uninstall + +This will remove the desktop launcher and icons from the system. As above, whether this is done on +the current user, or system wide, depends on whether this command is called with ``sudo`` or not. diff --git a/setup/README.md b/setup/README.md index 66bfb548c..a2c3f163f 100644 --- a/setup/README.md +++ b/setup/README.md @@ -46,5 +46,6 @@ install. `xdg-install` – Install launcher and icons for freedesktop systems. Run as root or with sudo for system-wide install, or as user for single user install. +Running `xdg-uninstall` will remove the icons. `win-install` – Install desktop and start menu icons for Windows systems.