How to launch LibreOffice with a defined Environment Variable?

Hi
I got some problems running Libreoffice in wayland, some context menus got lost under the screen and some other buttons. Using the command line I launched it with the enviroment variable GDK_DPI_SCALE=0.89 and got all the hidden buttons. Now how do I set Libreoffice to always use that variable? I tried in the .desktop but it didn’t worked.

it would have been nice to know what you tried in the .desktop file.

the “Exec” line in the .desktop file should look something like;

Exec=env GDK_DPI_SCALE="0.89" libreoffice

additionally you will have to copy .desktop file to ~/.local/share/applications/ for it to persist across package updates.

Exec=env GDK_DPI_SCALE=“0.89” libreoffice --base %U

It’s not launching with those parameters, I even refreshed the menus

This is syntactically two commands - it will likely not work as expected - it will be parsed as two arguments for env command

Since you are using GDK I assume you are using a Gnome desktop as the variable does not work for Plasma

Exec=GDK_DPI_SCALE="0.89" libreoffice --writer %U

Or

Exec=env GDK_DPI_SCALE="0.89" && libreoffice --writer %U
2 Likes

yes i think rather than calling the base app its better use it on .desktop for actual apps i.e. writer,calc, etc.

Tried again with both commands. Still not launching with the correct variables. Now the Menu entries are missing when using:

Exec=GDK_DPI_SCALE="0.89" libreoffice --writer %U

Exec=env GDK_DPI_SCALE="0.89" libreoffice --calc %U

This worked, but libreoffice startcenter still launches without the environment variables.

I’ll just install the flatpak and set the environment variables in flatseal.

As explanined above such command won’t work because all appended words are read as arguments for env command

Exec=env GDK_DPI_SCALE="0.89" && libreoffice --calc %U

Also mentioned above GDK env variables won’t affect Qt based apps - at least not on my Plasma based system - and judging from your profile you are using Plasma - which it QT based.

I just used writer as an example because the base command libreoffice only provides a portal and I wanted to see if the variable brought any change to apps iconband

AFAIK you should use full paths in .desktop files. So try with:

Exec=/usr/bin/env GDK_DPI_SCALE="0.89" && /usr/bin/libreoffice --calc %U

Or:

Exec=/usr/bin/sh -c "env GDK_DPI_SCALE='0.89' && libreoffice --calc"

Edit:

As a side question, I’ve always gotten an error when I suffix the libreoffice commands with %U, as they’re in the Launcher. For example:

Exec=libreoffice --impress %U

Like this:

https://i.imgur.com/iwS2hpt.png
/%U does not exist.

… and then just doesn’t start. But everything works :100: if I launch it with from the launcher, or if I remove the %U when running it from the terminal. So my guess is that it’s something KDE-specfic. That’s why I removed them from my sample commands.

Edit #2:

Never mind. Seems it’s part of the .desktop file specification. As per

https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html

%U: A list of URLs. Each URL is passed as a separate argument to the executable program. Local files may either be passed as file: URLs or as file path.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.