Debloat Fedora 37 Gnome

As usual, there's a lot of bloat is coming together with system. But nevertheless I must say I really love how stable it is working on my Asus Transformer Mini T102HA. I really love their Gnome implementation - all the tablet features are just operating out of the box.

ibus-typing-booster is taking up to 150Mb of RAM


If you don't know how to type this might be a good tool for you - https://mike-fabian.github.io/ibus-typing-booster/ But for me it's just a memory eating unneeded extra bloat.

$ ps v $(pgrep -f ibus-typing-booster)
    PID TTY      STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
   2290 ?        Sl     0:30     41     0 797219 159284  4.1 /usr/bin/python3 /usr/share/ibus-typing-booster/engine/main.py --ibus

$ yum remove ibus-typing-booster-2.19.13-2.fc37.noarch

packagekitd is taking up to 300Mb of RAM

This this right after service restart, but earlier before it was 300+ Mb.

$ ps v $(pgrep packagekitd)
    PID TTY      STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
   6260 ?        Ssl    0:07     10     0 574388 108200  2.8 /usr/libexec/packagekitd

To me, it shouldn't be like this. No shitty interim wrapper service to wrap rpm/apt/pacman into some common API that gui frontend programs can work with, shouldn't take that much of precious RAM.

Updated this bug https://bugzilla.redhat.com/show_bug.cgi?id=1354074 and https://github.com/PackageKit/PackageKit/issues/576 but I'm in a mood of throwing it into bin without waiting for the solution. Even by paying a price of loosing gnome-software.

Later I found this ticket, where there's a suggestion to configure a timeout for exiting. I set it to 30 seconds and it shuts itself down if not being used:

$ cat /etc/PackageKit/PackageKit.conf

# Shut down the daemon after this many seconds idle. 0 means don't shutdown.
ShutdownTimeout=30

Who needs firewall and modem in 21st century?

If you're not going to create any local network services (samba, telnet, cups, whatever proxy)  with an aim to let anyone from your local network (192.168.0.0) to use them without any authorization, then you don't need a firewall. Really - if you don't have any plans to have such unprotected services, you shouldn't care about firewall. It's a lame idea first of all, to have some uncontrolled bunch of garbage local services to be "protected" by firewall. Where "protected" usually means restricted from being used.

yum remove firewalld

Same goes for ModemManager. If you don't have a modem (if you old enough to know what it is) or if you don't pair your PC with your phone via Bluetooth to use is as a modem (don't confuse it with creating a WiFi access point by your phone) - you don't need this.

yum remove ModemManager

Throw out the rest trash

Didn't have time for the below, but need to sort it out. 200 Mb of RAM is just wasted in there. If you just kill it - nothing bad happens to system: calendar in the top-row is still working. You can even invoke an address book. I really don't understand, why to keep all these services up, when everything is already working fine.

/usr/libexec/geoclue - 31 M
/usr/libexec/evolution-data-server/evolution-alarm-notify - 57 M
/usr/bin/gnome-software --gapplication-service - 89 M
/usr/libexec/evolution-source-registry - 42 M
/usr/libexec/evolution-addressbook-factory - 28 M
+ /usr/bin/python3 /usr/share/ibus-typing-booster/engine/main.py - 81 M
/usr/bin/gnome-calendar --gapplication-service - 57 M

Just see what happens if you run the below:

pkill gnome-software
pkill gnome-calendar
pkill evolution-alarm
pkill evolution-addre
pkill evolution-calen
pkill evolution-sourc

To be continued to properly fix (wipe) all that shit from being started automatically.

Fedora 37 / Pop OS / Xubuntu / Manjaro / RebornOS on Asus Transformer Mini T102HA

Following up my previous post, I decided to give it a try few other Linux distros. And I was deeply impressed by results.

What I did, is that I flashed my USB stick drive with Ventoy (highly recommend it) and then uploaded a bunch of different Linux ISOs to it. Thanks to modern standards of linux distributions, most of them are actually live cd distributions you can give a good test run, before deciding to install.

Before I move on, I need to point out something, which is in common for all Linux distributions, if we speak about this particular device - Asus Transformer Mini T102HA. In none of them, below things were working:

* Built-in camera
* Built-in microphone
* Brightness of the backlid is  not configurable from keyboard - fn+F5/F6 - these keys are just not sending any codes.
You can still configure screen brightness with using software and the same you can remap it to be configurable from some different keys. Possible troubleshooting is described here - https://bbs.archlinux.org/viewtopic.php?id=229572

Fedora 37 with Gnome - 👍👍👍

Sound - works without issues
Screen orientation and touchscreen - is fine, when X boots up. In GRUB and system boot up the screen is still rotated - but we already know how to fix it (see "Fixing screen orientation in console" section here)
Automatic screen rotation -  works out of the box, but only with detached keyboard.
Screen brightness can be configured with applet
Couple of screen rotations - no issues
No screen tearing, thanks to Wayland

I noticed some strange backlid flickering on key presses, when it is set to low level and modal dialog is displayed, like prompting WiFi password

System information

# inxi -b
System:
  Host: localhost-live Kernel: 6.0.7-301.fc37.x86_64 arch: x86_64 bits: 64
    Console: pty pts/0 Distro: Fedora release 37 (Thirty Seven)
Machine:
  Type: Detachable System: ASUSTeK product: T102HA v: 1.0
    serial: GAN0CX00Z313409
  Mobo: ASUSTeK model: T102HA v: 1.0 serial: BSN12345678901234567
    UEFI: American Megatrends v: T102HA.303 date: 04/12/2017
Battery:
  ID-1: BATC charge: 9.5 Wh (42.0%) condition: 22.6/31.6 Wh (71.4%) volts: 3.8
    min: 3.8
CPU:
  Info: quad core Intel Atom x5-Z8350 [MCP] speed (MHz): avg: 766
    min/max: 480/1920
Graphics:
  Device-1: Intel Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx
    Integrated Graphics driver: i915 v: kernel
  Display: server: X.Org v: 22.1.3 with: Xwayland v: 22.1.3 driver:
    dri: crocus gpu: i915 note: X driver n/a resolution: 1280x800~60Hz
  API: OpenGL v: 4.6 Mesa 22.2.2 renderer: Mesa Intel HD Graphics (CHV)
Network:
  Device-1: Qualcomm Atheros QCA9377 802.11ac Wireless Network Adapter
    driver: ath10k_pci
Drives:
  Local Storage: total: 72.85 GiB used: 5.77 GiB (7.9%)
Info:
  Processes: 262 Uptime: 19m Memory: 3.66 GiB used: 2.44 GiB (66.7%)
  Shell: Bash inxi: 3.3.24
 

Making fingerprint sensor to work in Linux on Asus Transformer Mini T102HA

I fiugured it out that my fingerprint sensor should be supported by fprint project:

[root@localhost-live ~]# lsusb | grep -i finger
Bus 001 Device 006: ID 04f3:0903 Elan Microelectronics Corp. ELAN:Fingerprint

You need to install and enable fprintd:

yum install fprintd.x86_64
systemctl enable fprintd.service

Then, if you want to, you can play with enrolling / testing / deleting fingerprints right from the CLI:

fprintd-list <user>
fprintd-enroll <user>
fprintd-verify <user>
fprintd-delete <user>

... or go directly to Gnome Settings -> Users and configure it from there


Manjaro XFCE  😕

Overall it seems to be less fancy than Gnome on Fedora, but given the sound works here without any issues, it is much more pleasant than Linux Mint 21. But I need to say, that with all my love to XFCE, the Gnome is much better choise for tablets with touchscreens.

Sound - working without issues
Screen orientation and touchscreen - same as in Mint, needs fixing 
Automatic screen rotation -  doesn't work
Brightness of backlid cannot be even configured via xfc4 power settings applet 
Couple of screen rotations - xfce4-terminal started to have some small issues after first rotation, but system remained stable

System information

$ inxi -b

System:

  Host: manjaro Kernel: 6.1.1-1-MANJARO arch: x86_64 bits: 64 Desktop: Xfce

    v: 4.18.0 Distro: Manjaro Linux

Machine:

  Type: Detachable System: ASUSTeK product: T102HA v: 1.0

    serial: <superuser required>

  Mobo: ASUSTeK model: T102HA v: 1.0 serial: <superuser required>

    UEFI: American Megatrends v: T102HA.303 date: 04/12/2017

Battery:

  ID-1: BATC charge: 8.2 Wh (36.3%) condition: 22.6/31.6 Wh (71.4%) volts: 3.7

    min: 3.8

CPU:

  Info: quad core Intel Atom x5-Z8350 [MCP] speed (MHz): avg: 516

    min/max: 480/1920

Graphics:

  Device-1: Intel Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx

    Integrated Graphics driver: i915 v: kernel

  Display: x11 server: X.Org v: 21.1.6 driver: X: loaded: modesetting

    dri: crocus gpu: i915 resolution: 1280x800~60Hz

  API: OpenGL Message: Unable to show GL data. Required tool glxinfo

    missing.

Network:

  Device-1: Qualcomm Atheros QCA9377 802.11ac Wireless Network Adapter

    driver: ath10k_pci

Drives:

  Local Storage: total: 72.85 GiB used: 0 KiB (0.0%)

Info:

  Processes: 195 Uptime: 8m Memory: 3.67 GiB used: 2.48 GiB (67.6%)

  Shell: Bash inxi: 3.3.24


Xubuntu 22.10 😖

Sound - same issues as in Mint
Screen orientation and touchscreen - same as in Mint and Manjaro, needs fixing 
Automatic screen rotation -  doesn't work. I'm starting to think that XFCE just doesn't have this feature
Brightness can be configured via xfc4 power settings applet, so there's something wrong with just Manjaro alone
Couple of screen rotations with xrand - worked fine

System information

 
$ inxi -b
System:
  Host: xubuntu Kernel: 5.19.0-21-generic arch: x86_64 bits: 64 Desktop: Xfce
    v: 4.17.0 Distro: Ubuntu 22.10 (Kinetic Kudu)
Machine:
  Type: Detachable System: ASUSTeK product: T102HA v: 1.0
    serial: <superuser required>
  Mobo: ASUSTeK model: T102HA v: 1.0 serial: <superuser required>
    UEFI: American Megatrends v: T102HA.303 date: 04/12/2017
Battery:
  ID-1: BATC charge: 4.8 Wh (21.2%) condition: 22.6/31.6 Wh (71.4%)
    volts: 3.7 min: 3.8
CPU:
  Info: quad core Intel Atom x5-Z8350 [MCP] speed (MHz): avg: 504
    min/max: 480/1920
Graphics:
  Device-1: Intel Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx
    Integrated Graphics driver: i915 v: kernel
  Display: x11 server: X.Org v: 1.21.1.4 driver: X: loaded: modesetting
    unloaded: fbdev,vesa gpu: i915 resolution: 1280x800~60Hz
  OpenGL: renderer: Mesa Intel HD Graphics (CHV) v: 4.6 Mesa 22.2.1
Network:
  Device-1: Qualcomm Atheros QCA9377 802.11ac Wireless Network Adapter
    driver: ath10k_pci
Drives:
  Local Storage: total: 72.85 GiB used: 0 KiB (0.0%)
Info:
  Processes: 231 Uptime: 17m Memory: 3.67 GiB used: 2.04 GiB (55.7%)
  Shell: Bash inxi: 3.3.21

Sound issues


I decided to dig a bit deeper to see what is the difference between various audio components to narrow it down. In short, the issue looks like this - after a while of playing sound, like playing a video from YouTube, the sound stops at some random and very loud note and system sound controls cannot help you here.

xubuntu@xubuntu:~$ apt list --installed | grep -i pipew

libpipewire-0.3-0/kinetic,now 0.3.58-2ubuntu1 amd64 [installed,automatic]
libpipewire-0.3-common/kinetic,now 0.3.58-2ubuntu1 all [installed,automatic]
xubuntu@xubuntu:~$ apt list --installed | grep -i alsa

alsa-base/kinetic,now 1.0.25+dfsg-0ubuntu7 all [installed,automatic]
alsa-topology-conf/kinetic,now 1.2.5.1-2 all [installed,automatic]
alsa-ucm-conf/kinetic,now 1.2.6.3-1ubuntu2 all [installed,automatic]
alsa-utils/kinetic,now 1.2.6-1ubuntu1 amd64 [installed,automatic]
xubuntu@xubuntu:~$ apt list --installed | grep -i pulse

gstreamer1.0-pulseaudio/kinetic,now 1.20.3-1ubuntu1 amd64 [installed,automatic]
libpulse-mainloop-glib0/kinetic,now 1:16.1+dfsg1-1ubuntu3 amd64 [installed,automatic]
libpulse0/kinetic,now 1:16.1+dfsg1-1ubuntu3 amd64 [installed,automatic]
libpulsedsp/kinetic,now 1:16.1+dfsg1-1ubuntu3 amd64 [installed,automatic]
pulseaudio-module-bluetooth/kinetic,now 1:16.1+dfsg1-1ubuntu3 amd64 [installed,automatic]
pulseaudio-utils/kinetic,now 1:16.1+dfsg1-1ubuntu3 amd64 [installed,automatic]
pulseaudio/kinetic,now 1:16.1+dfsg1-1ubuntu3 amd64 [installed,automatic]
xfce4-pulseaudio-plugin/kinetic,now 0.4.5-0ubuntu1 amd64 [installed,automatic]

RebornOS  😖

Sound - works fine
Screen orientation and touchscreen - same as in Mint, Xubuntu and Manjaro, needs fixing 
Automatic screen rotation -  doesn't work. I'm starting to thing XFCE just doesn't have this
Brightness cannot be configured via xfc4 power settings applet, so there's something wrong with all Arch-based distributions
Screen rotations with xrand - system got unresponsive 

System information


 inxi -b
System:
  Host: rebornosiso Kernel: 6.1.2-arch1-1 arch: x86_64 bits: 64 Desktop: Xfce
    v: 4.18.0 Distro: RebornOS Linux
Machine:
  Type: Detachable System: ASUSTeK product: T102HA v: 1.0
    serial: <superuser required>
  Mobo: ASUSTeK model: T102HA v: 1.0 serial: <superuser required>
    UEFI: American Megatrends v: T102HA.303 date: 04/12/2017
Battery:
  ID-1: BATC charge: 3.6 Wh (15.9%) condition: 22.6/31.6 Wh (71.4%) volts: 3.7
    min: 3.8
CPU:
  Info: quad core Intel Atom x5-Z8350 [MCP] speed (MHz): avg: 1210
    min/max: 480/1920
Graphics:
  Device-1: Intel Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx
    Integrated Graphics driver: i915 v: kernel
  Display: x11 server: X.Org v: 21.1.6 with: Xwayland v: 22.1.7 driver: X:
    loaded: intel unloaded: fbdev,modesetting,vesa dri: crocus gpu: i915
    resolution: 1280x800~60Hz
  API: OpenGL v: 4.6 Mesa 22.3.2 renderer: Mesa Intel HD Graphics (CHV)
Network:
  Device-1: Qualcomm Atheros QCA9377 802.11ac Wireless Network Adapter
    driver: ath10k_pci
Drives:
  Local Storage: total: 72.85 GiB used: 0 KiB (0.0%)
Info:
  Processes: 211 Uptime: 10m Memory: 3.67 GiB used: 1.88 GiB (51.3%)
  Shell: Zsh inxi: 3.3.23


PopOS 😐

Automatic screen rotation works out of the box, with and without keyboard attached
No backlid flickering on low levels in modal dialog, as it was in Fedora
Youtube in Firefox doesn't work right out of the box, however Odysse does. Sound crashes the similar (but not the same) way as in Xubuntu and Mint.
I was experiencing occasional freezes on Firefox, and it even crashed once. System is overall not very responsive.
Bad screen tearing, while playing dynamic videos.
Worst of all, that after playing with is for 20-30 minutes, system freezes completely.

Few additional notes, related to PopOS:
Touchpad jestures in COSMIC are not that comfortable as in Gnome. Gnome is miles ahead.
As soon as you start to use touchscreen, it's kind a hard to get your mouse pointer back, if you switch to touchpad/mouse

System information

 
$ inxi -b
System:
  Host: pop-os Kernel: 6.0.12-76060006-generic x86_64 bits: 64
    Desktop: GNOME 42.3.1 Distro: Pop!_OS 22.04 LTS
Machine:
  Type: Detachable System: ASUSTeK product: T102HA v: 1.0
    serial: <superuser required>
  Mobo: ASUSTeK model: T102HA v: 1.0 serial: <superuser required>
    UEFI: American Megatrends v: T102HA.303 date: 04/12/2017
Battery:
  ID-1: BATC charge: 22.6 Wh (100.0%) condition: 22.6/31.6 Wh (71.4%)
CPU:
  Info: quad core Intel Atom x5-Z8350 [MCP] speed (MHz): avg: 480
    min/max: 480/1920
Graphics:
  Device-1: Intel Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx
    Integrated Graphics
    driver: i915 v: kernel
  Display: x11 server: X.Org v: 1.21.1.3 driver: X: loaded: modesetting
    unloaded: fbdev,vesa gpu: i915 resolution: 1280x800~60Hz
  OpenGL: renderer: Mesa Intel HD Graphics (CHV) v: 4.6 Mesa 22.2.0
Network:
  Device-1: Qualcomm Atheros QCA9377 802.11ac Wireless Network Adapter
    driver: ath10k_pci
Drives:
  Local Storage: total: 72.85 GiB used: 0 KiB (0.0%)
Info:
  Processes: 241 Uptime: 10m Memory: 3.66 GiB used: 1.43 GiB (39.0%)
  Shell: Bash inxi: 3.3.13


Ubuntu 22.04 😐

Automatic screen rotation works out of the box, with and without keyboard attached
No backlid flickering on low levels in modal dialog, as it was in Fedora
Same issues with sound as in Xubuntu and Mint
No screen tearing
Very limited support of touchpad / touchscreen gestures of Ubuntu Gnome compared to say Fedora 37 Gnome. Fedora is really the clean winner for tablets like Asus Transformer Mini T102HA.


Linux Mint 21 on Asus Transformer Book T102HA

I do own three (!) such Asus x86_64 tables. They're nice little machines with quite a powerful battery, which allows them to stay off grid up to 10 hrs. And that was back in 2014 . Off course, due to normal battery wearing and tearing, now they are hardly can stay more than 6 hrs, but it's still quite good enough to me. I got tiered of Windows 10 on those little machines, so I decided to give it a try and install Linux on one of them.

I started with Mint 21. This post is to capture what kind of issues I encountered and how I was fixing them. 

Running ahead, it probably doesn't make sense to install Mint on this machine and it's better to give it a try couple of other distros like:

  • PopOS
  • Ubuntu
  • Debian
  • Fedora 
  • Manjaro or any Arch-based like RebornOS

And the easiest to do that is to flash your USB stick with Ventoy and collect a bunch of different Linux Distribution Live ISOs to it, so you could test all of them, one-by-one, in a live environment, before making a final decision to install them to your hard drive. 

Issues encountered

  • Screen orientation is wrong
  • Brightness is not configurable from keyboard - fn+F5/F6 
  • System freezes after number of screen rotations (xrandr -o left/right)
  • Issues with audio - playback was "freezing" while playing a single high-pitch loud note
  • Built-in camera is not working
  • Fingerprint reader is not working 
  • Automatic screen rotation didn't work out of the box


System details

Before we move further, let me show you how the system was identified in Mate 21 by inxi:


$ inxi -b
System:
  Host: T102HA Kernel: 5.15.0-58-generic x86_64 bits: 64
    Desktop: Xfce 4.16.0 Distro: Linux Mint 21 Vanessa
Machine:
  Type: Detachable System: ASUSTeK product: T102HA v: 1.0
    serial: <superuser required>
  Mobo: ASUSTeK model: T102HA v: 1.0 serial: <superuser required>
    UEFI: American Megatrends v: T102HA.303 date: 04/12/2017
Battery:
  ID-1: BATC charge: 11.0 Wh (48.7%) condition: 22.6/31.6 Wh (71.4%)
    volts: 3.8 min: 3.8
CPU:
  Info: quad core Intel Atom x5-Z8350 [MCP] speed (MHz): avg: 506
    min/max: 480/1920
Graphics:
  Device-1: Intel Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx
    Integrated Graphics
    driver: i915 v: kernel
  Display: x11 server: X.Org v: 1.21.1.3 driver: X: loaded: modesetting
    unloaded: fbdev,vesa gpu: i915 resolution: 1280x800~60Hz
  OpenGL: renderer: Mesa Intel HD Graphics (CHV) v: 4.6 Mesa 22.0.5
Network:
  Device-1: Qualcomm Atheros QCA9377 802.11ac Wireless Network Adapter
    driver: ath10k_pci
Drives:
  Local Storage: total: 72.85 GiB used: 52.17 GiB (71.6%)
Info:
  Processes: 245 Uptime: 13h 59m Memory: 3.67 GiB used: 1.47 GiB (40.1%)
  Shell: Bash inxi: 3.3.13

Screen orientation is wrong

Out of the box, the screen orientation was all wrong:

  • when the grub boot menu comes up, it's rotated 90 degrees counter-clockwise
  • linux mint splash screen logo, which  hides kernel messages upon startup is 90 degrees rotated
  • if you hit ESC to hide the splash screen, you'll see that startup messages are printed to a console, that is also 90 degrees rotated
  • when the desktop manager starts, it's orientation is also rotated 90 degrees right
  • and when you finally login to the desktop environment of your choice (mine is XFCE as it is a lightweight), it's also rotated in there 

First of all some might ask - what the heck? I didn't have that on Windows! The answer appears to be that the screen manufacturer (ASUS) decided to declare the screen orientation is portrait by default. The good news is that you can fix almost everything from the above list.

Fixing screen orientation in Desktop Environment

We will start with something simple, like fixing orientation in Desktop Environment. You just log in to it, go to display settings (or run xfce4-display-settings) and there you're able to change the screen orientation. Hurray!

Alternatively you can run:

xrand -o right 

and that, in theory, should update the local config file for your user, somewhere in ~/.config, like xrand usually does.  So the next time you log in, the desktop environment will be properly oriented.

Fixing touchscreen sensor orientation

Even though our screen is now properly rotated, if you touch it, the cursor is moved like the touchscreen orientation is still wrong. And it is still wrong. Fixing it just a slightly more complicated than the above section, so bear with me.

First of all, you need to know that all the input devices your PC has, like:

  • orientation sensor (this is the one which tells whether your device is in portrait mode or in landscape mode)
  • ambient light sensor -  to turn on brightness, when it's too much light around
  • hardware buttons - like volume up/down, power
  • touchpad below your keyboard
  • touchscreen
  • keyboard
  • mouse
  • ... whatever else

...are explicitly appearing as device files under /dev/input/ and also you can list them by calling xinput but it's kinda hard to map one to another (or I'm an idiot).

In order to understand what is your input sensor device, you need to do something like this:

$ sudo cat /dev/input/mouse0

.. and then do something with your device, like touch your screen (if you're searching for touchscreen / rotate your device / cover the light sensor if you know where it is). If the device is responding to Linux Kernel, you'll see something starts printing on the console. If nothing happens, then CTRL+C and proceed with next device. 

Alternatively you can run xinput to see what device ids are there:

$ xinput
⎡ Virtual core pointer                        id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                  id=4    [slave  pointer  (2)]
⎜   ↳ ASUS HID Device ASUS HID Device Touchpad    id=13    [slave  pointer  (2)]
⎜   ↳ ASUS HID Device ASUS HID Device Consumer Control    id=14    [slave  pointer  (2)]
⎜   ↳ ELAN22A6:00 04F3:22A6                       id=15    [slave  pointer  (2)]
⎜   ↳ ASUS HID Device ASUS HID Device Mouse       id=12    [slave  pointer  (2)]
⎣ Virtual core keyboard                       id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard                 id=5    [slave  keyboard (3)]
    ↳ Power Button                                id=6    [slave  keyboard (3)]
    ↳ Video Bus                                   id=7    [slave  keyboard (3)]
    ↳ Power Button                                id=8    [slave  keyboard (3)]
    ↳ Sleep Button                                id=9    [slave  keyboard (3)]
    ↳ ASUS HID Device ASUS HID Device System Control    id=10    [slave  keyboard (3)]
    ↳ ASUS HID Device ASUS HID Device Keyboard    id=11    [slave  keyboard (3)]
    ↳ ELAN22A6:00 04F3:22A6 Stylus                id=16    [slave  keyboard (3)]
    ↳ chtdc_ti_pwrbtn                             id=17    [slave  keyboard (3)]
    ↳ Intel HID events                            id=18    [slave  keyboard (3)]
    ↳ gpio-keys                                   id=19    [slave  keyboard (3)]
    ↳ gpio-keys                                   id=20    [slave  keyboard (3)]
    ↳ Asus WMI hotkeys                            id=21    [slave  keyboard (3)]
    ↳ ASUS HID Device ASUS HID Device Consumer Control    id=22    [slave  keyboard (3)]

and then run the below command for each device, trying to do the same:

xinput test 15

where 15 is for device id=15, but you'll need to test them all one by one to find the touchscreen device. 

In my case, the touchscreen was the device with id=15 so my output looked like this, when I touched the screen:

$ xinput test 15
motion a[0]=28260 a[1]=36430
button press   1 a[0]=28260 a[1]=36430
motion a[0]=28293 a[1]=36410
motion a[0]=28392 a[1]=36390
motion a[0]=28591 a[1]=36370
....

So it's just a last step here. We'll need to configure that device with using xinput to apply a "transformation matrix" to it - see more details here - https://wiki.ubuntu.com/X/InputCoordinateTransformation

If you're the same as me, just want to rotate the touchscreen to the right, run the below command:

xinput set-prop 15 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1  

Screen & touchscreen autorotation

If you ever want to rotate your screen back to portrait mode (there's an orientation sensor in this laptop, remember?) we can do that via monitor-sensor cli tool in a dirty and quick way:

$ sudo apt install inotify-tools
$ cat autorotate.sh
#!/bin/sh

killall monitor-sensor
monitor-sensor > /dev/shm/sensor.log &
while inotifywait -e modify /dev/shm/sensor.log; do

ORIENTATION=$(tail /dev/shm/sensor.log | grep 'orientation' | tail -1 | grep -oE '[^ ]+$')

case "$ORIENTATION" in
normal)
xinput set-prop 15 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1
xrandr -o normal;;
right-up)
xinput set-prop 15 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1
xrandr -o right;;
left-up)
xrandr -o left;;
bottom-up)
xrandr -o inverted;;
esac
done

Fixing logon manager (LightDM) screen orientation 

But we still have a desktop manager (aka login manager - lightdm) in wrong orientation. For that we create an additional config file, that will be executed by lightdm upon startup - /etc/lightdm/lightdm.conf.d/50-rotate.conf - with the below content:

[SeatDefaults]
display-setup-script=xrandr -o right

Fixing screen orientation in console

Then, in order to fix the orientation in console (after the GRUB menu is passed - I couldn't fix orientation in there) you need to edit few lines in /etc/default/grub file and then run update-grub command to regenerate grub configs:

GRUB_CMDLINE_LINUX_DEFAULT="quiet fbcon=rotate:1"
GRUB_CMDLINE_LINUX="fbcon=rotate:1"

As you can see, I removed the "splash" word out of the parameters, so I don't care to rotate the splash screen with Mint logo - I'd rather to hide it altogether. 

Fixing GRUB menu orientation

Unfortunately I didn't find an easy solution so far. It looks like there's a long-standing issue with some of the Intel devices (https://bugzilla.kernel.org/show_bug.cgi?id=201553) and there's even a patch exists, but I was too lazy to recompile the kernel or kernel module to get it applied. I didn't want to drift from the stock kernel, just because I want to receive updates to it through the package manager, without the need of recompiling it again and again, as the new version appears.

Don't make this fatal mistake, while building your own Smart Home

What are main caveats in existing "Smart Home" solutions?

Vendor-locked-in and incompatibility. If you started to build something using components of company A, you'll hardly could add components of company B. They require you to stick to their own custom mobile application or their own gateway or their own sophisticated protocol, they incapsulate into their WIFI devices or their own cloud. And that is dumb-ass idea for multiple reasons:

- if your "smart home" can be only configured through the mobile app that is worst case you can imagine. Mobile apps tend to stop working, if they're not updated by mothership company to support latest versions of mobile operating systems. If the company decides to ditch the support of application, which was the only way how you could configure your "smart home" - you're done. If you decided to upgrade your phone from iOS / Android version 98 to version 99, be prepared the application you used to control your smarthome will stop working, if it didn't have proper support of that OS version. 

- you decided not to upgrade your mobile phone to "latest and greatest" version of iOS / Android just because you don't want. Or your phone does not support it. But the app for "smart home" you had requires you to do that, so you cannot configure / control your "smart home" receive upgrades any more, until you buy a new smartphone. 

- your hardware gateway you bought from company A might fail after few years in service, and you'll be disappointed to know that you cannot buy a replacement, because company has moved away from that realm / doesn't make these specific devices any longer (and newer devices are not compatible with you other smart home components).

- if your smart home is using some cloud service, it means it will stop working the same moment the mothership company decides to block your own personal account, just because you're jewish, russian, black, or said something wrong on a social media - whatever. As a mild potential scenario they can first promise "the cloud" will be always free, but then they introduce a monthly usage fee. Or they get hacked and all the data from your "smart home" will be in hands of god knows who. Or that company decides to leave the smart home market and shut down it's clouds. Or your internet provider will be having issues and all your "smart home" will become a bunch of devices you cannot even interact with in a manual way

- do you know what all these companies are doing with your data, you send to their servers?

But there's a bunch of good news here. They are - opensource solutions. For a smart home automation save these names:

For offline voice assistants:

For preferred protocols your home devices should be supporting:

  • ZigBee 
  • Z-wave 

If you follow the above, you would be able to make 100% your own autonomous smart home, with fully interchangeable components and even have a completely offline voice assistant to control all that with your voice. At your home. Even without internet. 


Practical use cases

Voice control to turn on / off lights in different rooms, various electrical devices, connected to power outlets. Or multiple such devices at once.

Automatic climate control, when you need it. Should include thermostats on radiators +  turning on / off / set the temperature for air conditioning, so the room temperature will be matching to what you like.

Monitor air quality and turn the humidifier / air filter / when the air quality drops.

Shut down the cold/hot intake water valves in case of water leak detected or by voice command / remotely if you're leaving your home for some long time.

Monitor the soil moisture for home plants and warn you know when it drops so you will water them.

Shut down heated floors when noone is at home / at night / when leaving (by voice command or by pressing a button at your entry door)

Turn the lights on and off in a fish tank. Feed the fish by timer. Turn off the water pump filter while feeding for approx 30 minutes, so the food won't get sucked in a filter.

When leaving the apartment - turn off all the lights, set the heating level to minimum, turn off heated floors.


So what you need to do?

Given you already have an SBC, like my own Orange Pi 4 LTS, you just need to install a HomeAssistant, Rhasppy and buy a cheap ZigBee USB Dongle, with EFR32MG21 (most preferable),  CC2652P or CC2531 chips inside. 


Devices you might be interested in:

Controllable power strips:

  • Tuya ZigBee UseLink 4 AC outlets with USB / SM-SO306EZ-16 / TS0115
  • LELLKI WP33 - ZegBee 4 AC outlets with USB
  • Xiaomi ZigBee Power outlet AC-AC adapter ZNCZ04LM 

water valve actuator:

  • Tuya ZigBee water valve actuator - ZN231392

for heated floors
  • MOES ZigBee thermostat BHT-002 

for water radiators:
  • MOES Zigbee thermostat HY369RT 
  • MOES Zigbee thermostat TV-01
  • MOES Zigbee thermostat BRT-100-TRV



Some useful links

https://connect.smartliving.ru/umniy-dom-oborudovanie.html
https://modkam.ru/
https://sprut.ai/

Upgrading from Debian 11 Stable to Debian 11 testing. Recompiling Retropie. Moving to bigger SD card.

Here's the short note on what has been done with my project over the last couple of months.

Upgraded from Debian 11 Stable to Debian 11 Testing

This was a piece of cake job. It's well documented in the official Debian documentation. 

Before I did that, I wanted to have an option to rollback, if things go wrong. For that I decided to use Timeshift to create a full backup of my system utilizing a spare 256 GB SD card I had. The tricky thing is, the GUI frontend of Timeshift is not fully functioning in Debian 11 Stable and it looks like it's a known bug. Hopefully the Timeshift CLI was functioning so I was able to make that backup.

The upgrade itself was long and boring and included quite a number of manual interventions, especially for the purposes of merging my modified config files from /etc to align them to what was in Debian 11 Testing. Do not worry, it's not something that you'll have to know about in advance - the apt will warn you when you need to review and make a decision on what to don, when you get there.

As a result of this upgrade, I have eventually got what I wanted - more fresh packages and a rolling-style of release. But subjectively the Xorg (or KDE) is working less stable on Testing - so no surprise it was a price to pay. I'd wish to give myself an advice to not upgrade (or roll back) but it is too late already and I'm lazy one :)

Recompiling Retropie (actually emulationstation, retroarch and libretro cores)

The first thing I have noticed after upgrading to Debian 11 Testing, is that RetroPie part of my distribution stopped working. 

This is how it is supposed to work and worked before I went with  upgrade: when I turn on or reboot my Orange Pi 4 LTS, Linux is booted into systemd' multi-user.target where I do have Retropie scripts started. These scripts run EmulationStation, which acts as a nice UI dashboard with different themes. It is working upon SDL library in a framebuffer mode, so no Xserver is invovled at this point, as it's just not existing in RetroPie distribution. From the EmulationStation you chose a platform (NES, SNES, PSX - you name it) and a game to play. When you click on a game, the EmulationStation runs a Retrorch and passes it a bunch of CLI parameters, which include a selected libretro core and the game ROM file location. You usually don't see Retroarch UI, unless you invoke in-game overlay menu, and for you it looks like you have just started the game directly from EmulationStation, which is off course is not true :) 

So in my case, when I tried to start the game, EmulationStation attempted to start Retroarch but then it was immediately returning back to EmulationStation, like Retroarch was failing to start. It wasn't a surprise for me, given the number of underlying libraries have changed because of aforementioned Debian 11 Stable -> Testing upgrade in my case. 

The solution was to go and recompile all "core components" of Retropie, using their own scripts ~pi/RetroPie-Setup/rertropie_setup.sh as I was hoping they should pick up all the latest libraries that are there in the system.

"Core components" here are:
* EmulationStation itself
* Retroarch
* Libretro cores

The tricky thing in there, is that I managed to install quite a number of additional Debian packages since this whole project started (like X11, hehe), but given:
- RetroPie, as a project, is bit behind from its "core components", which are independent projects, in terms of code base and patches
- RetroPie is probably relying on a particular version of OS (like Debian 11 Stable) and appropriate set/versions of libraries to be there - so they didn't care to accept a lot of patches from their upstream projects, like EmulationStation or Retroarch
- I have significantly changed versions fo all those packages in my system, with my upgrade to Debian 11 Testing
... it wasn't surprise that all of that started to fall apart and I wasn't able to finish the build successfully without manual intervention.

The intervention I'm speaking about was quite simple - just follow the below steps. The main idea is that you run the default script to recompile everything, wait for it to fail,  then deal with a failure, and then attempt to build that thing again. Exactly in this order:

1. Run a script to attempt to build for the first time
$ sudo ~pi/RetroPie-Setup/rertropie_setup.sh

2. In the CLI menu, select "Manage packages" -> "Core" -> "Update all installed packages"

This will run another script that does git clone (or git pull) and then running ./configure and make of all RetroPie "core components", one-by-one. 

The build will be happening in ~pi/RetroPie-Setup/tmp/build/ folder - you'll see different folders for different "core components" will be appearing in there, as the build progresses.

Build logs are put to ~pi/RetroPie-Setup/logs folder.

3. When you see the build fails, don't panic. Go and investigate the log, where exactly it failed. In my case the very first issue I had was:

In file included from /home/pi/RetroPie-Setup/tmp/build/emulationstation/es-core/src/components/DateTimeComponent.h:5,
                 from /home/pi/RetroPie-Setup/tmp/build/emulationstation/es-core/src/components/DateTimeComponent.cpp:1:
/home/pi/RetroPie-Setup/tmp/build/emulationstation/es-core/src/utils/TimeUtil.h:41:37: error: field ‘mTimeStruct’ has incomplete type ‘tm’
   41 |                         tm          mTimeStruct;
      |                                     ^~~~~~~~~~~

The very first hit from google where Arch people were discussing the same issue happening recently for their AUR package was exactly the fix I took. You'll need to go and modify ~pi/RetroPie-Setup/tmp/build/emulationstation/es-core/src/utils/TimeUtil.h file to add this include statement to the top:

#include <time.h<----- this one
#include <string>  

Then you can repeat points 1 and 2 again (run the script and select an option to update all core packages) to see where it fails now.

4. Next issue was awaiting for me in a form of ffmpeg package I had installed to my system for my own needs. For some reason retroarch build scripts were trying to use it in one if Retroarch "drivers" (?) to record screen while playing a game I guess. This is the feature I don't use so I won't be missing it much. In terms of build log error it looked like this:

make: *** [Makefile:206: obj-unix/release/record/drivers/record_ffmpeg.o] Error 1
make: *** Waiting for unfinished jobs....
cores/libretro-ffmpeg/ffmpeg_core.c: In function ‘libretro_ffmpeg_retro_init’:
cores/libretro-ffmpeg/ffmpeg_core.c:243:4: warning: implicit declaration of function ‘av_register_all’ [-Wimplicit-function-declaration]
  243 |    av_register_all();
      |    ^~~~~~~~~~~~~~~
cores/libretro-ffmpeg/ffmpeg_core.c: In function ‘init_hw_decoder’:
cores/libretro-ffmpeg/ffmpeg_core.c:991:82: error: ‘AVStream’ has no member named ‘codec’
  991 |    struct AVCodec *codec = avcodec_find_decoder(fctx->streams[video_stream_index]->codec->codec_id);
      |                                                                                  ^~
cores/libretro-ffmpeg/ffmpeg_core.c: In function ‘select_decoder’:
cores/libretro-ffmpeg/ffmpeg_core.c:1101:49: error: ‘AVStream’ has no member named ‘codec’
 1101 |       format = fctx->streams[video_stream_index]->codec->pix_fmt;
      |                                                 ^~
cores/libretro-ffmpeg/ffmpeg_core.c: In function ‘open_codec’:
cores/libretro-ffmpeg/ffmpeg_core.c:1135:62: error: ‘AVStream’ has no member named ‘codec’
 1135 |    AVCodec *codec = avcodec_find_decoder(fctx->streams[index]->codec->codec_id);
      |                                                              ^~
cores/libretro-ffmpeg/ffmpeg_core.c:1142:31: error: ‘AVStream’ has no member named ‘codec’
 1142 |    *ctx = fctx->streams[index]->codec;
      |                               ^~
cores/libretro-ffmpeg/ffmpeg_core.c: In function ‘open_codecs’:
cores/libretro-ffmpeg/ffmpeg_core.c:1233:47: error: ‘AVStream’ has no member named ‘codec’
 1233 |       enum AVMediaType type = fctx->streams[i]->codec->codec_type;
      |                                               ^~
cores/libretro-ffmpeg/ffmpeg_core.c:1248:54: error: ‘AVStream’ has no member named ‘codec’
 1248 |                   && !codec_is_image(fctx->streams[i]->codec->codec_id))
      |                                                      ^~
cores/libretro-ffmpeg/ffmpeg_core.c:1283:54: error: ‘AVStream’ has no member named ‘codec’
 1283 |                AVCodecContext *ctx = fctx->streams[i]->codec;
      |                                                      ^~


I spent quite a time, trying to figure it out, how to overcome it. I tried to uninstall the ffmpeg package, but that wasn't helping. I tried to play around with configure and various generated define scripts - but that also didn't help. What eventually helped is to modify this script - ~pi/RetroPie-Setup/tmp/build/retroarch/qb/config.params.sh

In there you'll need to modify couple of parameters, to change their values from auto to no:

HAVE_FFMPEG=no

And then you're again free to go and repeat points 1 and 2.

5. The last build error I've got was this one:

(something X11-related cannot remember what exactly)

Knowing that RetroPie shouldn't be using any of X11 as it's running on top of SDL library in a framebuffer mode, we want to keep it as is. So go ahead to modify config.params.sh file again to change the value of HAVE_X11 parameter to no:

HAVE_X11=no

... and run the build again (repeat steps 1 and 2). This time it went just fine. 

 

Migrating everything to a bigger SD card

Initially for this project I bought 128 Gb SD card. It sounded about right, until I realized how big PlayStation 1 games could be. And I also wanted my SBC to host backup of my photos from my Android Phone and some movies. It wasn't long until I ordered another, 256 Gb SD card, but it was just lying around as a spare one.

So now the time has come and I need to move everything from one SD card to another. For that we need:

1. To boot our SBC out of its internal EMMC, which also has Linux flashed by manufacturer. It will just make things easier. For that we'll need to power off the device and eject the SD card and power it back on. 

2. Once Linux is boot up, we'll insert the SD card back and also will use a small USB SD card reader to insert our second SD card.

3. With using lsblk we figure it out, what is the name of our block device (under /dev/). In my case it was /dev/mmcblk1 and /dev/sda

4. With using dd we clone the entire disk, using block size of 4 Mb like this:

dd if=/dev/sda of=/dev/mmcblk1 bs=4M

This is where I started to get errors. dd was complaining it cannot read from source device (smaller SD card) after reading few tens of Gb from it. I run e2fsck / badblocks / some other utilites against it number of times, but all of them were  keep complaining and complaining, finding issues and not actually fixing them. 

I gave up and rebooted the system, using different power adapter and gave it another try. It went just fine this time, the only difference was that I cloned partition (i.e. /dev/sda1 to /dev/mmcblk1) instead of clonning the whole disk. After cloning was successfully finished, I ran the parted CLI partition manager to extend the fresh partition to span all 100% of disk and then tried to upsize the filesystem with resize2fs. This is where I started to see some issues again. I rebooted again, ran e2fsck and badblocks - none of them found anything, so I ran resize2fs again and this time it went fine. 

I'm guessing all these issues had something to do with the cheap USB SD card reader I had.

Sound subsystem in Linux is still fucking mess

Introduction of another piece of software (PipeWire) only made it worse.
For the end users, even technical ones like me, every new topic in Linux reveals a true messy nature of it.
I'll give you this example.
Recently I have installed Ubutntu 22.10 on my desktop PC. From the user perspective it works just great, but when I tried to run some of my past experiments on it, I was doing on my Orange PI 4 LTS, I figured arecord / aplay just don't work:

$ arecord -d 5 -r 48000 test.wav
ALSA lib pcm_dsnoop.c:566:(snd_pcm_dsnoop_open) unable to open slave
arecord: main:831: audio open error: No such file or directory

$ aplay gb0.ogg 
ALSA lib pcm_dmix.c:999:(snd_pcm_dmix_open) unable to open slave
aplay: main:831: audio open error: No such file or directory

I haven't look deeper into it, whether that is happening because of some pseudo-files (device files) are missing, or they're being exclusively locked by some different audio servers (Pipewire? Pulseaudio?). At first, I tried to figure out, what kind of audio server is being used, and to my surprise I found Ubuntu 22.10 has a fucking mess of all 3 linux audio subsystems:

$ apt list --installed | grep pulse

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libcanberra-pulse/kinetic,now 0.30-10ubuntu1 amd64 [installed,automatic]
libpulse-dev/kinetic,now 1:16.1+dfsg1-1ubuntu3 amd64 [installed,automatic]
libpulse-mainloop-glib0/kinetic,now 1:16.1+dfsg1-1ubuntu3 amd64 [installed,automatic]
libpulse0/kinetic,now 1:16.1+dfsg1-1ubuntu3 amd64 [installed,automatic]
libpulse0/kinetic,now 1:16.1+dfsg1-1ubuntu3 i386 [installed,automatic]
pipewire-pulse/kinetic,now 0.3.58-2ubuntu1 amd64 [installed,automatic]

$ apt list --installed | grep wire

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

gstreamer1.0-pipewire/kinetic,now 0.3.58-2ubuntu1 amd64 [installed,automatic]
libpipewire-0.3-0/kinetic,now 0.3.58-2ubuntu1 amd64 [installed,automatic]
libpipewire-0.3-common/kinetic,kinetic,now 0.3.58-2ubuntu1 all [installed,automatic]
libpipewire-0.3-modules/kinetic,now 0.3.58-2ubuntu1 amd64 [installed,automatic]
libwireplumber-0.4-0/kinetic,now 0.4.12-1 amd64 [installed,automatic]
pipewire-bin/kinetic,now 0.3.58-2ubuntu1 amd64 [installed,automatic]
pipewire-pulse/kinetic,now 0.3.58-2ubuntu1 amd64 [installed,automatic]
pipewire/kinetic,now 0.3.58-2ubuntu1 amd64 [installed,automatic]
wireless-regdb/kinetic,kinetic,now 2022.06.06-0ubuntu1 all [installed,automatic]
wireless-tools/kinetic,now 30~pre9-13.1ubuntu4 amd64 [installed,automatic]
wireplumber/kinetic,now 0.4.12-1 amd64 [installed,automatic]

$ apt list --installed | grep -i alsa

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

alsa-base/kinetic,kinetic,now 1.0.25+dfsg-0ubuntu7 all [installed,automatic]
alsa-topology-conf/kinetic,kinetic,now 1.2.5.1-2 all [installed,automatic]
alsa-ucm-conf/kinetic,kinetic,now 1.2.6.3-1ubuntu2 all [installed,automatic]
alsa-utils/kinetic,now 1.2.6-1ubuntu1 amd64 [installed,automatic]
gstreamer1.0-alsa/kinetic,now 1.20.3-2 amd64 [installed,automatic]

Start here

Disable Firefox from updating itself and flash those annoying "Restart to Keep Using Firefox" messages on you

I recently switched from Brave to Firefox. Just because Brave appeared to be some proprietary shit, even though they're masking themselv...