[HN Gopher] A few HiDPI tricks for Linux
       ___________________________________________________________________
        
       A few HiDPI tricks for Linux
        
       Author : woodruffw
       Score  : 67 points
       Date   : 2021-01-30 17:01 UTC (6 hours ago)
        
 (HTM) web link (blog.yossarian.net)
 (TXT) w3m dump (blog.yossarian.net)
        
       | xolve wrote:
       | I am using Retina display on which everything looks tiny. I
       | struggled with setting up QT scaling, GTK3.0 scaling, icon sizes,
       | font DPI and resolutions. The problem is there is no single
       | setting which all UI libraries follow and this makes your life
       | hell.
       | 
       | Even worse is when you connect an external monitor which is not
       | HiDPI and now everything is bigger than usual.
       | 
       | Instead scale the whole display and this works perfectly. I have
       | explained it here:
       | https://np.reddit.com/r/linuxquestions/comments/4c2o4p/what_...
       | (Except one hiccup, but its way better than tuning inidividual
       | knobs)
       | 
       | I have added the command to /etc/X11/xinit/xinitrc so it scales
       | automatically when I login:
       | 
       | xrandr --output eDP1 --scale 0.60x0.60
        
         | scooble wrote:
         | > Even worse is when you connect an external monitor which is
         | not HiDPI and now everything is bigger than usual.
         | 
         | This has been a real bugbear for me. I'm a big fan of small
         | sharp bitmap terminal fonts, but as my new laptop is now the
         | same resolution as my external monitor I have a choice between
         | comically small on the laptop display or comically huge on the
         | monitor.
        
         | ironmagma wrote:
         | The question is, how do we fix this? Is there a best setting to
         | use, and if not, who will join the working group to define one?
        
           | wmf wrote:
           | It's fixed in Wayland.
        
             | glandium wrote:
             | Is it intrinsically fixed, or is it up to the compositor to
             | do the right thing? (implying it may be broken in some
             | compositors)
        
               | BearOso wrote:
               | There's only integral buffer scales, so it's entirely up
               | to the compositor or client to do fractional scaling.
               | 
               | https://wayland-
               | client-d.dpldocs.info/wayland.client.protoco...
        
               | glandium wrote:
               | I don't know anything about the wayland API. Does this
               | imply that windows can't have a different scaling on each
               | screen they may overlap on? Or can a window be split
               | across different surfaces?
        
         | makeworld wrote:
         | What if you want to display a pixel-perfect image? Perhaps this
         | a rare use case, but it's important for some things, like
         | dithering. Is there any way for you display an image where
         | every pixel matches up to a display pixel?
        
       | 29athrowaway wrote:
       | My settings are:
       | 
       | GTK2 apps do not support HiDPI correctly. oomox (and similar) can
       | be used to generate a scaled GTK2 theme, but it won't solve all
       | your problems.
       | 
       | GTK3 supports HiDPI well. If you use Gnome, Xfce and others, you
       | can configure this via the preferences UI. Otherwise, add this to
       | your .profile file:                   export GDK_SCALE=2
       | export GDK_DPI_SCALE=0.5
       | 
       | Many Java apps can be scaled by adding an argument...
       | java -Dsun.java2d.uiScale=2
       | 
       | For Qt you can add this to your .profile file:
       | export QT_AUTO_SCREEN_SCALE_FACTOR=0         export
       | QT_SCALE_FACTOR=2              # For theming, requires qt5ct
       | export QT_QPA_PLATFORMTHEME=qt5ct
       | 
       | For Spotify... I use ncspot for listening, and the web version to
       | manage my playlists (although you can also management with
       | ncspot). ncspot is a keyboard friendly, lightweight terminal
       | client.                   https://github.com/hrkfdn/ncspot
       | 
       | I use FreeOffice as office suite, you can configure HiDPI through
       | the menus and works perfectly. Same with Steam.
        
       | arendtio wrote:
       | Setting the DisplaySize in a /etc/X11/xorg.conf.d/90-monitor.conf
       | is the way I like solving the DPI issue. The advantage is, that
       | even the display manager (in my case SDDM) runs with the correct
       | DPI.
       | 
       | If you want to find the correct dimensions for you monitor, this
       | page might help you:
       | 
       | https://www.displayspecifications.com
        
       | gorgoiler wrote:
       | Nice.
       | 
       | If you, like me, are blind as a bat may I recommend
       | `Xcursor.size` as well.
       | 
       | Anyone know how to get mouse cursor comet trails in Linux?
        
       | KirillPanov wrote:
       | If anybody knows how to forcibly override the "pixels per mm"
       | reported by a monitor, you will be my hero forever.
       | 
       | Every solution I've found so far (including the QT/GTK
       | environment variables for overriding DPI) ends up instead causing
       | scaling during compositing, rather than getting the apps to
       | rasterize their fonts at the correct size in the first place. The
       | worst offenders are anything derived from Chromium (i.e.
       | qutebrowser, who say the problem is a QtWebEngine bug that they
       | can't fix).
       | 
       | I'm using sway, but almost all the Wayland compositors lack this
       | override-the-monitor-reported-DPI functionality, because (for
       | good reason) their philosophy is to securely multiplex the
       | hardware, not abstract it away. They just pass through whatever
       | values the monitor reports, to the client.
       | 
       | IMHO this does not make sense for physical pixel size, because it
       | disregards the physical distance between the user's face and the
       | pixels. What you _really_ want to size your fonts based on is the
       | number of _arc-radians_ (or arc-degrees) per pixel, measured at
       | the user 's eyeball. In order to compute that you need to know
       | both the physical pixel size (which can be queried from the
       | device) and the physical eyeball-screen distance (which will need
       | to be user-configurable).
        
       | podiki wrote:
       | Some other resources that may be helpful for anyone looking is
       | (of course) the Arch wiki [0]. I also found it helpful to set
       | somethings like DPI based on the machine (I share my dot files
       | across my computers) which can be done pretty easily using e.g.
       | the hostname [1]. (Note that GitHub doesn't perfectly render the
       | org file, you'd want to see the raw file for details if
       | interested in literal dotfiles.)
       | 
       | [0] https://wiki.archlinux.org/index.php/HiDPI
       | 
       | [1] https://github.com/podiki/dot.me/tree/master/x11
        
         | [deleted]
        
         | vbernat wrote:
         | Also, it is possible for most settings to be dynamic, which is
         | useful on a laptop where you can plug screens, with XSETTINGS.
         | That's what Gnome and XFCE are using. With Awesome WM, I am
         | using a script [1] to update XSETTINGS (through xsettingsd
         | configuration file). I explain more on my blog [2].
         | 
         | [1] https://github.com/vincentbernat/awesome-
         | configuration/blob/... [2]
         | https://vincent.bernat.ch/en/blog/2018-4k-hidpi-dual-screen-...
        
       | greggyb wrote:
       | I have synced dotfiles across my various machines and I run i3
       | across these. My configs for DPI consist entirely of the
       | following:
       | 
       | Xresources:                   Xft.dpi:120         st.font:
       | monospace:size=14
       | 
       | xsession:                   # haven't had time to dig into this,
       | some systems need         # DPI set twice         xSetDpi () {
       | xrandr --dpi "$1"; xrandr --dpi "$1"; }
       | 
       | That function is called in a case statement for other machine-
       | specific startup config, but it's just a matter of _xSetDpi
       | 144;_.
       | 
       | emacs.d/init.el:                   (set-face-attribute 'default
       | nil :height xxx)
       | 
       | Again this is per-host, but it's a simple COND expression.
       | 
       | qutebrowser/config.py:                   # even with DPI set, I
       | typically find web text too small         c.zoom.default = '175%'
       | 
       | I promise you that this does not feel like any significant effort
       | for me. It's ~10 lines across a few config files, each of which I
       | would be maintaining anyway - none of these configs were born for
       | the express purpose of handling DPI or zoom or anything like
       | that.
       | 
       | I value having a system that is configured exactly to my
       | preferences. I recognize that having multiple configs is a
       | turnoff for some. I can't debate personal preference.
       | 
       | I have spent much more time trying to get something like Gnome to
       | behave in a way I want than I have on all of my current config.
       | XFCE is a pretty good experience for a DE and configuring scaling
       | through system settings.
       | 
       | Machines:
       | 
       | 1. 11" HD, OpenBSD current
       | 
       | 2. 12" FHD, Artix Linux
       | 
       | 3. 2x27" WQHD, Artix Linux
        
       | libcg wrote:
       | This article makes it seem like these steps are necessary for
       | most Linux setups, when in reality you can do per monitor
       | fractional scaling from a GUI as long as you're using GNOME on
       | Wayland. No need to fiddle with per app settings, it works
       | transparently.
        
         | azinman2 wrote:
         | Except the author is using X11 as many people will. And what
         | this shows is how many different environments / toolkits /
         | settings there are out there. It would be nice if distributions
         | would do a better job of handling this for you. I've run into
         | the same issues myself, and it's kind of hard to believe that I
         | even had to figure out these configuration dpi settings in
         | 2021.
        
           | libcg wrote:
           | He's using "i3 with a heavily customized userspace" which
           | isn't exactly what most people would use. Gnome on X11 lets
           | you (integer) scale monitors through a GUI at the very least.
        
             | nxc18 wrote:
             | Yeah but there's a very good chance that won't work with
             | various hardware configurations. I was able to get per-
             | monitor scaling to work only after giving up use of half my
             | GPUs, and still there were problems with several apps. This
             | was on stock Ubuntu; I didn't get too crazy customizing
             | because I just wanted to find a Linux desktop that worked.
        
       | alsoc wrote:
       | I tried ubuntu + i3 on a Lenovo x1 carbon. The fonts, the
       | settings, the software, the differences, incompatibilities
       | everyday just killed me. I went back to Mac + Magnet window
       | manager. I could never know if I was actually seeing the actual
       | setting I included/desired or the font was being displayed
       | correctly. It Was a constant study of web searches and esoteric
       | knowledge such as evident in this blog of what to do to get
       | whatever you wanted that just worked on a Mac or even windows.
        
         | gurkendoktor wrote:
         | To provide some counter-anecdata, if you are in the lucky
         | position to have screens that work at exactly 200% (4K at 24",
         | 5K at 27"), then Ubuntu and its derivatives will Just Work out
         | of the box. At least that was my experience around 2017-2019.
         | Fractional scaling factors like 150% are tricky, but macOS does
         | not properly support them either.
         | 
         | The only app that didn't pick up my DPI settings on Linux was
         | Spotify, but all web-ish apps support ctrl +/-...which honestly
         | strikes me as a big usability win over native toolkits.
         | 
         | I actually found my 5K screen more enjoyable under Linux than
         | macOS, because the performance of JetBrains IDEs on Retina Macs
         | seems to flip-flop between okay and abysmal every year.
         | 
         | Mixed-DPI setups are where macOS is truly superior.
        
           | robertoandred wrote:
           | macOS supports fractional scaling just fine, by rounding up
           | and then downscaling. Sure it's not pixel-perfect to the
           | display, but at such high ppi it's not really noticeable, and
           | certainly much better than trying to get actual fractional
           | resolutions working.
           | 
           | Apple tried true resolution independence in the early 2000s
           | and it didn't work out. 2x and 3x scaling proved to be a much
           | better solution.
        
         | jonwest wrote:
         | Same opinion here. Whereas with Mac you're setting things in
         | one place across all of your apps, and it accounts for
         | different scaling factors for different displays, this just
         | seems like a huge pain to have to set things on an almost per-
         | app basis.
        
       | sitzkrieg wrote:
       | what an incredible waste of time. messing with dpi, crappy apps
       | taking from here and there in 2021. linux desktop userspace is a
       | dumpster fire
        
         | danieldk wrote:
         | The problem is largely X11. Wayland desktops such as GNOME +
         | Wayland applications generally work very well with HiDPI.
         | 
         | Even X11 applications work reasonably well on XWayland on e.g.
         | GNOME, as long as all screens use 100% or 200% scaling.
         | Unfortunately, with fractional scaling things break down with
         | X11 applications.
        
           | gtirloni wrote:
           | Indeed. I'm running my 4k monitor at 100% and just increase
           | the fonts in the apps themselves. It seems to work fine and
           | there's no scaling involved.
        
         | woodruffw wrote:
         | Author here: as they say, Linux is free if your time is
         | worthless.
         | 
         | In my case, my time isn't worthless but I _do_ enjoy
         | configuring my system. The tweaks shown in those blog post took
         | me maybe half a day; I haven't needed to make any significant
         | changes since.
        
           | sitzkrieg wrote:
           | well that is good that it holds up. i also have to make this
           | tradeoff but am less enthusiastic about it obviously.
           | switching to a single hidpi display has made it more
           | tolerable with bigger DMs
        
       | matt961 wrote:
       | Plasma wayland has per-screen DPI scaling to any percentage you
       | want. Only thing holding me back from switching is screen
       | recording/sharing woes.
        
         | kevincox wrote:
         | Have you set up pipewire? It doesn't seem to be the default in
         | any distros yet but it works fine for me. The only real issue
         | is that the permission dialog on Firefox makes you select the
         | window or screen to share twice. Not seamless but gets the job
         | done.
        
       | SweetestRug wrote:
       | I set up Linux on a Dell XPS 13 with the HiDPI screen. With both
       | Ubuntu and Manjaro it was relatively painless, especially using
       | GNOME via Wayland. i3 and sway also worked well too. I had heard
       | a lot of issues with Linux and HiDPI, and was worried I would
       | have to return/swap for a FHD screen, but everything has worked
       | almost flawlessly.
        
         | danieldk wrote:
         | I have used a 4k screen for several years now without any
         | issues on GNOME with 200% scaling.
         | 
         | However, I recently bought a ThinkPad T14 with a 1080p screen.
         | With 100% scaling, the fonts and widgets are too small. The
         | ideal scaling seems to be 125% or 150%. GNOME has experimental
         | support for fractional scaling. This works generally ok for
         | Wayland applications, but windows of X11 applications are
         | incredibly blurry both on the laptop display with 150% scaling
         | and the external screen with 200% screen. I think they are
         | rendered at 100% and then scaled up. There are various
         | workarounds for X11 applications, but it seems that e.g. none
         | of the workaround really works with e.g. JetBrains IDEs (there
         | are some bug reports about it).
         | 
         | Windows 10, on the other hand, handles fractional scaling and
         | per-screen scaling just fine. It's frustrating, because I
         | highly prefer GNOME and Linux and if all applications supported
         | Wayland, there wouldn't be any major problems.
        
           | boatsie wrote:
           | I have a similar problem with a QHD screen that I want 150%
           | scaling. The worst part is that using the experimental
           | scaling is it seems to consume a lot more cpu usage and thus
           | power on my laptop.
        
         | sammorrowdrums wrote:
         | My only issue is that my mid sized 4k screen is a but clunky at
         | 2x UI scaling but otherwise I don't have an issue until I plug
         | into a standard Monitor when 2x scaling is ridiculous.
         | 
         | But I find 1x scaling to be too small to enjoy on the QHD
         | screen. Multiple integer scale factors are possible but it is a
         | bit complex and when I did it machine was prone to crash...
         | 
         | That said I still love it.
        
         | paulie_a wrote:
         | The xps 13 with 4k is gorgeous. Pair it with an external 4k and
         | everything is seemless. If you go 1080 or whatever for the
         | external monitor it becomes a pain to switch resolutions and
         | scaling. I briefly had to do that and had a script to adjust
         | things but pycharm for instance needed to be restarted
         | 
         | Once I upgraded to a 4k it's a great setup. I actually have
         | dual 4k monitors now and that xps can handle it easily. No
         | software issues either. The most I've had to do was adjust the
         | zoo launcher to be hidpi
        
       | leephillips wrote:
       | I have a 2013 Chrome Pixel, with 240 dpi, and I've also found
       | that the Xft.dpi setting takes care of nearly everything,
       | although there are some interface elements in some applications
       | that still display tiny type. The author seems to be suggesting
       | that 163 DPI is high resolution; is it commonly understood to be
       | so? Because that would look a bit fuzzy to me.
        
         | azinman2 wrote:
         | Every screen's density of pixels are different.
        
           | leephillips wrote:
           | No, I once saw two that were the same.
        
             | woodruffw wrote:
             | This is not true. Your pixel density is a function of your
             | resolution and dimensions. "HiDPI" is a nebulous term that
             | refers to high resolution screens that are _also_
             | relatively small.
        
               | leephillips wrote:
               | If DPI means "dots per inch", then how can the size of
               | the screen come into it?
               | 
               | And what is "not true"?
        
               | woodruffw wrote:
               | As the phrase "dots per inch" implies, it's a ratio.
               | Specifically, it's the ratio between your resolution
               | (say, 4K) and the size of your screen.
               | 
               | What is "not true" is that every screen's pixel density
               | is the same. Different screens have different sizes and
               | resolutions, which means they have different pixel
               | densities.
        
       | azinman2 wrote:
       | The author brought up mouse acceleration, which reminded me of
       | why I switched back from Linux to a Mac: the mouse curves were
       | terrible IMHO, with seemingly no way to change it. The parameters
       | you can tweak in X11 didn't let me change the fundamental curve,
       | and to me where so much worse than Apple's it rendered the system
       | frustrating to use. I don't know if wayland suffers from the same
       | issue or not, but certainly googling around the many places were
       | people similarly complained weren't answered by a magic Wayland
       | config. Does anyone know if it's possible to get an Apple-like
       | mouse curve in Linux?
        
         | sitzkrieg wrote:
         | i managed (well, to make sensitivity low enough it was usable
         | even at 400dpi .. ) by recompiling libinput. yea really
        
           | edoceo wrote:
           | Seems like a patch others (ie:me) would like to see
        
           | ironmagma wrote:
           | Shouldn't that be something that's pulled into upstream? And
           | if they refuse, fork libinput?
        
       | alwaysanon wrote:
       | Credit where credit is due this is the one area where Windows is
       | the best OS these days. It not only will do fractional scaling
       | but it will do display independent fractional scaling - whack in
       | the scaling percentage on each screen and in the recent versions
       | of Windows 10 it works well and looks great and remembers your
       | settings when you plug that monitor back in. It is perhaps THE
       | thing along with WSL2 (now giving me a 'real' Ubuntu commandline
       | as well as Docker/Kubernetes experience where disks are mounted
       | on both sides and things work seamlessly via VS Code) that made
       | me choose Windows over the Mac and Linux this time around.
        
         | kevincox wrote:
         | This also works well on GNOME Wayland (and probably other
         | Wayland compositors) since about 1.5 years ago (for me at
         | least). In the display settings you can pick a scale per
         | monitor and almost all apps will respect it. (It seems some
         | apps with custom toolkits are lagging but I can't remember the
         | last time I ran into one of these).
        
         | leokennis wrote:
         | Yep. Windows 10 is fantastic in this regard.
         | 
         | MacOS on the other hand sucks. Basically the recommendation is
         | to run a lower and blurry resolution if you want bigger buttons
         | and text...
         | 
         | At the same time, iOS has great scaling and text sizing
         | options, and macOS' interface is so abstract that it should be
         | very easy to vectorize it, enabling seamless scaling to any
         | size wanted.
         | 
         | Really baffling.
        
           | alwaysanon wrote:
           | Yep - all our screens at work are not 4K but 2K (1/2 being
           | the ultra wide curved ones) and I find that the MacBooks look
           | just awful on them as it doesn't see them as 'retina'. It was
           | really strange at first as I always remembered Macs to have
           | great font rendering when displays were even lower res than
           | that but I can't stand how it looks on them. Having Windows
           | scale to 150% on them just looks soo much better. I have a 4K
           | 15" ThinkPad and a 4K 27" external at home and, even though
           | they are the same resolution, they are such different sizes
           | and I like to scale them differently to make things closer to
           | the same size when I drag them back and forth - but only when
           | docked. At other times I scale at a lower percentage to give
           | me more realestate. With Windows I can do this on the fly
           | these days without even logging off and everything looks
           | great and 'just works'. And I get real MS Office which is
           | still useful to me occasionally as a bonus.
        
       | Tepix wrote:
       | Not related to HiDPI, but looking at the picture of his monitor
       | setup:
       | 
       | From an ergonomics standpoint (i.e. the health of your neck), the
       | upper edge of your monitor shouldn't be higher than your eye
       | level. Looking straight or looking down is fine.
       | 
       | Thus the monitor on the left is probably not very ergonomic.
        
         | woodruffw wrote:
         | Author here: you're absolutely right. My previous vertical
         | monitor was a lot shorter; this one has definitely not been
         | great for my neck. I'll probably switch it back to horizontal
         | at some point.
        
           | Stratoscope wrote:
           | What size monitors are those? I use a pair of 24" 4K monitors
           | in roughly the same configuration as yours. 27" would
           | definitely be too tall.
           | 
           | I find having a vertical 24" monitor to be super useful,
           | especially for reading typical PDF files as an entire page
           | fits nicely on the screen.
           | 
           | My vertical monitor is a bit closer to the desk, and the
           | horizontal monitor is much higher than yours, about 7.5"
           | above the desk. The bottom edges are not aligned; the
           | vertical monitor bottom edge is about 5" below the bottom of
           | the horizontal monitor, and its top edge is about 3" above
           | the top of the horizontal monitor.
           | 
           | The top of horizontal monitor is just below my eye height. So
           | the top of the vertical one is a couple of inches above that,
           | but this is not a problem as I don't spend much time looking
           | at the very top of that monitor.
           | 
           | Each monitor is tilted separately. The horizontal one is
           | tilted back only slightly; the vertical one tilted more. So
           | the center of each monitor is perpendicular to my line of
           | sight.
           | 
           | At the moment I'm using the two monitors with a Linux
           | desktop, but sometimes I connect them both to a ThinkPad for
           | a three-monitor setup with the ThinkPad's display and
           | keyboard. When I do this, I raise the horizontal monitor up
           | another inch so the ThinkPad display tucks in underneath it.
           | 
           | With your horizontal monitor sitting so close to the desk, I
           | have to wonder if your seating position may be too low? Are
           | your forearms horizontal when typing? (Forgive me if I'm
           | being nosy or presumptuous, just curious.)
           | 
           | One related tip for anyone reading this, regardless of your
           | monitor arrangement: if you wear glasses, _do not_ use
           | progressive lenses at your computer. Instead, get a pair of
           | single vision lenses with a fairly tall aspect ratio so they
           | let you see the entire screen(s) without tilting your head
           | back. Don 't ask your optometrist for a "reading"
           | prescription - that tends to be about a 16" distance, and
           | your monitors are probably farther from your eyes than that.
           | Measure the distance from your eyes to the monitors and get
           | single vision lenses made for that distance.
        
             | woodruffw wrote:
             | > What size monitors are those? I use a pair of 24" 4K
             | monitors in roughly the same configuration as yours. 27"
             | would definitely be too tall.
             | 
             | They're 24", like yours. It sounds like our setups are
             | actually nearly identical: the top of my horizontal monitor
             | is also just below my eye height, and I spend most of my
             | time looking at the middle of the vertical one. I should
             | probably move them around a bit so I can actually look at
             | the vertical one without turning my head, though.
             | 
             | > With your horizontal monitor sitting so close to the
             | desk, I have to wonder if your seating position may be too
             | low? Are your forearms horizontal when typing? (Forgive me
             | if I'm being nosy or presumptuous, just curious.)
             | 
             | I appreciate it! I _think_ my seating is right, at least
             | based on what I was taught about ergonomics -- my forearms
             | are horizontal and I don 't have to pivot my wrists up or
             | down while typing or moving my mouse.
        
         | arendtio wrote:
         | Actually, I prefer looking up and down over looking left and
         | right. So for me it is normal to have the upper monitor way
         | above my eye level.
        
         | chao- wrote:
         | This is the recommended default, and I assume it is for good
         | reason, but I would caution against adopting this on faith. If
         | you feel pain, try different positions out. I had the setup you
         | recommend for many years. At first I started getting shoulder
         | pain, and realized that I was stopping over to accommodate when
         | looking down. I forced myself (at regular intervals, and modest
         | cost to productivity) to have better posture, and to tilt my
         | neck downward instead. It fixed the shoulder pain but my neck
         | was uncomfortable. Not in pain, but constantly uncomfortable. I
         | kept with it because I knew this was the "proper" ergonomics.
         | 
         | Then I realized: I spend most of my time staring at the bottom
         | half, to bottom edge, of the screen. Typing in a terminal,
         | adding functions at the bottom of a file, etc. I moved my
         | monitor such that my eyes are almost dead-center, vertically,
         | and haven't had any issues since, neither neck nor shoulders. I
         | kept the improved posture too, so I'm sure that ultimately
         | helped too.
         | 
         | I'm sure the recommended is recommended for a reason, and works
         | for most, but hopefully my experience is useful to some.
        
       ___________________________________________________________________
       (page generated 2021-01-30 23:01 UTC)