Chrome UI size & zoom levels in Ubuntu 16.04
I figured this out, thanks in part to the Angel who wrote this.
tl;dr: do this:
- Go to your Settings -> Displays
- Note what the value of the slider is at "Scale for menu and title bars" (mine was 1.5)
- Open a terminal
sudo gedit /usr/share/applications/google-chrome.desktop
- Find this line (at approx 108):
Exec=/usr/bin/google-chrome-stable %U
- Change it to this (where
n
is the value you noted in step #2):
Exec=/usr/bin/google-chrome-stable --force-device-scale-factor=n %U
- Save/close, relaunch Chrome.
Unfortunately this doesn't seem to work with VS Code, but that's less of an issue, as you can simply zoom out (View Menu -> Zoom Out), and it affects the entire UI.
Explanation: Ubuntu applies a system-wide scaling factor to the UI in hi-DPI monitors. Chrome thinks it's so special, so it ignores that and does its own thing.
The link above recommends changing to a 1
scaling factor, but this is the equivalent of 0
scaling (not OK for hi-dpi).
By mirroring the system scale factor, you bring Chrome in-line w/ everything else.
I managed to get Chrome to auto-scale to the same scale I'm using in gnome desktop by doing the following:
I created a bash script at /usr/bin/chrome-scaled
:
#!/bin/bash text_scale=$(gsettings get org.gnome.desktop.interface text-scaling-factor) /usr/bin/google-chrome-stable --high-dpi-support=1 --force-device-scale-factor=$text_scale %U
And then I created a new desktop shortcut at /user/share/applications/chrome-scaled.desktop
:
[Desktop Entry] Version=1.0 Name=Google Chrome GenericName=Web Browser Comment=Access the Internet Exec=/usr/bin/chrome-scaled Terminal=false Icon=google-chrome Type=Application Categories=Network;WebBrowser; MimeType=text/html;text/xml;application/xhtml_xml;image/webp;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp; X-Ayatana-Desktop-Shortcuts=NewWindow;NewIncognito Name[en_CA]=Chrome Scaled
Then I opened the shortcut and locked it to my launcher. Now, whatever scale you're using in gnome will also be used in Chrome.
You could also potentially avoid creating the new .desktop file and just edit the google-chrome.desktop
file instead.
The problem still persists when using Google Chrome under Ubuntu 18.04.
I didn't want to touch the system-wide desktop file (which I believe may get overridden by a Chrome update), so I've edited the Chrome launcher using the Alacarte menu editor, adding the --force-device-scale-factor=n
as Brandon has instructed.
It worked, but only for launching Chrome from the overview. When launching it from the dock, the scale factor override was disregarded, and all the fonts were again small.
To fix it, I've edited the ~/.local/share/applications/google-chrome.desktop
(created probably by Alacarte), inserting --force-device-scale-factor=n
in every line after Exec=/usr/bin/google-chrome-stable
- there are three such lines in the desktop file, and Alacarte only altered the first, but not those for "New Window" and "New Incognito Window".
Now the font dpi override works even when launching Chrome from the dock, and I haven't had to alter files as root.
Try adding:
Exec=/usr/bin/google-chrome-stable --force-device-scale-factor=0.8 %U
in chrome.desktop
file and fonts in tabs and menu look nice.