Fix generic application icon under Wayland session

A common problem in Wayland session is some apps show generic Wayland icon instead of the proper application icon. Here is an example:

Fortunately, this problem is very easy to fix for common GUI libraries.

Here are the solutions (replace APP_ID with application ID):

Qt

C++

#include <QGuiApplication>

QGuiApplication::setDesktopFileName(APP_ID);

or

#include <QApplication>

QApplication app(argc, argv);
app.setDesktopFileName(APP_ID);

PyQt (Python)

from PyQt6.QtGui import QGuiApplication

QGuiApplication.setDesktopFileName(APP_ID)

or

class Application(QtWidgets.QApplication):
...


app = Application()
app.setDesktopFileName(APP_ID)

GTK

C

g_set_prgname(APP_ID);

gtkmm (C++)

Glib::set_prgname(APP_ID);

gtk-rs (Rust)

glib::set_prgname(Some(APP_ID));

PyGObject (Python)

from gi.repository import GLib

GLib.set_prgname(APP_ID)

GLFW

glfwWindowHintString(GLFW_WAYLAND_APP_ID, APP_ID);

Slint

use i_slint_backend_winit::winit::platform::wayland::WindowAttributesExtWayland;

let backend = i_slint_backend_winit::Backend::builder()
    .with_window_attributes_hook(|attr| attr.with_name(APP_ID, ""))
    .build()
    .unwrap();

slint::platform::set_platform(Box::new(backend))

Run Linux ELF binary file on Android

Although usual Android apps are installed to your device as APK files, you still have the option to run native ELF binary file compiled for the architecture of your device.

Prerequisites

  • A Linux PC with gcc or other C compiler installed
    • If you are trying to run the compiled ELF file on a device with an ISA that differs from your PC, a cross compiler is required
      • The most common scenario is x86-64 PC + ARM64 (aka. AArch64) Android device, where aarch64-linux-gnu-gcc is needed
  • An Android phone, container or emulator (I am using Waydroid) with Termux installed

Compilation

Take the following "Hello world" program (test.c) as an example:

#include <stdio.h>

int main() {
    printf("Hello world!\n");
    return 0;
}

Use gcc to compile it:

gcc test.c -static -o test

If you intend to run the compiled binary on ARM64 (aka. AArch64) devices and your PC is not ARM64:

aarch64-linux-gnu-gcc test.c -static -o test

-static option is needed to statically link the system C library as Android uses bionic as C library instead of glibc or musl.

Next, copy the compiled ELF file to your Android device.

Copy the compiled ELF file to the appropriate path

As /storage is mounted with option noexec, you can't execute files under the /storage directory even if they have been given executable permission with chmod +x. Therefore, we need to find a directory without noexec mounting option. A common choice is /data/local/tmp.

- $ mount
...
tmpfs on /storage type tmpfs (rw,nosuid,nodev,noexec,relatime,mode=755,gid=1000,inode64)
...

To access /data/local/tmp directory, the root permission is needed for Termux.

su
cp test /data/local/tmp

Execute the file

chmod +x test
./test

See also