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.

Sunday, July 18, 2021

Disabling middle trackpad click on Ubuntu 21.04

Since Ubuntu 21.04 my fix to reassign the middle trackpad click using xinput to "left click" no longer works. Now whenever my hand drifts to the middle of the trackpad, and I click on an application icon, I open up a copy of the current application. Or if I am in a program I end up pasting something I didn't want to. So I tried instead gnome-tweaks, which you can easily install using apt-get in terminal:

sudo apt-get install gnome-tweaks

Now lauch gnome-tweaks (e.g. by typing gnome-tweaks in Terminal) and select "Keyboard and Mouse". There is a section there called "Mouse click emulation". There are three settings:

  1. Fingers: all single trackpad clicks are left-clicks but you can simulate a right click by tapping with two fingers. I find this the most comfortable setting.
  2. Area: this is the default. the trackpad is divided into three areas. The bottom middle of the trackpad is middle click, leaving very little space for left-click which is dominant.
  3. Disabled: all clicks on the trackpad are left-clicks. I find this useless as you must have right click in many cases.

There is also a setting to disable middle click paste. I turned that off as I do not want middle click at all. Middle click makes sense with a mouse where you have tactile feedback as to what you are pressing but on a featureless trackpad you can only middle-click reliably if you stare at it the whole time. For terminal copy and paste I use shift-control-c and shift-control-v. With option 1 above you can still have middle click paste with a three-finger tap.