Skip to content

Commit 3ee07c7

Browse files
authored
Merge pull request #736 from vkbo/xdg_setup
XDG Setup and Uninstall
2 parents 641ff44 + 96fb892 commit 3ee07c7

File tree

6 files changed

+97
-16
lines changed

6 files changed

+97
-16
lines changed

.github/workflows/test_linux_3.6.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ jobs:
2626
pip install --upgrade pip
2727
pip install -r requirements.txt
2828
pip install pytest-timeout
29+
pip install pytest-cov
2930
pip install pytest-qt
31+
pip install codecov
3032
- name: Run Tests
3133
run: |
3234
export QT_QPA_PLATFORM=offscreen
33-
pytest -v --timeout=60
35+
pytest -v --cov=nw --timeout=60
36+
- name: Upload to Codecov
37+
uses: codecov/codecov-action@v1

.github/workflows/test_linux_3.7.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ jobs:
2626
pip install --upgrade pip
2727
pip install -r requirements.txt
2828
pip install pytest-timeout
29+
pip install pytest-cov
2930
pip install pytest-qt
31+
pip install codecov
3032
- name: Run Tests
3133
run: |
3234
export QT_QPA_PLATFORM=offscreen
33-
pytest -v --timeout=60
35+
pytest -v --cov=nw --timeout=60
36+
- name: Upload to Codecov
37+
uses: codecov/codecov-action@v1

docs/source/int_started.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,14 @@ you're running novelWriter from the source code, a local copy of this documentat
109109
generated. It requires the following Python packages on Debian and Ubuntu.
110110

111111
* ``python3-sphinx``
112+
* ``python3-sphinx-rtd-theme``
112113
* ``python3-sphinxcontrib.qthelp``
113114

114115
Or from PyPi:
115116

116117
.. code-block:: console
117118
118-
pip install sphinx sphinxcontrib-qthelp
119+
pip install sphinx sphinx-rtd-theme sphinxcontrib-qthelp
119120
120121
The documentation can then be built from the ``docs`` folder in the source code by running:
121122

docs/source/setup_linux.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,16 @@ all users, run the script with the ``sudo`` command.
9595

9696
.. tip::
9797
All options of the setup script can be listed with: ``./setup.py help``.
98+
99+
100+
Uninstalling Icons
101+
==================
102+
103+
The steps taken by the ``xdg-install`` step can be reversed by running:
104+
105+
.. code-block:: console
106+
107+
./setup.py xdg-uninstall
108+
109+
This will remove the desktop launcher and icons from the system. As above, whether this is done on
110+
the current user, or system wide, depends on whether this command is called with ``sudo`` or not.

setup.py

Lines changed: 71 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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:

setup/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@ install.
4646

4747
`xdg-install` – Install launcher and icons for freedesktop systems. Run as root
4848
or with sudo for system-wide install, or as user for single user install.
49+
Running `xdg-uninstall` will remove the icons.
4950

5051
`win-install` – Install desktop and start menu icons for Windows systems.

0 commit comments

Comments
 (0)