Merge pull request #170809 from hqurve/libreoffice-dolphin

libreoffice: add templates to dolphin "create new" menu
This commit is contained in:
7c6f434c 2022-05-04 15:52:02 +00:00 committed by GitHub
commit 36b9c0594c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 12 deletions

View file

@ -0,0 +1,6 @@
[Desktop Entry]
Name=LibreOffice @app@...
Comment=Enter LibreOffice @app@ filename:
Type=Link
URL=.source/soffice.@ext@
Icon=libreoffice-oasis-@type@

View file

@ -1,19 +1,32 @@
{ libreoffice, runCommand, dbus, bash }:
let
jdk = libreoffice.jdk;
in
(runCommand libreoffice.name {
inherit dbus libreoffice jdk bash;
} ''
{ lib, runCommand
, libreoffice, dbus, bash, substituteAll
, dolphinTemplates ? true
}:
runCommand libreoffice.name {
inherit (libreoffice) jdk meta;
inherit dbus libreoffice bash;
} (''
mkdir -p "$out/bin"
ln -s "${libreoffice}/share" "$out/share"
substituteAll "${./wrapper.sh}" "$out/bin/soffice"
chmod a+x "$out/bin/soffice"
for i in $(ls "${libreoffice}/bin/"); do
test "$i" = "soffice" || ln -s soffice "$out/bin/$(basename "$i")"
done
'') // {
inherit libreoffice dbus;
meta = libreoffice.meta;
}
mkdir -p "$out/share"
ln -s "${libreoffice}/share"/* $out/share
'' + lib.optionalString dolphinTemplates ''
# Add templates to dolphin "Create new" menu - taken from debian
# We need to unpack the core source since the necessary files aren't available in the libreoffice output
unpackFile "${libreoffice.src}"
install -D "${libreoffice.name}"/extras/source/shellnew/soffice.* --target-directory="$out/share/templates/.source"
cp ${substituteAll {src = ./soffice-template.desktop; app="Writer"; ext="odt"; type="text"; }} $out/share/templates/soffice.odt.desktop
cp ${substituteAll {src = ./soffice-template.desktop; app="Calc"; ext="ods"; type="spreadsheet"; }} $out/share/templates/soffice.ods.desktop
cp ${substituteAll {src = ./soffice-template.desktop; app="Impress"; ext="odp"; type="presentation";}} $out/share/templates/soffice.odp.desktop
cp ${substituteAll {src = ./soffice-template.desktop; app="Draw"; ext="odg"; type="drawing"; }} $out/share/templates/soffice.odg.desktop
'')