Force Mendeley Desktop GTK theme
I've been trying for a while to set the GTK theme of the Mendeley desktop UI, without success. The reason I want to do this is because I am using a dark theme, and that Mendeley is unreadable (dark font on dark bg) with this theme. The two relevant sources of information I'm using are here and here.
They both basically say that calling an executable like so
$ GTK_THEME=MyFancyTheme my_stubborn_app
should override the default GTK theme for the current user, and that permanent theme changes can be integrated in the .../share/my_stubborn_app.desktop
by altering the EXEC
line:
Exec=env GTK_THEME=MyFancyTheme /path/to/my_stubborn_app %u
None of these methods works in my case. The special things about Mendeley desktop UI on Ubuntu (Trusty Tahr 14.04, Mendeley UI v1.14 in my case) are:
- It comes as a standalone package with its own
bin
andshare
andlib
folders and it uses Qt. - The actual binary is in
lib/mendeleydesktop/libexec/mendeleydesktop.x86_64
(for Ubuntu 64 bits) but cannot be called directly because it requires environment variables defined by the python scriptbin/mendeleydesktop
. - The
mendeleydesktop.desktop
file (which allows having an icon in the Unity launcher) is overwritten bybin/install-mendeley-link-handler.sh
each timebin/mendeleydesktop
is called. - This
mendeleydesktop.desktop
file is created/overwritten in$HOME/.local/share/applications
.
What I did so far was to edit bin/install-mendeley-link-handler.sh
so that the .desktop
file overwritten at each call would include the modified Exec=env GTK_THEME...
line. That doesn't seem to work. Can anyone help?
Solution 1:
I finally managed to get it done, although it feels a bit clunky. In the following:
-
$MENDELEY_FOLDER
is the Mendeley folder, -
$CURRENT_GTK_THEME
is the name of the GTK theme you are currently using -
$MENDELEY_GTK_THEME
is the name of the theme you'd like to use with Mendeley
NOTE: To get the name of the theme that you are currently using, type gsettings get org.gnome.desktop.interface gtk-theme
in a terminal. A good theme to be using with Mendeley is Ambiance
.
Create a new themes directory
We will essentially trick Mendeley into thinking that the root GTK themes folder is somewhere else.
mkdir $MENDELEY_FOLDER/share/themes/
ln -s /usr/share/themes/$MENDELEY_GTK_THEME $MENDELEY_FOLDER/share/themes/$CURRENT_GTK_THEME
Modify the script install-mendeley-link-handler.sh
It should be located in $MENDELEY_FOLDER/bin/install-mendeley-link-handler.sh
.
You need to edit the lines that overwrite the file mendeleydesktop.desktop
, in my case:
cat > $DESKTOP_PATH/mendeleydesktop.desktop <<EOF
[Desktop Entry]
Name=Mendeley Desktop
GenericName=Research Paper Manager
Comment=Mendeley Desktop is software for managing and sharing research papers
Exec=env GTK_DATA_PREFIX=$MENDELEY_FOLDER $MENDELEYDESKTOP_BIN %u
Icon=mendeleydesktop
Terminal=false
Type=Application
Categories=Education;Literature;Qt;
X-SuSE-translate=false;
MimeType=x-scheme-handler/mendeley;application/pdf;text/x-bibtex;
X-Mendeley-Version=1
EOF
Notice the change in the Exec=...
line.
Create a new mendeley executable
Wherever you keep your local binaries (eg $HOME/local/bin
), create a new file mendeley
with the following:
GTK_DATA_PREFIX=$MENDELEY_FOLDER \
$MENDELEY_FOLDER/bin/mendeleydesktop
Then make it executable by running chmod +x mendeley
, and run it in order to update the mendeleydesktop.desktop
file.
If you installed Mendeley system-wide
The last step is only slightly different, in that the system-wide script (most likely located in /opt/mendeleydesktop
) actually creates a link to the mendeleydesktop
executable in $HOME/.local/share
, and that is what the previous script needs to call instead.
Applying those changes to the Unity icon
The file to edit should be /usr/share/applications/mendeleydesktop.desktop
.
In this file, you should modify the Exec
line as previously, by prefixing the call with the definition of GTK_DATA_PREFIX
. This should do the trick :)
Solution 2:
I would like to add an answer that has worked well for me on kde plasma (manjaro linux). It does not require any admin rights.
disclaimer: only tested once on my system on 2018-12-04 with Mendeley 1.19,
commands below and results may vary with different DE and/or OS or different Mendeley version.
- create an empty folder, e.g.
mkdir $HOME/.config.theme_override
. - symlink your Mendeley config to the new folder:
ln -s "$HOME/.config/Mendeley Ltd." "$HOME/.config.theme_override/Mendeley Ltd."
- start mendeleydesktop from the command line using:
XDG_CONFIG_HOME="$HOME/.config.theme_override" mendeleydesktop
Then mendeley will look for plasma theme settings in $HOME/.config.theme_override
, it will not find any theme and fall back to the readable bright theme.
Now the desktop entry:
- make sure mendeley is closed
- edit the file
$HOME/.local/share/applications/mendeleydesktop.desktop
to look like (**) below - remove write permission from the
.desktop
file:chmod -w $HOME/.local/share/applications/mendeleydesktop.desktop
- start mendeleydesktop from the app launcher and gaze at the clear and readable interface.
A few notes/insights to help future detectives:
- The default Mendeley config folder is
$HOME/.config/Mendeley Ltd.
, changing your config folder does not change where the Mendeley database is located ($HOME/.local/share/data/Mendeley Ltd.
). - Mendeley also stores some data in
$HOME/.local/share/Mendeley Ltd.
and$HOME/.cache/Mendeley Ltd.
, changing the config folder does not change where Mendeley looks for these folders. It looks like these folders can be removed without risk and Mendeley will restore them automatically. If the stuff above does not work for changing the theme, then maybe removing these folders can help, but I'm not sure, proceed at your own risk. - Each time Mendeley is started, a script is run to override the
.desktop
file, which is the file that makes mendeley show up in application menus and launchers. This why we needed step (3.) above. This file is located at:$HOME/.local/share/applications/mendeleydesktop.desktop
, it will execute the file$HOME/.local/share/mendeleydesktop
, which by default is symlinked to/opt/mendeleydesktop/bin/mendeleydesktop
. Don't ask me why Mendeley developers chose this complicated setup.
(** contents of $HOME/.local/share/applications/mendeleydesktop.desktop
)
[Desktop Entry]
Name=Mendeley Desktop
GenericName=Research Paper Manager
Comment=Mendeley Desktop is software for managing and sharing research papers
Exec=env XDG_CONFIG_HOME="$HOME/.config.theme_override" $HOME/.local/share/mendeleydesktop %f
Icon=mendeleydesktop
Terminal=false
Type=Application
Categories=Education;Literature;Qt;
X-SuSE-translate=false
MimeType=x-scheme-handler/mendeley;application/pdf;text/x-bibtex;
X-Mendeley-Version=1