4

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 and share and lib 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 script bin/mendeleydesktop.
  • The mendeleydesktop.desktop file (which allows having an icon in the Unity launcher) is overwritten by bin/install-mendeley-link-handler.sh each time bin/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?

4 Answers4

4

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 :)

  • confirm! works with new gnome too, default Adwaita also looks good – MInner Oct 11 '17 at 16:12
  • Thanks for the comprehensive writeup! Would you mind sharing a screenshot to show what it looks like before I jump in? – Hatshepsut Oct 18 '17 at 03:41
  • Hi, Thnaks for your tutorial. This is not working for me. Can you kindly check https://unix.stackexchange.com/questions/438437/dark-theme-for-mendeley – BaRud Apr 18 '18 at 05:03
  • @BaRud You should read more carefully. The target of a link is not the same as its name. And your env-var is wrongly set. – Jonathan H Apr 18 '18 at 14:40
3

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.

  1. create an empty folder, e.g.
    mkdir $HOME/.config.theme_override.
  2. symlink your Mendeley config to the new folder:
    ln -s "$HOME/.config/Mendeley Ltd." "$HOME/.config.theme_override/Mendeley Ltd."
  3. 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:

  1. make sure mendeley is closed
  2. edit the file $HOME/.local/share/applications/mendeleydesktop.desktop to look like (**) below
  3. remove write permission from the .desktop file:
    chmod -w $HOME/.local/share/applications/mendeleydesktop.desktop
  4. 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
Adam
  • 103
  • This fix worked great for me for several months. It seems a recent Mendeley update (1.19.4) seems to have broken it again unfortunately. – Dzinic Apr 25 '19 at 15:52
  • 1
    Hi, I used this fix again today with mendeley 1.19.4 on kubuntu 19.10 and it still worked. So it might be worth giving it another try :) – Sam De Meyer Feb 08 '20 at 17:52
0

I did this in a slightly different way. My KDE Plasma style was set as Breeze Dark with some custom font size settings. I wanted mendeleydesktop to use all these font size settings but not the dark color settings.

As suggested in the posts above, I created an empty folder:

mkdir $HOME/.config.theme_override

Then, I run

XDG_CONFIG_HOME="$HOME/.config.theme_override" mendeleydesktop

...to see which folders it will use on default in its config folder. It turned out that, in my case, mendeleydesktop created three new folders in $HOME/.config.theme_override:

libreoffice  'Mendeley Ltd.'   pulse

I removed these new folders:

rmdir libreoffice

rmdir 'Mendeley Ltd.'

rmdir pulse

and I replaced them with symlinks to the corresponding old folders in $HOME/.config:

ln -s "$HOME/.config/Mendeley Ltd." "$HOME/.config.theme_override/Mendeley Ltd."

ln -s "$HOME/.config/libreoffice" "$HOME/.config.theme_override/libreoffice"

ln -s "$HOME/.config/pulse" "$HOME/.config.theme_override/pulse"

Next, I copied the kdeglobals file from $HOME/.config to $HOME/.config.theme_override:

cp $HOME/.config/kdeglobals $HOME/.config.theme_override/

Finally, I removed all sections about colors from $HOME/.config.theme_override/kdeglobals:

[ColorEffects:Inactive]
ChangeSelectionColor=true
Color=112,111,110
ColorAmount=0.025
ColorEffect=2
ContrastAmount=0.1
ContrastEffect=2
Enable=false
IntensityAmount=0
IntensityEffect=0

[Colors:Button]
BackgroundAlternate=77,77,77
BackgroundNormal=49,54,59
DecorationFocus=61,174,233
DecorationHover=61,174,233
ForegroundActive=61,174,233
ForegroundInactive=189,195,199
ForegroundLink=41,128,185
ForegroundNegative=218,68,83
ForegroundNeutral=246,116,0
ForegroundNormal=239,240,241
ForegroundPositive=39,174,96
ForegroundVisited=127,140,141

[Colors:Complementary]
BackgroundAlternate=59,64,69
BackgroundNormal=49,54,59
DecorationFocus=30,146,255
DecorationHover=61,174,230
ForegroundActive=246,116,0
ForegroundInactive=175,176,179
ForegroundLink=61,174,230
ForegroundNegative=237,21,21
ForegroundNeutral=201,206,59
ForegroundNormal=239,240,241
ForegroundPositive=17,209,22
ForegroundVisited=61,174,230

[Colors:Selection]
BackgroundAlternate=29,153,243
BackgroundNormal=61,174,233
DecorationFocus=61,174,233
DecorationHover=61,174,233
ForegroundActive=252,252,252
ForegroundInactive=239,240,241
ForegroundLink=253,188,75
ForegroundNegative=218,68,83
ForegroundNeutral=246,116,0
ForegroundNormal=239,240,241
ForegroundPositive=39,174,96
ForegroundVisited=189,195,199

[Colors:Tooltip]
BackgroundAlternate=77,77,77
BackgroundNormal=49,54,59
DecorationFocus=61,174,233
DecorationHover=61,174,233
ForegroundActive=61,174,233
ForegroundInactive=189,195,199
ForegroundLink=41,128,185
ForegroundNegative=218,68,83
ForegroundNeutral=246,116,0
ForegroundNormal=239,240,241
ForegroundPositive=39,174,96
ForegroundVisited=127,140,141

[Colors:View]
BackgroundAlternate=49,54,59
BackgroundNormal=35,38,41
DecorationFocus=61,174,233
DecorationHover=61,174,233
ForegroundActive=61,174,233
ForegroundInactive=189,195,199
ForegroundLink=41,128,185
ForegroundNegative=218,68,83
ForegroundNeutral=246,116,0
ForegroundNormal=239,240,241
ForegroundPositive=39,174,96
ForegroundVisited=127,140,141

[Colors:Window]
BackgroundAlternate=77,77,77
BackgroundNormal=49,54,59
DecorationFocus=61,174,233
DecorationHover=61,174,233
ForegroundActive=61,174,233
ForegroundInactive=189,195,199
ForegroundLink=41,128,185
ForegroundNegative=218,68,83
ForegroundNeutral=246,116,0
ForegroundNormal=239,240,241
ForegroundPositive=39,174,96
ForegroundVisited=127,140,141

With the above sections removed, mendeleydesktop uses its own colors and not the KDE Plasma style colors but it uses all other style settings from $HOME/.config.theme_override/kdeglobals.

0

A little update here: A quick update solution to read in dark mode in Ubuntu now is using Gnome Extension Inverted Color.

enter image description here

Then, you can toggle the application screen between dark and light by Super + I

enter image description here

dtlam26
  • 111