/YOTLD

The Year Of The Linux Desktop

The Year of the Linux Desktop From Macbook to Linux

After many years of using Macbook Pros, I’m finally saying “Enough!”. I have a great 2010-2012 Macbook Pro that still rocks. But in 2014 I decided to buy a mid-2014 model and after two years it started falling apart. First, one of the speakers started sounding tinny. Then the power plug port pins burnt out. Then, just after the warranty expired, came stain gate: the anti-reflective coating started to peel off, staining large portions of the screen. I dug around on the internets for advice and solved the problem by rubbing the film off the glass with metal polish. A few months later, the other speaker went the way of the first, and the power plug port pins burnt out again. Finally, the screen started to flicker (and it wasn't the LVDS display cable). Enough!!

Apple staingate

I decided to go back to Linux on a Lenovo and tweak it to make it as similar as possible to what I was used to on macOS. Here’s my guide for improving the (Gnome) Linux desktop experience—2020 really is the year of the Linux desktop!

Distro

Most major distros will do the job, however some of them come with useful out-of-the-box features. Two are especially worth mentioning:

  1. Pop OS This distro not only stands out for not being loaded with crapware (unnecessary, probably useless software), it also has its own distro version to manage Nvidia video cards. Nvidia cards are usually a headache for Linux users since some cards only work with signed proprietary drivers. And once you manage to get the card working, your pain isn’t over: you find out you've given birth to a power hog and your battery won't last. The latest Pop OS allows you to just turn off the GPU without manually blacklisting modules and use the onboard card or operate in hybrid mode. There’s no need for ACPI table hacks or vgaswitcheroo. The ability to turn off the GPU is integrated into the desktop. One click, finito. It also includes a simple tiling manager that can be turned on and off at will with a single click.

  2. Fedora Fedora does a great job with power consumption and the latest version (32) works well out-of-the-box. With Fedora, many new features, such as Wayland, become available sooner than with other major distros. The troubles with docker are mostly gone.

Battery life

Battery life has always been a nightmare with Linux laptops. Fortunately, there are distros like Fedora that have come with reasonable defaults so that laptops are more power efficient out-of-the-box. The old tools have evolved a lot. I am talking about the duo TLP and powertop.

To optimize battery power, the first thing to do is to establish a baseline while running on battery power. I prefer to start measuring idle power consumption (discharge rate depends on the workload). If Windows is available, BatteryInfoView is useful for setting a goal by looking at the charge/discharge rate value.

  1. powertop: sudo powertop -c will calibrate the measurement and present an estimate.
  2. powerstat: sudo powerstat will wait for a delay and take measurements over time to generate statistics.

If battery life is a major concern, it is advisable to be able to completely turn off the GPU (Graphic Processing Unit). The former section on Pop OS contains some links and strategies for the task. For Nvidia GPUs, the command ndvia-smi should confirm the card is turned off. After turning off the GPU, set a new idle power consumption baseline.

TLP and powertop can get along together, however, it's better if only one of them is in charge. I usually start with TLP, check and modify settings using sudo tlpui and then check with sudo powertop to see if there’s any optimization that’s not turned on. With this new tweak I can establish a new baseline.

When you feel comfortable, you can start optimizing on your usual work load (browser + code editor + bluetooth headset, etc). Powertop is handy here.

Some power hogs to watch out for:

  • Docker, containerd (switch them to on demand)
  • Browser tabs with misconfigured ads, mining, flash, etc.
  • Social networks (they are constantly polling or receiving socket events)
  • Unused interfaces (use sudo ifdown interface_name down to turn them off)
  • Any disk indexer
  • Monitoring software
  • Daemons checking for updates, file modifications, and syncs

To get some extra milliwatts, you can try correcting throttling (if necessary) and undervolting. If undervolting is used, it’s advisable to test it on your usual workload and try to suspend and unsuspend the laptop to test for stability. It’s typical to undervolt identically on the CPU and Cache.

Battery lifespan

For some Lenovo laptops, TLP allows you to set a different charge/discharge threshold so that the battery won't charge while it operates in the threshold band. This will prolong the battery life span.

Scaling

Screen scaling out-of-the-box on Linux usually sucks since it tends to be tiny. To correct the scaling, a common solution for Gnome users is to install the tweaks package:

sudo apt install gnome-tweaks
gnome-tweaks

and then go to the Fonts panel and adjust the scaling factor between 1.4 and 1.5 for a similar scaling to a Macbook Pro.

Mouse

After switching from a Macbook Pro, your new trackpad can feel awful. You might need to investigate further, but I found that after using it for a few days, I got comfortable with this adaptive profile of Gnome tweaks.

  1. Open gnome-tweaks
  2. Keyboard & mouse panel
  3. Acceleration profile: choose adaptive
  4. Check disable while typing
  5. Check mouse click emulation: fingers

CTRL Key

Most of the shortcuts are the same on Linux, but instead of the command key you use the control key. I prefer macOS shortcuts so I remapped the keys using gnome-tweaks.

  1. Go to Keyboard & Mouse Panel
  2. Click on Additional Layout Options
  3. Find Alt/Win Key Behavior
  4. Check: CTRL is mapped to Alt; Alt is mapped to Win.

A full working solution is to use kinto

If more options are needed, you might need to use xmodmap or kinto

http://xahlee.info/linux/linux_xmodmap_tutorial.html https://github.com/rbreaves/kinto

Shortcuts

If you don't use kinto, you can set up manually.

After many years of using Macbooks, I’m used to Apple shortcuts. In Gnome-based systems you can manually configure or import using this script from askubuntu.

to export key bindings

./keybindings.pl -e /tmp/keys.csv

to import

./keybindings.pl -i /tmp/keys.csv

Here you can find my bindings

Since alt was remapped, window related shortcuts should bind to control. I use some other shortcuts included with my bindings to try to match my spectacle profile on macOS.

Multitouch Gestures

You can use Fusuma to enable your Linux to recognize swipes or pinchs and assign commands. https://github.com/iberianpig/fusuma

Gifs and screenshots (peek and flameshot)

Screencast

sudo apt-get install byzanz
sudo apt-get install appmenu-gtk2-module appmenu-gtk3-module

git clone https://github.com/lolilolicon/xrectsel.git
sudo apt-install autoconf
./bootstrap
#!/usr/bin/env sh

[ $# -lt 2 ] && \
  echo 'You have to pass a duration in seconds and a filename: "gif.sh 10 /tmp/record.gif"' && \
  exit 1

byzanz-record                                        \
  --cursor                                           \
  --verbose                                          \
  --delay=2                                          \
  --duration="${1}"                                    \
  "$(xrectsel "--x=%x --y=%y --width=%w --height=%h")" \
  "${2}"

from: flameshot-org/flameshot#172 (comment)

Image and video previews

sudo apt install gnome-sushi

Emoji Keyboard

The emoji keyboard shortcut can collide with some text editors as vscode—since it is configured as shift+ctrl+e - so it needs to be changed. To change it, open ibus-setup and remap it so that it won't collide.

A gnome shell extension exists https://extensions.gnome.org/extension/1162/emoji-selector/

Clipboard Manager

For a very simple clipboard manager, I use clipit.

sudo apt install clipit

Another option is installing a gnome-shell extension https://extensions.gnome.org/extension/779/clipboard-indicator/ and then syncronize clipboards with autocutsel

sudo apt install autocutsel -y
# add to .bashrc
autocutsel &
autocutsel -s PRIMARY &

COPYQ is great https://github.com/hluk/CopyQ

Fonts

https://aswinmohan.me/posts/better-fonts-on-linux/

Password Manager

KeepassXC can import 1passwd files and many others.

xournal

To annotate and sign PDFs, Apple's preview works amazingly well. On Linux xournal can accomplish pretty much the same thing.

Spotify

The scaling is usually tiny. You can declare an alias in your .bashrc or similar.

If using the flatpack version, Otherwise just run sportify with options.

alias spotify="flatpak run com.spotify.Client --force-device-scale-factor=1.5 2>/dev/null"

As Apple continues to downgrade the quality of its hardware (to match its pricey, disposable adaptors), we need to look for other options. These steps will give you a much better user experience—comparable to that of macOS—on a Gnome-based desktop on Linux.

For anyone who wants to contribute more tips and tweaks, you can send your contributions to this Github repository.

HackerNews

This post thread HN https://news.ycombinator.com/item?id=25163685