Monday, February 13, 2023

Ubuntu 22.04.1 on Lenovo Thinkpad P14s (Ryzen R7 Pro 6850U)

I was a bit nervous about this as the Canonical site says that the latest version of Ubuntu may not run on the Thinkpad P14s:

Pre-installed in some regions with a custom Ubuntu image that takes advantage of the system’s hardware features and may include additional software. Standard images of Ubuntu may not work well, or at all.

Indeed, on booting up the laptop is indeed has a custom kernel 5.14.0-1047-oem and Ubuntu 20.04 (Focal Fossal). But I was determined to upgrade to 22.04. After upgrading the hard drive to 2TB PCIe 4.0 I noticed that in this model (21J5) there are NO slots for memory expansion. So you're stuck with the soldered 32GB it comes with. However, the installation went smoothly. I chose "Install 3rd party software for graphics and wifi". After installation I rebooted and tested wifi, sleep, suspend, closing the lid and connecting to a dock with two screens, keyboard and mouse. Also tested the function keys. All was fine. So I'd recommend this model for those of us who want a Linux laptop and don't want to pay the Microsoft tax.

Sunday, May 1, 2022

Ubuntu 22.04: Gdk-CRITICAL **... gdk_wayland_window_set_dbus_properties_libgtk_only: assertion 'GDK_IS_WAYLAND_WINDOW (window)' failed

I encountered this error when running the soffice commandline interface under Jammy Jellyfish (Ubuntu 22.04). Since there wasn't any window being generated I was puzzled. A little searching revealed that the library libgdk3.0-cil (CLI binding for GDK 3) was not installed, and so running:

sudo apt install libgdk3.0-cil

solved the problem.

Wednesday, March 23, 2022

Create a bootable .iso from a folder in Linux

If you have ever tried to modify a Linux installer you will know that you must mount the .iso file:

sudo mkdir /mnt/ubuntu
sudo mount -o loop ubuntu-xxx.iso /mnt/ubuntu

then copy it to another directory:

sudo cp -ra /mnt/ubuntu ~/ubuntu

because you can only mount it read-only. Then you can make your modifications to the files in the copied folder. In my case I provided a default value for the keyboard (US) to see if the installer would skip asking me for the setting. Then the bootable .iso must be recreated from the modified folder. But how to do it? I used xorriso:

sudo xorriso -as mkisofs \
   -J -R -V 'UNUNTU-20.04 [CUSTOM]' \
   -o ubuntu-20.04.custom.iso \
   -J -joliet-long -cache-inodes \
   -isohybrid-mbr isohdpfx.bin \
   -b isolinux/isolinux.bin \
   -c isolinux/ \
   -boot-load-size 4 -boot-info-table -no-emul-boot \
   -eltorito-alt-boot \
   -e boot/grub/efi.img \
   -no-emul-boot -isohybrid-gpt-basdat -isohybrid-apm-hfsplus \

Note the use of the file isohdpfx.bin. I couldn't locate this in the Ubuntu distribution so I just copied the first 432 bytes of the existing Ubuntu .iso installer and saved it using hexedit. Without this it will fail to mount and hence won't be bootable. Now make an installable USB out of the .iso using a tool like Startup Disk Creator or Balena Etcher and it will boot happily from it.

Monday, October 25, 2021

Puppeteer page waitForSelector and visible:true option won't process click

I had a problem in Puppeteer where an initially hidden menu has to be invoked by clicking on the menu icon. I used await page.waitForSelector(selector) and then called, where 'selector' is a css selector and page is my page object in Puppeteer. Nothing happened. I figured that as the page had just loaded the menu icon might have been in the DOM but not yet visible. So I tried adding the visible:true option: page.waitForSelector(selector,{visible:true}). Again nothing happened. Then I added a short delay before via page.waitForTimeout(2000) and it worked. But that's like a hack. I mean how long do you wait? So I figured that the menu icon is visible but the click-handler for it is not yet loaded, and waiting ensures that it usually is. But how to do it correctly? Then I tried this:

await page.waitForSelector(selector);
await page.$eval(selector, elem =>;

And it worked.

Wednesday, September 1, 2021

Cure for crashing iPhone

My iPhone kept crashing. If I left it on overnight it would invariably crash by morning and drain the battery in the process. I tried all the cures suggested on the Internet, including wiping the phone and reinstalling everything from scratch. That worked for a while then it started crashing again. I tried shutting it down overnight, but it still crashed the same. So then I tried shutting it down AND wrapping it in aluminium foil. And hey presto -- it woke up the next morning and the battery was fine. So this tells me that there is some communication going on between even a 'shut down' iPhone and the service provider, since radio waves can't penetrate alfoil. Also that there is some kind of broken connection that it tries to re-establish overnight that fails repeatedly until it runs out of power. Miraculously, the foil also stopped it crashing -- for a while. So those broken connections appear to be marked as 'stale' and it doesn't try to remake them, though eventually new ones appear. So if you have the same problem it can't hurt to try the same remedy that worked for me -- shutting it down overnight and wrapping it in alfoil. It's a lot easier than reinstalling the software.

Wednesday, August 18, 2021

Installing 'tkinter' on Linux for Python3

I find it confusing that the python module 'tkinter', the interface module for the tk scripting language, is only installable via the Linux platform package manager. On Ubuntu I used:

sudo apt-get install python3-tk

and then in python3 I can import tkinter:

Python 3.9.5 (default, May 11 2021, 08:20:37) 
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> quit()

Using pip3 directly to install tkinter doesn't work, nor does pip3 install tk, which installs an unrelated module.

For python2 remove the '3' from the above commands.

Wednesday, July 21, 2021

Installing VLC on Ubuntu 21.04

There are plenty of guides on how to install VLC on Ubuntu, but rather few on how to do it on Ubuntu 21.04. If you believe what they say then you only need to install the vlc and ubuntu-restricted-extras packages. The first package is the VLC application itself and the ubuntu-restricted-extras is supposed to contain all the needed codecs to play encrypted dvds. Except it doesn't work. You also need libdvd-pkg. Install that and all will be fine.