Skip to content

Commit

Permalink
Use soffice by default, fallback to libreoffice (#139)
Browse files Browse the repository at this point in the history
Co-authored-by: Lennart Regebro <[email protected]>
  • Loading branch information
regebro and Lennart Regebro authored Oct 11, 2024
1 parent 6f8474b commit 1f6a134
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
2.3 (unreleased)
----------------

- Nothing changed yet.

- By default it will now use the `soffice`` executable instead of `libreoffice`,
as I had a problem with it using 100% load when started as `libreoffice`.

2.3b1 (2024-10-09)
------------------
Expand Down
19 changes: 16 additions & 3 deletions src/unoserver/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import argparse
import logging
import os
import shutil
import signal
import socket
import subprocess
Expand Down Expand Up @@ -252,8 +253,8 @@ def main():
parser.add_argument("--daemon", action="store_true", help="Deamonize the server")
parser.add_argument(
"--executable",
default="libreoffice",
help="The path to the LibreOffice executable",
default=None,
help="The path to the LibreOffice executable, defaults to looking in the path",
)
parser.add_argument(
"--user-installation",
Expand Down Expand Up @@ -292,10 +293,22 @@ def main():
user_installation,
)

if args.executable is not None:
executable = args.executable
else:
# Find the executable automatically. I had problems with
# LibreOffice using 100% if started with the libreoffice
# executable, so by default try soffice first. Also throwing
# ooffice in there as a fallback, I don't think it's used any
# more, but it doesn't hurt to have it there.
for name in ("soffice", "libreoffice", "ooffice"):
if (executable := shutil.which(name)) is not None:
break

# If it's daemonized, this returns the process.
# It returns 0 of getting killed in a normal way.
# Otherwise it returns 1 after the process exits.
process = server.start(executable=args.executable)
process = server.start(executable=executable)
if process is None:
return 2
pid = process.pid
Expand Down

0 comments on commit 1f6a134

Please sign in to comment.