logo
vision scalability social networking revelation source

Linux desktop

abstract: Linux desktop setup: configuring earlyoom for desktop responsiveness, browser choices, coupling GUI applications to the Linux desktop, and Flatpak sandboxing.

1 Desktop

1.1 memory

Linux oom killer is designed for servers and the C compilation toolchain. Locks desktops

Any linux desktop needs early oom.

apt update
apt ugrade -qy
apt install earlyoom libnotify-bin
nano  /etc/default/earlyoom
# Examples:

# Print memory report every minute instead of every hour
# EARLYOOM_ARGS="-r 60"

# Available minimum memory 5%
# EARLYOOM_ARGS="-m 5"

# Available minimum memory 15% and free minimum swap 5%
# EARLYOOM_ARGS="-m 15 -s 5"

# Avoid killing processes whose name matches this regexp
# EARLYOOM_ARGS="--avoid '(^|/)(init|X|sshd|firefox)$'"

# See more at `earlyoom -h'

notify_command='notify-send "Early OOM" "Process {process_name} was killed"'

# Prefer killing browsers, avoid Codium and development tools
EARLYOOM_ARGS="-m 5 -M 10 -s 5 -S 10 -r 60 --prefer '(^|/)(firefox|chrome|chromium|brave|opera|vivaldi|microsoft-edge|waterfox|librewolf|epiphany|konqueror|falkon|qutebrowser|nyxt|surf|midori|seamonkey|palemoon|basilisk)$' --avoid '(^|/)(init|systemd|Xorg|sshd|dbus-daemon|gnome-shell|kwin_x11|plasmashell|codium|code-oss|vscodium|gcc|g\\+\\+|clang|clang\\+\\+|make|cmake|ninja|meson|autoconf|automake|ld|as|objdump|gdb|rustc|cargo|go|javac|java|node|npm|python|ruby|php)$' --avoid-oom-score-adj -1000"

If you have unreasonably large swap storage, you can still get the system stalling unreasonably while earlyoom fails to kick in.

# Reduce system's tendency to swap
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf

# Prefer dropping caches over swapping
echo 'vm.vfs_cache_pressure=50' | sudo tee -a /etc/sysctl.conf

For vms that are used a lot, consider providing ample swap storage on virtual disk that loses all its contents every time the vm is shut down and restarted.

1.2 browser

Install librewolf, though you might need firefox for websites than insist on full spy capability.

apt update && apt install extrepo -y
extrepo enable librewolf
apt update && apt install chromium librewolf -y

Harden librewolf/firefox

The Chromium browser is the anti privacy browser, reporting everything you do to one of the world’s greatest llms, and should only be used in a firewalled and wireguarded environment dedicated to a single identity with a single set of activities.

2 Implementing Gui in linux

2.1 coupling to the desktop

To couple to the desktop requires a pile of information and configuration, which most people ignore most of the time. To the extent that they provide it, they seem to write it for the Gnome based desktops, Cinnamon and Mate – more for Mate because it is older and has changed less.

An install program should use desktop-file-install which is presumably customized for each desktop,

The autostart directory `$XDG_CONFIG_HOME /autostart’ is a part of the freedesktop.org/XDG Desktop Application Autostart Specification.

$XDG_CONFIG_HOME is seldom set, in which case it is equal to ~/.config, hence the autostart directory is nearly always ~/.config/autostart

The desktop specification is chock full of references to $XDG_foo_bar, which is confusing because these are environment variables that no one ever sets, and which should never be set, which means that their default values almost always apply. Further, many of the directories are not default created, so the first program to write a file into them has to create them. Which is likely to be your program, because superuser is likely to create a user specially for your program.

This mysterious usage is explained, cryptically, in base directory specifications

Since wxWidgets is written for GDT in its linux version, it is written for Gnome.

Gnome3, the default Debian desktop, is broken, largely because they refuse to acknowledge that it is broken, so the most standard linux environment, the one for which your practices are least likely to break on other linuxes, is Debian with Lightdm and Mate. (pronounced Mahtee)

Looks to me that KDE may be on the way out, hard to tell, Gnome3 is definitely on the way out, and every other desktop other than Cinnamon and Mate is rather idiosyncratic and non standard.

Lightdm-Mate has automatic login in a rather obscure and random spot. Linux has its command line features polished and stable, but is still wandering around somewhat lost figuring out how desktops should work.

Under Mate and KDE Plasma, bitcoin implements run-on-login by generating a bitcoin.desktop file and writing it into ~/.config/autostart ($XDG_CONFIG_HOME/autostart).

It does not, however, place the bitcoin.desktop file in any of the expected other places. Should be in /usr/share/applications ($XDG_DATA_DIRS/applications).

The following works

$ cat ~/.local/share/applications/bitcoin.desktop
[Desktop Entry]
Type=Application
Name=Bitcoin
Exec=/home/«username»/bitcoin-22.0/bin/bitcoin-qt -min -chain=main
GenericName=Bitcoin core peer
Comment=Bitcoin core peer.
Icon=/home/«username»/bitcoin-22.0/bin/bitcoin-qt
Categories=Office;Finance
Terminal=false
Keywords=bitcoin;crypto;blockchain;qwe;asd;
Hidden=false

cat ~/.config/autostart/bitcoin.desktop
[Desktop Entry]
Type=Application
Name=Bitcoin
Exec=/home/«username»/bitcoin-22.0/bin/bitcoin-qt -min -chain=main
Terminal=false
Hidden=false

Under Mate and KDE Plasma, bitcoin stores its configuration data in ~/.config/Bitcoin/Bitcoin-Qt.conf, rather than in ~/.bitcoin

wxWidgets attempts to store its configuration data in an environment appropriate location under an environment appropriate filename.

It does not, however, seem to have anything to handle or generate desktop files.

desktop files are the Linux desktop standard for a gui program to integrate itself into the linux desktop, used to ensure your program appears in the main application menu, the linux equivalent of the windows startup menu.

Getting your desktop file into the menus is slightly different in KDE to the way it is in Gnome, but there are substantial similarities. FreeDesktop tries to maintain and promote uniformity. Gnome3 rather casually changed the mechanism in a minor release, breaking all previous desktop applications.

2.2 Flatpack

Every Linux desktop is different, and programs written for one desktop have a tendency to die, mess up, or crash the desktop when running on another Linux desktop.

Flatpack is a sandboxing environment designed to make every desktop look to the program like the program’s native desktop (which for wxWidgets is Gnome), and every program look to the desktop like a program written for that particular desktop.

Flatpack simulates Gnome or KDE desktops to the program, and then translates Gnome or KDE behaviour to whatever the actual desktop expects. To do this, it requires some additional KDE configuration for Gnome desktop programs, and some additional Gnome information for KDE desktop programs, and some additional information to cover the other 101 desktops.

WxWidgets tries to make all desktops look alike to the programmer, and Flatpack tries to make all desktops look alike to the program, but they cover different aspects of program and desktop behaviour, so are both needed. Flatpack covers interaction with launcher, the iconization, the install procedure, and stuff, which wxWidgets does not cover.

Linux installs tend to be wildly idiosyncratic, and the installed program winds up never being integrated with the desktop, and never updated.

Flatpack provides package management and automatic updates, all the way from the git repository to the end user’s desktop, which wxWidgets cannot.

This is vital, since we want every wallet to talk the same language as every other wallet.

Flatpack also makes all IPC look alike, so you can have your desktop program talk to a service, and it will be talking gnome iPC on every linux.

Unfortunately Flatpack does all this by running programs inside a virtual machine with a virtual file system, which denies the program access to the real machine, and denies the real machine access to the program’s environment. So the end user cannot easily do stuff like edit the program’s config file, or copy bitcoin’s wallet file or list of blocks.

A program written for the real machine, but actually running in the emulated flatpack environment, is going to not have the same behaviours. The programmer has total control over the environment in which his program runs – which means that the end user does not.

Creative Commons License reaction.la gpg key 154588427F2709CD9D7146B01C99BB982002C39F
This work is licensed under the Creative Commons Attribution 4.0 International License.