Matebook Arch Tweak Note

This is a collection of notes of setting up and tweaking Arch Linux on Huawei Notebook 13. There are quite some existing write-ups about installing Arch on Matebook, among which I found this one most complete and useful. My post is more focused on my opinions and choices.

Installation

Before actually installing Arch, the first thing is to launch the stock Windows and check if everything works. It will be harder to get warrant later. Plus, Huawei provides BIOS updates as Windows executables. Though it is possible to install it on Linux, it's much simpler and more reliable to install it on Windows. Just grab and run the exe.

Matebook Specifics

BIOS

As stated earlier, Huawei provides BIOS updates as Windows executables. There are some tutorial and scripts about installing it on Linux, but they look complex and I would rather to use the old one. There are even reports of the updates degrading the performance, anyway.

Driver for battery and the Fn key

There is huawei-wmi that provides the battery protection function and the Fn key setting. The driver requires Linux kernel ⩾ 5.0, and is included in Linux ⩾ 5.5. So there is no need to install it separately.

However, there is a small problem with the battery protection. The setting will get reset randomly every a few days. The only solution is to repeatedly set it. I created /etc/systemd/system/huawei.service with the following content and systemctl enable huawei to set it automatically on startup.

[Unit]
Description=Huawei Battery Protection
After=suspend.target hibernate.target hybrid-sleep.target

[Service]
Type=oneshot
ExecStart=/usr/bin/sh -c 'echo "70 80" > /sys/devices/platform/huawei-wmi/charge_control_thresholds'

[Install]
WantedBy=suspend.target hibernate.target hybrid-sleep.target multi-user.target

Gnome and Wayland

Font

Maintenance

Clean

Backup

Rescue

Desktop Applications

Browser

Though not liking the recent moves of Google towards their definition of Web, Chromium is still my favorate browser. However, the standard build does not run on Wayland. XWayland works almost great, unless together with fractional scaling. Unfortunatly, the resolution of Matebook forces me to use 150% scaling, and it makes the text on XWayland apps blurry.

There are on going works to support Wayland and the AUR packages chromium-ozone and electron-ozone are usable, though with some issues like random crashing (about once an hour). They take several hours to build and keep CPU 100% during the building, so I usually build them on cloud and download the packages later via a custom repository.

Due to the numerous bugs in chromium-ozone, I keep tor-browser installed as a backup. Incidentally, it can be used to access some cool websites as well.

Video Player

The Gnome project provides totem (also simply called Videos). It is quite simple and looks nice. However, it depends on the disastrous gst-plugins-bad, which has a huge indirect dependencies, including python2. (Update: python2 is finally removed, hooray🎉)

Since I use ffmpeg, which comes with an extremely simple player called ffplay, I decided to use that as my default player. Beyond it, chromium is also an option, but I find ffplay more handy when the file name does not contains common video extname. chromium will try to download it unless the file is called "xxx.mp4".

To let Gnome and xdg-open recognize ffplay, add the following desktop description to ~/.local/share/applications/ffplay.desktop.

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Terminal=false
Type=Application
Name=FFPlay
Exec=ffplay %U
NoDisplay=true
Categories=AudioVideo;Audio;Video;Player;
MimeType=application/mxf;application/ogg;application/ram;application/sdp;application/smil;application/smil+xml;application/vnd.apple.mpegurl;application/vnd.ms-asf;application/vnd.ms-wpl;application/vnd.rn-realmedia;application/vnd.rn-realmedia-vbr;application/x-extension-m4a;application/x-extension-mp4;application/x-flac;application/x-flash-video;application/x-matroska;application/x-netshow-channel;application/x-ogg;application/x-quicktime-media-link;application/x-quicktimeplayer;application/x-shorten;application/x-smil;application/xspf+xml;audio/3gpp;audio/3gpp2;audio/aac;audio/ac3;audio/AMR;audio/AMR-WB;audio/basic;audio/dv;audio/eac3;audio/flac;audio/m4a;audio/midi;audio/mp1;audio/mp2;audio/mp3;audio/mp4;audio/mpeg;audio/mpegurl;audio/mpg;audio/ogg;audio/opus;audio/prs.sid;audio/scpls;audio/vnd.rn-realaudio;audio/wav;audio/webm;audio/x-aac;audio/x-aiff;audio/x-ape;audio/x-flac;audio/x-gsm;audio/x-it;audio/x-m4a;audio/x-m4b;audio/x-matroska;audio/x-mod;audio/x-mp1;audio/x-mp2;audio/x-mp3;audio/x-mpg;audio/x-mpeg;audio/x-mpegurl;audio/x-ms-asf;audio/x-ms-asx;audio/x-ms-wax;audio/x-ms-wma;audio/x-musepack;audio/x-opus+ogg;audio/x-pn-aiff;audio/x-pn-au;audio/x-pn-realaudio;audio/x-pn-realaudio-plugin;audio/x-pn-wav;audio/x-pn-windows-acm;audio/x-realaudio;audio/x-real-audio;audio/x-s3m;audio/x-sbc;audio/x-scpls;audio/x-shorten;audio/x-speex;audio/x-stm;audio/x-tta;audio/x-wav;audio/x-wavpack;audio/x-vorbis;audio/x-vorbis+ogg;audio/x-xm;image/vnd.rn-realpix;image/x-pict;misc/ultravox;text/google-video-pointer;text/x-google-video-pointer;video/3gp;video/3gpp;video/3gpp2;video/dv;video/divx;video/fli;video/flv;video/mp2t;video/mp4;video/mp4v-es;video/mpeg;video/mpeg-system;video/msvideo;video/ogg;video/quicktime;video/vivo;video/vnd.divx;video/vnd.mpegurl;video/vnd.rn-realvideo;video/vnd.vivo;video/webm;video/x-anim;video/x-avi;video/x-flc;video/x-fli;video/x-flic;video/x-flv;video/x-m4v;video/x-matroska;video/x-mjpeg;video/x-mpeg;video/x-mpeg2;video/x-ms-asf;video/x-ms-asf-plugin;video/x-ms-asx;video/x-msvideo;video/x-ms-wm;video/x-ms-wmv;video/x-ms-wmx;video/x-ms-wvx;video/x-nsv;video/x-ogm+ogg;video/x-theora;video/x-theora+ogg;x-content/video-dvd;x-scheme-handler/pnm;x-scheme-handler/mms;x-scheme-handler/net;x-scheme-handler/rtp;x-scheme-handler/rtmp;x-scheme-handler/rtsp;x-scheme-handler/mmsh;x-scheme-handler/uvox;x-scheme-handler/icy;x-scheme-handler/icyx;

A caveat is that manually calling update-desktop-database ~/.local/share/applications is required, which is usually done by pacman hooks.

ffplay doesn't even have a single button on its UI. All controls are hidden in man ffplay. The most frequently used commands for me are:

  • right mouse click to seek to percentage in file corresponding to fraction of width;
  • left/right arrow to backward/forward 10 seconds, and down/up arrows for 1 minute;
  • p to pause, and q to close;
  • and double click to (un)fullscreen.
  • Other Applications

    Proxy

    Some kinds of proxy softwares must be there for a Chinese developer. shadowsocks-libev is very light and stable. However, it is losing its market and alternatives like V2ray are emerging. Unlike shadowsocks, V2ray is huge and the implementation is chaotic.

    Thus I wrote v2socks. It is a simple implementation of the vmess protocol and socks5. The usage is very similar to shadowsocks-libev, i.e. no need to create a dedicated config file. More importantly, it is a single 270K binary without any dependencies except for glibc. For comparison, the official v2ray core is 43M, and the 99% functionalities are not being used and only act as attack surfaces. Switching proxies can sometimes become annoying too, so I also wrote a simple gnome extension for proxy subscription and switching.

    Apart from forward proxing, reverse proxing can be very handy too. For example, I may updated my blog and want to check it on my phone without deploying. I use frp for this task. It is also bloated IMO, including very unnecessary things like admin dashboard. I have planned to write a lighter alternative.

    For temporary proxy like download a paper from school, the ubiquitous ssh -D is probably the best choice.