niels / Automotive / #carplay,#continuity,#hotspot,#iphone

CarPlay or an AI box?

Recently, I looked into dongles that take the existing CarPlay head unit in your car and make it work wirelessly. Unfortunately all of these dongles suffer the same problem: a 1-2 seconds delay when making phone calls.

There’s also no way to use CarPlay for apps while still routing phone calls through regular Bluetooth. At least not with the head unit in my 2018 Mazda CX-5. As soon as CarPlay connects, it drops all Bluetooth connections, even those to other phones.

Although I don’t make a lot of phone calls while driving, it needs to work without annoying delays when I do.

AI boxes

Disappointed with the wireless dongles, I allowed the Amazon and AliExpress algorithms to take me into the world of AI boxes. I don’t know what AI stands for in this context, but there’s no Artificial Intelligence involved.

The AI boxes are essentially Android set-top boxes for your car. Instead of an HDMI output to your TV, these boxes output CarPlay to your car’s head unit. You read that right – even though these are Android boxes, that run Android apps, they output a CarPlay signal to your car’s head unit.

Watching reviews I couldn’t help wondering: why don’t people just use an old phone? These AI boxes aren’t cheap, nor are they very good.

iPhone vs AI Box

Different people have different needs, so let’s do a quick comparison. I’m comparing to an old iPhone here – comparing to an Android phone should yield similar results.

Start-up

AI boxes have no battery. This means they need to boot every time you start the car. This can be annoying if the AI box needs considerably more than than your head unit.

The iPhone does have a battery, but it could run out if not charged regularly. (Continue reading to see how I improve this.)

Platform Features

AI boxes are Android based. There are no iOS boxes. Great if you’re an Android user. Inconvenient if you’re an iPhone user.

AI boxes will show any Android app on your head unit (barring compatibility issues). The iPhone will display only apps designed for CarPlay.

Some AI boxes come with an additional HDMI output, allowing you to stream video to screens in the back seat.

Support

Apple promise a minimum of 4 years of major updates on all iPhones. It’s also known to release security fixes regularly, for several years.

AI box manufacturers make no promises. I have not seen any of them provide a major Android version update or regular security updates.

So far it appears that AI box manufacturers limit themselves to releasing functional bug-fixes for their latest products only.

Performance

The fastest AI boxes available at the time of writing use a low-end chip-set from 2017. The Qualcomm SD660. It’s decent, but not great. Other AI boxes use lesser chip-sets. They are outdated the day you buy them.

Setup

To make the CarPlay iPhone a superior alternative to an AI box, we need to prevent its battery from draining. We can accomplish this by using the Shortcuts app and a proper charger.

Shortcuts

If you haven’t already, install Apple’s Shortcuts app. We’ll use it to automatically enable the low power- and airplane modes on the CarPlay iPhone when we’re not using it.

In Shortcuts:

  • Switch to the Automation tab
  • Choose Create Personal Automation
  • Scroll down to CarPlay and choose Disconnects.
  • Tap Next.

Now add the following Actions:

  • Set Low Power Mode > Turn Low Power Mode On.
  • Set Airplane Mode > Turn Airplane Mode On.
  • Tap Next.

Finally:

  • Disable the Ask Before Running option.
  • Tap Done.

We also have to create the reverse: when CarPlay connects we want the CarPlay iPhone to disable the low power- and airplane modes.

In Shortcuts:

  • Switch to the Automation tab
  • Choose Create Personal Automation
  • Scroll down to CarPlay and choose Connects.
  • Tap Next.

Now add the following Actions:

  • Set Low Power Mode > Turn Low Power Mode Off.
  • Set Airplane Mode > Turn Airplane Mode Off.
  • Tap Next.

Finally:

  • Disable the Ask Before Running option.
  • Tap Done.

Charger

To ensure your CarPlay iPhone charges sufficiently on shorter drives, get a USB-PD charger providing 20W or more. For example, the 40W mophie charger that Apple sells.

Phone Calls (optional)

Connect both iPhones to the same iCloud account and the same Wi-Fi. Then enable Calls on other devices on your regular iPhone. This allows the CarPlay iPhone to answer your calls. Without any noticeable delay or other annoyances.

To setup a Wi-Fi hotspot in the car I used the Huawei E8372 USB adapter. I’ve tried using a Personal Hotspot on the CarPlay iPhone itself, but that is not supported.


niels / Blog / #classicpress,#migration

Migration

Update: all content has been migrated. Will keep this post around to test theme and plugins.

While content is being migrated, you can find the old blog at https://peen-dev.pages.dev/

Testing my new Markdown editor plug-in for ClassicPress.

Does it work?

  1. Yes
  2. No
  3. Not sure

More test.

<?php
echo "code test";

testing, 1, 2, 3. 4.


niels / Software / #linux,#ubuntu

Preferring IPv4 over IPv6

As explained in my previous post, I get my IPv6 subnet through a tunnelbroker. This is a great way to use IPv6 when your Internet provider does not yet support it.

There’s a downside though: the tunnel adds overhead in terms of both latency and a lower MTU. It also introduces an additional point where congestion or failure can occur.

Getaddrinfo

Most Linux apps use the getaddrinfo function to obtain the IP address for a hostname. It is this function that causes your apps to prefer IPv6 over IPv4.

Fortunately it comes with a configuration file, which we can modify to have it prefer IPv4 over IPv6.

Open the configuration file by entering:

sudo vi /etc/gai.conf

(replace vi with your preferred editor)

Then scroll down to the following section:

#precedence  ::1/128       50
#precedence  ::/0          40
#precedence  2002::/16     30
#precedence ::/96          20
#precedence ::ffff:0:0/96  10
#
#    For sites which prefer IPv4 connections change the last line to
#
#precedence ::ffff:0:0/96  100

Uncomment that last line, so it looks like this:

#precedence  ::1/128       50
#precedence  ::/0          40
#precedence  2002::/16     30
#precedence ::/96          20
#precedence ::ffff:0:0/96  10
#
#    For sites which prefer IPv4 connections change the last line to
#
precedence ::ffff:0:0/96  100

Save the file.

That’s it! Most apps will now prefer IPv4 over IPv6.


niels / Hardware / #linux,#router

ExtraIP.com and UDM Pro

I’m using IPv4 and IPv6 ranges supplied by extraip.com. (Available in The Netherlands only.)

Unfortunately the UDM Pro has no UI for setting up the required tunnels. I had to write a script, which I’m sharing below.

My Use Case

The script configures dnsmasq to distribute the IPv6 subnet using SLAAC. If you prefer, you could comment this section out and use the DHCPv6 server in the UI instead.

It also omits the traditional use of an IPv4 network-, gateway- and broadcast- address, allowing us to use all 8 IP addresses for clients or servers.

Prerequisites

The instructions assume you have udm-utilities installed.

Disable IPv6 in UI

To prevent unexpected behavior created by the UI, we disable IPv6 on both WAN and LAN interfaces.

WAN

Open the Network application and navigate to Internet. Now edit your WAN interface to disable its IPv6 Connection.

LAN

Open the Network application and navigate to Settings > Networks. Edit the relevant network,
scroll down to IPv6, and switch it to Disable.


niels / Blog / #linux

Tweaking Elementary OS

Elementary OS has been my favorite desktop distribution for the past 2 years or so. Its out-of-the-box experience is very close to my preferred setup. Nothing is perfect though. Below are the tweaks I apply when installing Elementary OS 6.

BTRFS

The default Elementary OS install uses an encrypted ext4 partition. If you want to use encrypted btrfs, you’re out of luck. The Custom Install will let you use btrfs, but not encrypted btrfs. My work-around is very simple, if a bit tedious.

Default install

First run the default install like you would normally do. This erases your disk and sets you up with an encrypted ext4 partition.

Open Encryption

Boot the installer once more. This time, choose a Custom Install. Choose to manage your disks, which fires up gparted. Use gparted to Open Encryption on the encrypted partition. (You could do this on the command-line, but this is quick and easy.)

Convert to btrfs

Exit gparted and go backwards in the installer. Now choose to enter the Demo mode and open a Terminal.

Enter the following command to convert the ext4 root to btrfs:

sudo btrfs-convert /dev/mapper/data-root

This takes only a minute or so on a clean install.

Update /etc/fstab

Before rebooting, we’ll need to update /etc/fstab. To access the file, we first mount our newly converted btrfs filesystem:

sudo mount /dev/mapper/data-root /mnt

We then determine the new blkid of the btrfs filesystem:

sudo blkid /dev/mapper/data-root

It will show you two ID’s, you need the first one:

sudo blkid /dev/mapper/data-root 
[sudo] password for niels:         
/dev/mapper/data-root: UUID="dba6ca21-79e0-49c9-b889-c37d2ccb446a" UUID_SUB="27c5452a-7878-4357-8f95-596a08cab55b" TYPE="btrfs"

Now use your favorite text editor to update /etc/fstab:

PARTUUID=48e067c9-0a5e-4ad7-acb6-2313973188d6  /boot/efi  vfat  umask=0077  0  0
UUID=da66e7aa-9162-4550-b527-514a045759b0  /boot  ext4  noatime,errors=remount-ro  0  0
UUID=dba6ca21-79e0-49c9-b889-c37d2ccb446a  /  btrfs  defaults,noatime,autodefrag,compress  0  0
/dev/mapper/data-swap  none  swap  defaults  0  0

Two things have been updated:

  1. The UUID, as obtained with blkid.
  2. The options changed from noatime,errors=remount-ro to defaults,noatime,autodefrag,compress

Reboot

You should now be able to reboot into your Elementary OS install.


niels / Blog / #linux

Magic Trackpad 2 with Xorg

Not quite happy with the solution described in my original post, I took another look at the problem and found:

  1. Xorg defaults to the libinput driver (just like Wayland), not the synaptics driver.
  2. The libinput driver complained about a parse error in /usr/share/libinput/50-system-lenovo.quirks.

I ignored the parse error the first time around because I do not have any lenovo input devices on this computer and assumed the parse error would not affect other devices. However, a parse error in 1 quirks file, does cause all quirks files to be ignored.

Deleting the faulty quirks file resolved the issue. My Magic Trackpad 2 now functions properly with Xorg.

Original post

I’ve been using an Apple Magic Trackpad 2~~ with my Ubuntu desktop for the past two years or so.
When using Wayland this works perfectly out-of-the-box.

Not so much with Xorg. It detects the trackpad and loads the driver, but the cursor won’t move unless I press the trackpad at the same time.

Creating /etc/X11/xorg.conf.d/10-touchpad.conf
fixed this:

Section "InputClass"
    Option "FingerLow" "2"
    Option "FingerHigh" "2"
EndSection

If you have more – potentially conflicting – input devices you’ll want to expand that to:

Section "InputClass"
    Identifier "Apple Magic Trackpad"
    MatchIsTouchpad "on"
    MatchUSBID "05ac:0265"
    Driver "synaptics"
    Option "FingerLow" "2"
    Option "FingerHigh" "2"
EndSection

Use lsusb to check that the USBID is correct for your trackpad:

❯ lsusb
...
Bus 001 Device 005: ID 05ac:0265 Apple, Inc. Magic Trackpad 2
...

niels / Blog / #jigsaw,#php

Jigsaw

Whoops. I accidentally wiped the VM running my WordPress blog.

Rather than restore the WordPress blog I decided to go with Jigsaw this time. Jigsaw is one of many static site generators, or as the cool kids say, a way to use Jamstack.

Jamstack

What makes a Jamstack site more than just a regular static website is its use of
Javascript and API services to add dynamic features to your website.

The JAM in Jamstack stands for Javascript, API and Markup

I’m not a fan of microservice architectures like Jamstack as it tends to add complexity, cost and a dependency on potentially unreliable 3rd-parties.

That said, I don’t need much functionality on my blog. This is JAMstack with very little J and no A. I may add comments at some point, but only if I can self-host them.

WordPress

The founding developer of WordPress, Matt Mullenweg, has this to say about it:

JAMstack is a regression for the vast majority of the people adopting it

Matt is biased, of course, but I agree with his arguments. Read them in more detail at thenewstack.io.


niels / Hardware / #laptop,#legion,#lenovo,#ubuntu

Ubuntu on the Legion 5 Pro (2021)

Heads up: I’m not a gamer. A combination of specs, pricing, availability and urgency led me to purchase this laptop for productivity reasons. My run-through may not cover all aspects needed for gaming.

As my work depends on this laptop, I did purchase the additional on-site support.

Keyboard Shortcuts

If the RGB show on the keyboard annoys you, use Fn+SPACE to select a less annoying mode for now.
Also: Fn+L to toggle the Legion logo, Fn+Q to toggle thermal profile. These shortcuts work on both Windows and Linux.

Windows

I expect support to want to deal with Windows only, so I left Windows installed.

Even if you decide to remove Windows, I recommend you set it up first and use it to apply any BIOS or firmware updates prior to installing Ubuntu. (As it turns out, my laptop already shipped with the latest BIOS version.)

The factory Windows install uses about 60GB, so I shrunk the Windows-SSD down to 75GB. You can use the Disk Management tool to do so.

BIOS

Shutdown the laptop and restart it while pressing F2. This gets you into the BIOS. I made the following changes:

  • Graphic Device: Dynamic Graphics (you will need to use nomodeset in GRUB if you don’t do this)
  • Boot > PXE Boot to LAN: Disabled;

That’s it. I left Secure Boot enabled. Ubuntu and Ubuntu based Linux distributions have no problem with it.

Ubuntu

Install Ubuntu. How to install Ubuntu has been well documented, I won’t repeat it here.

You’ll notice that while the brightness function keys appear to work they do not actually change the brightness. You can fix this by editing /etc/default/grub and adding the amdgpu.backlight parameter:

GRUB_CMDLINE_LINUX="amdgpu.backlight=0"

Run update-grub, reboot, and things will work.

Battery Conservation Mode

Battery conservation mode prevents your laptop battery from charging fully and keeps it around 60% instead. This should aid the longevity of the battery.

For convenience I created a systemd unit called /etc/systemd/system/battery-conservation-mode.service
with the following content:

[Unit]
Description=Battery Conservation Mode

[Service]
Type=oneshot
ExecStart=/usr/bin/bash -c 'echo 1 > "/sys/devices/pci0000:00/0000:00:14.3/PNP0C09:00/VPC2004:00/conservation_mode"'
ExecStop=/usr/bin/bash -c 'echo 0 > "/sys/devices/pci0000:00/0000:00:14.3/PNP0C09:00/VPC2004:00/conservation_mode"'
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Which we then activate using:

systemctl daemon-reload 
systemctl start battery-conservation-mode 
systemctl stop battery-conservation-mode 
systemctl enable battery-conservation-mode 

Function Lock

Maybe you never use the F1, F2,.. keys and just want them to function them as permanent media keys (for volume control, etc.) instead. You can do this by enabling the Fn Lock:

echo 1 > "/sys/devices/pci0000:00/0000:00:14.3/PNP0C09:00/VPC2004:00/fn_lock"

Just like the battery conservation mode, you could put this in a systemd unit to enable it automatically at start-up.

File System

Ubuntu comes with periodic SSD trimming out of the box. No need to enable that yourself. If you use encrypted partitions like I do, Ubuntu also enabled discard in crypttab automatically. Some changes I made to fstab:

  • Added the ssd option for my btrfs file systems.
  • Added the noatime option to both btrfs and ext4 file systems.

niels / Software / #linux,#snap,#wayland,#zsh

Snap apps with Wayland and Zsh

There’s are two longstanding issues using snap apps in Ubuntu. Two issues that still exist in Ubuntu 20.04 beta.

Snap apps don’t show up in Gnome’s Activities view when using Wayland instead of Xorg.
Snap apps cannot be started from the command-line when using zsh instead of bash.
Looking into this, I ran into numerous discussions on both topics. Most notably:

ZSH

The zsh work-around mentioned in these and other discussions works very well. Just add the following line to your .zshrc. (Adding it to /etc/zsh/zshrc should work as well.)

emulate sh -c 'source /etc/profile.d/apps-bin-path.sh'

When using bash the scripts in /etc/profile.d/ are sourced automatically. Zsh does not bother with them, unless we instruct it to.

Wayland

Unfortunately the work-arounds for Wayland did not work for me. They failed to convince Wayland and Gnome to look in snap’s applications folder.

The following line links snap’s applications folder into the Ubuntu’s main applications folder.

sudo ln -s /var/lib/snapd/desktop/applications/ /usr/share/applications/snap

Unlike all the other work-arounds out there, there’s no need to logout and log back in. This works instantly.


niels / Blog / #wordpress

Cleaner Theme

Update 2021-10-31: I’m no-longer using WordPress or the theme mentioned below.

Changed to a nice clean WordPress theme that uses Tailwind CSS. Based on the wp-tailwind starter theme by freeshifter. (Thank you!)

Will share my changes on Github shortly.