Localization in FreeBSD

While testing XFCE, I noticed, that the date and time format in some desktop applications, such as Thunderbird, no longer was ISO 8601. It had become more like US or metric. I want English with Danish format and UTF-8 encoding.

Configuring language in FreeBSD login class.

According to the FreeBSD handbook, the recommended method for configuring language, format and encoding is in the login class definition. This is, however, not correct. I have not been able to test this to work. I recommend, that the language format in the login class is set to the following POSIX standard and the rest is configured in FreeBSD enviroment variables.

# nano /etc/login.conf
:charset=UTF-8:\
:lang=C.UTF-8:\
:setenv=PATH_LOCALE=/usr/local/share/locale:
# cap_mkdb /etc/login.conf

Configuring language in FreeBSD environment variables.

Configure environment variables. In this example, I will be using the Bourne shells.

# nano /etc/profile
LANG=en_DK.UTF-8

I have tested this to work for system shell as well as XFCE desktop environment and Thunderbird.

Issue: Configuring language in login class not working.

According to the FreeBSD handbook, the recommended method for configuring language, format and encoding is in the login class definition. This requires, that the correct language definition is available. This is known as a locale and is formulated in the following format.

en_DK.UTF-8

The current list of available locales can be listed.

# locale -a | grep en_DK.UTF-8

In this example, mine was not available, but was available as a package to be installed or a port to be built.

# pkg install locale-en_DK
Message from locale-en_DK-0.1.1:
In order to set the en_DK.UTF-8 locale for the login shell of an single
user add the following configuration to ~/.login_conf:
me:\
:charset=UTF-8:\
:lang=en_DK.UTF-8:\
:setenv=PATH_LOCALE=/usr/local/share/locale:
More information about the process of configuring login class methods in
available in the handbook.
More information about the PATH_LOCALE environment variable is available in the
locale(1) manual page.

The default login class can now be configured. However, this did not work. The special Danish characters did not work.

References.

How to disable XFCE power manager on FreeBSD

Blank screen and muted audio in XFCE.

The first issue, I noticed, when switching from GNOME to XFCE, was, how the HDMI output was cut-off after a few minutes in which there has been no user input, such as attending a video conference. Pressing a key would turn-on the screen, but the audio would never return again. The audio could not even be re-enabled with Pulse Audio controls.

Disabling power management from XFCE interface.

Using the settings dialog, I disabled any kind of power management. This includes any screen blank and suspend option. Despite of this, the video and audio is getting cut-off. I could not find any kind of screensaver, that should be causing this.

# ps aux | grep power
/usr/local/libexec/upowerd
xfce4-power-manager
# ps aux | grep saver
# ps aux | grep screen

Removing power manager from XFCE?

I assume, that this is related to power management, because a screen saver would probably not be so aggressive. Knowing, that I will not need power management, a simple approuch would be to remove it from the installation. However, XFCE went for a forced depedency on this one. What a piece of shit programming from XFCE. Power management should be optional – and not a plague!

Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 2 packages (of 0 packages in the universe):
Installed packages to be REMOVED:
xfce: 4.20
xfce4-power-manager: 4.20.0
Number of packages to be removed: 2
The operation will free 2 MiB.
Proceed with deinstalling packages? [y/N]: N

How does power managment in XFCE work?

A search for occurances indicates, that it could be started automatically as an unwanted service. It could even be started, if it was running in an earlier user session.

# find / -type f -name '*xfce4-power*'
/home/lightman/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-power-manager.xml
/usr/local/share/metainfo/xfce4-power-manager.appdata.xml
/usr/local/share/man/man1/xfce4-power-manager-settings.1.gz
/usr/local/share/man/man1/xfce4-power-manager.1.gz
/usr/local/share/applications/xfce4-power-manager-settings.desktop
/usr/local/etc/xdg/autostart/xfce4-power-manager.desktop
/usr/local/bin/xfce4-power-manager-settings
/usr/local/bin/xfce4-power-manager

Stopping power manager in XFCE.

To my surprice, XFCE did actually write a built-in help, which kindly lists a quit option. It also seemed to actually quit the unwanted service. However, this is probably just a shortlived pleasure. It might restart. Especially after a new session or a reboot.

$ xfce4-power-manager --help
Usage:
xfce4-power-manager [OPTION?]
Help Options:
-h, --help Show help options
--help-all Show all help options
--help-sm-client Show session management options
Application Options:
--daemon Daemonize
--debug Enable debugging
--dump Dump all information
--restart Restart the running instance of Xfce power manager
-c, --customize Show the configuration dialog
-q, --quit Quit any running xfce power manager
-V, --version Version information
$ xfce4-power-manager -q

Killing the XFCE power manager from cron as a work-around.

As it remains unclear, how the unwanted service is started, a work-around is to repeat killing it from cron, until I learn, how this service can be permanently disabled. This cron job kills it every minute, if running. I have tested this be working.

# pkg info -r xfce4-power-manager
xfce4-power-manager-4.20.0:
xfce-4.20
# pkg info -r upower
upower-1.90.7:
xfce4-settings-4.20.1
xfce4-power-manager-4.20.0
gnome-power-manager-3.32.0_3
gnome-control-center-43.2_4
mutter-42.4_3
gnome-settings-daemon-42.2_8
# nano /etc/crontab
* * * * * root pkill xfce4-power-manager
* * * * * root pkill upowerd
# service cron restart

Tips appreciated!

I appreciate any tips about this issue.

Managing PulseAudio on FreeBSD

Configuring PulseAudio on FreeBSD.

In this example, the PulseAudio is configured to output to HDMI by default. If USB headphones are attached, then audio output is automatically switched to these. I tested this to be working.

$ pactl list sinks
Sink #3
State: RUNNING
Name: oss_output.dsp3
Description: 3 - Intel (0x2818) (HDMI/DP 8ch)
Mute: no
# nano /usr/local/etc/pulse/default.pa
set-default-sink oss_output.dsp3
load-module module-switch-on-connect

Switching audio output with pactl on FreeBSD.

pactl is a control interface for a running PulseAudio sound server. In this example, the audio output is switched to a pair of USB headphones. The listings indicate, that the headphones are associated with sink 4 and name oss_output.dsp5. The output is switched to to this and it is un-muted. Warning: The volume is optionally set to 100%. The volume setting is the same as the one, that is set on the headphones themselves.

$ pactl list sinks
Sink #4
State: RUNNING
Name: oss_output.dsp5
Description: 5 - Corsair CORSAIR HS80 RGB Wireless Gaming Receiver
muted: yes
Sample Specification: s16le 2ch 44100Hz
$ pactl list sinks short
4 oss_output.dsp5 module-oss.c s16le 2ch 44100Hz RUNNING
$ pactl set-default-sink oss_output.dsp5
$ pactl set-sink-mute oss_output.dsp5 0
$ pactl set-sink-volume oss_output.dsp5 100%

References.

Poudriere build failure: net-im/signal-desktop

I noticed, that my Poudriere build machine failed to compile net-im/signal-desktop for FreeBSD 14 with latest ports branch, because it require devel/esbuild 0.25.0, while build environment has 0.24.0. Tested 2025-03-07 and 2025-03-10.

✘ [ERROR] Cannot start service: Host version "0.24.0" does not match binary version "0.25.0"
1 error
Error: The service was stopped: write EPIPE
at /wrkdirs/usr/ports/net-im/signal-desktop/work/Signal-Desktop-7.44.0/node_modules/esbuild/lib/main.js:968:34
at responseCallbacks.<computed> (/wrkdirs/usr/ports/net-im/signal-desktop/work/Signal-Desktop-7.44.0/node_modules/esbuild/lib/main.js:622:9)
at afterClose (/wrkdirs/usr/ports/net-im/signal-desktop/work/Signal-Desktop-7.44.0/node_modules/esbuild/lib/main.js:613:28)
at /wrkdirs/usr/ports/net-im/signal-desktop/work/Signal-Desktop-7.44.0/node_modules/esbuild/lib/main.js:1988:18
at onwriteError (node:internal/streams/writable:605:3)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)
ERROR: "build:esbuild" exited with 1.
*** Error code 1
Stop.
make: stopped in /usr/ports/net-im/signal-desktop
=>> Cleaning up wrkdir
===> Cleaning for signal-desktop-7.44.0_1
build of net-im/signal-desktop | signal-desktop-7.44.0_1 ended at Mon Mar 10 05:13:34 CET 2025
build time: 00:00:47
!!! build failure encountered !!!

I notified the FreeBSD maintainer. He kindly replied, that he has notified devel/esbuild and the issue will be fixed.

Earlier this year, I noticed, that a similar issue happened. The required version was 0.21, while build environment had 0.24. I notified the maintainer. It was fixed.

Prevent Signal from being removed during update.

As a consequence of the failed build, I locked Signal. This prevents it from being deinstalled, while it fails to build.

# pkg lock signal-desktop
signal-desktop-7.42.0: lock this package? [y/N]:

It can later be unlocked.

# pkg unlock signal-desktop

Work-around for “Shared object “libFLAC.so.12″ not found”.

The update, while Signal being locked, resulted in a problem with a link to a FLAC library.

$ signal-desktop &
$ ld-elf.so.1: Shared object "libFLAC.so.12" not found, required by "signal-desktop"

I fixed this with a temporary link to the correct FLAC library. This should automatically be fixed, when Signal is fixed upstream.

# pkg info -l flac | grep libFLAC
/usr/local/lib/libFLAC++.a
/usr/local/lib/libFLAC++.so
/usr/local/lib/libFLAC++.so.11
/usr/local/lib/libFLAC++.so.11.0.0
/usr/local/lib/libFLAC.a
/usr/local/lib/libFLAC.so
/usr/local/lib/libFLAC.so.14
/usr/local/lib/libFLAC.so.14.0.0
/usr/local/share/aclocal/libFLAC++.m4
/usr/local/share/aclocal/libFLAC.m4
# pkg which /usr/local/lib/libFLAC.so.12
/usr/local/lib/libFLAC.so.12 was not found in the database
# ln -s /usr/local/lib/libFLAC.so.14 /usr/local/lib/libFLAC.so.12
# ldconfig -R
$ signal-desktop &

It can later be removed.

# rm /usr/local/lib/libFLAC.so.12
# ldconfig -R

Fixed.

The port compiled again 2025-03-21 and the package could be unlocked and the symbolic link removed.

References.

Poudriere build failure: graphics/cmake

My Poudriere build machine suddently stopped at the following error, that seems to be caused by a problem with CMake or run-time dependency, which should be built automatically.

build started at Fri Mar  7 16:46:57 CET 2025
port directory: /usr/ports/graphics/evince
package name: evince-46.3.1
...
Poudriere version: poudriere-git-3.4.2
Host OSVERSION: 1402000
Jail OSVERSION: 1402000
...
Did not find CMake 'cmake'
Found CMake: NO
Run-time dependency gnome-desktop-3.0 found: NO (tried pkgconfig)
meson.build:237:20: ERROR: Dependency "gnome-desktop-3.0" not found, tried pkgconfig

Any tips for solutions are greatly appreciated.

References.

Tracker3 Core Dumps on FreeBSD with GNOME

Tracker3 core dumps on FreeBSD with GNOME.

If you have a FreeBSD desktop computer with the GNOME desktop environment, or similar open source desktop computer, you might have noticed random Tracker3 core dumps on the file system.

$ find . -name '*.core'
./bin/tracker3.core
./projects/tracker3.core

You might also have noticed messages about Tracker3 error, exit and core dumps in system logs.

$ dmesg
pid 2416 (tracker3), jid 0, uid 1001: exited on signal 10 (no core dump - other error)
pid 2451 (tracker3), jid 0, uid 1001: exited on signal 10 (no core dump - other error)
pid 2848 (tracker3), jid 0, uid 1001: exited on signal 10 (core dumped)

What is Tracker3?

A first approach to learning, what Tracker3 is, would be to open its manual page. Unfortunately, as often seen with utilities like this, they do not include a manual by default.

$ man tracker3
No manual entry for "tracker3"

A search for “tracker3 official website” on search engines does not give a clean answer. The utility seems to not have a website nor a coding home listed on search engines. Again, a sign of poor coding and project management skills.

Thanks to Freshports, more about the utility can be learned. Here, it is described as a system utility, that index and harvest meta data for GNOME utilities, such as the file management utility Nautilus. A rather useless feature, in my oppinion. Its undocumented operation is a privacy concern. It might even scan files across datasets and partitions, which could be privacy concern.

Tracker is a powerful desktop-neutral first class object database, tag/metadata
database, search tool and indexer.

Tracker is also extremely fast and super efficient with your systems memory when
compared with some other competing frameworks and is by far the fastest and most
memory efficient Nautilus search and Deskbar backends currently availble.

It consists of a common object database that allows entities to have an almost
infinte number of properties, metadata (both embedded/harvested as well as user
definable), a comprehensive database of keywords/tags and links to other
entities.

Freshports does have a reference to a page, which seems to be about Tracker3 by GNOME, but aligned with their poor views on privacy and security, the site either does not work or blocks privacy VPNs.

<Code>AccessDenied</Code>

It does not come with a manual by default. However, according to FreeBSD Manual Pages, there are no known manual for it. I even tried compiling it with option for installing its manual pages. It was not installed.

===> The following configuration options are available for tracker3-3.5.3_3:
DOCS=on: Build and/or install documentation
MAN=off: Install manual pages

It is a dependency of Nautilus, which does not have an option for disabling this.

Removing Tracker3 from GNOME and FreeBSD.

If a system utility, that index and harvest the file system for filenames and metadata in the background, is not needed or unwanted, it might be a logic approach, that Tracker3 is removed with the package manager. However, as seen in the output, it does not seem, that GNOME wanted that to be an option.

# pkg remove tracker3
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 7 packages (of 0 packages in the universe):
Installed packages to be REMOVED:
evince: 43.1_11
gnome-lite: 42_5
gnome-terminal: 3.44.2_3
gnome-tweaks: 40.10_4
nautilus: 42.2_3
sushi: 42.0_5
tracker3: 3.5.3_3
Number of packages to be removed: 7
The operation will free 38 MiB.
Proceed with deinstalling packages? [y/N]:

Tracker3 in GNOME is a privacy concern.

Tracker3 is deeply embedded in GNOME. Tracker3 comes enabled without consent from the user. It is a forced installation, that comes with no clear information, warning nor documentation. It is difficult or impossible to disable or deinstall. It scans file systems, datasets and partitions. It stores metadata from files, that has been downloaded temporary. It stores metadata for files, that has been deleted. It stores metadata in internal database and hidden files. It does not have an interface to manage data. This is not a utility, that fits well with the UNIX philosophy. Tracker3 is a privacy concern.

Disabling Search and Tracker3 in GNOME.

Tracker3 can to some degree be disabled from within GNOME by going to the Settings menu and Search and then disabling Application Search. This also seems to reduce the amount of core dumps. However, I have been able to find any documentation about this.

Switching from GNOME to XFCE.

Switching desktop environment from GNOME to XFCE, or similar more simple, resource friendly and privacy focused desktop environment, could be a better over-all solution. The switch to XFCE should be fairly straight forward, because it is also based on X. Unfortunately, there is no guarantee, that XFCE will not implement the same or similar kind of file system metadata scanner at some point. A reason is, that some users and project contributors believe, that a desktop search feature is more important than privacy and security.

References.

Converting Line Breaks To Paragraph

Some text files has line breaks, that might look good on fixed width screens, but can not be used as paragraph in other editing software. The is cause by line breaks.

$ cat input.txt 
The computer was a powerful WOPR machine for game simulation.
You can play a nice game of chess or an exciting war game.

This one-liner will replace line breaks with space and then remove any double spaces. It will also make sure, that the file ends with a new line, so it meets the POSIX standard definition of a text file.

$ (tr '\n' ' ' < input.txt | sed 's/  */ /g'; echo) > output.txt

The result is one clean paragraph, that will scale to any screen width or be used in other editing software.

$ cat output.txt 
The computer was a powerful WOPR machine for game simulation. You can play a nice game of chess or an exciting war game.

Reducing or disabling swap on FreeBSD

Is it possible to reduce or disable swap memory on FreeBSD? In this example, 32 GB swap is enabled by using 16 GB on each of 2 SSDs. I would prefer this to be closer to 8 GB by using 4 GB on each of 2 SSDs.

Information about current swap devices.

Get information about currently active swap devices and sizes.

# swapinfo -h
Device Size Used Avail Capacity
/dev/nda0p3 16G 0B 16G 0%
/dev/nda1p3 16G 0B 16G 0%
Total 32G 0B 32G 0%

Get information about partitions on disks and GEOM providers. Each device and partition has a unique identifier, that can be used to make changes.

# gpart show
=> 40 4000797280 nda0 GPT (1.9T)
40 532480 1 efi (260M)
532520 1024 2 freebsd-boot (512K)
533544 984 - free - (492K)
534528 33554432 3 freebsd-swap (16G)
34088960 3966707712 4 freebsd-zfs (1.8T)
4000796672 648 - free - (324K)
=> 40 3907029088 nda1 GPT (1.8T)
40 532480 1 efi (260M)
532520 1024 2 freebsd-boot (512K)
533544 984 - free - (492K)
534528 33554432 3 freebsd-swap (16G)
34088960 3872940032 4 freebsd-zfs (1.8T)
3907028992 136 - free - (68K)

The devices can be listed. This also shows the naming convention for the partitions.

# gpart status
nda0p1 OK nda0
nda0p2 OK nda0
nda0p3 OK nda0
nda0p4 OK nda0
nda1p1 OK nda1
nda1p2 OK nda1
nda1p3 OK nda1
nda1p4 OK nda1

Disabling swap on FreeBSD.

Move swapped pages out from swap devices and disable them.

# swapoff -a
swapoff: removing /dev/nda0p3 as swap device
swapoff: removing /dev/nda1p3 as swap device

If you want to re-enable swap, it is as easy as reverting that.

# swapon -a
swapon: adding /dev/nda0p3 as swap device
swapon: adding /dev/nda1p3 as swap device

Reducing swap partitions?

Is it possible to reduce the swap partition on each SSD and then have ZFS use the free space? Is it possible to split the partitions?

Deleting swap partitions?

Delete or comment out the swap partitions from the static information about file systems. This ensures, that they do not get re-mounted during boot.

# nano /etc/fstab
# Device Mountpoint FStype Options Dump Pass#
/dev/gpt/efiboot0 /boot/efi msdosfs rw 2 2
#/dev/nda0p3 none swap sw 0 0
#/dev/nda1p3 none swap sw 0 0
proc /proc procfs rw 0 0

Is it possible to delete the swap partition on each SSD and then have ZFS use the free space? The handbook does mention growing partitions, but it is not clear, if ZFS can in fact grow directly or it will be necessary to re-create partitions, format, import and encrypt.

Links

Configuring Bourne shell on FreeBSD

What is a Bourne shell?

The Bourne shell, also often referred to as /bin/sh or just sh, has been a default shell for users on FreeBSD for many major versions, while C shell was the default shell for root. From FreeBSD 14, the default shell for root is the Bourne shell.

Changing to Bourne shell on FreeBSD.

The shell for a user in FreeBSD can be changed with the chsh utility.

Configuring the Bourne shell in FreeBSD.

The Bourne shell in FreeBSD is configured by editing the global configuration file /etc/profile and/or the local user configuration file .shrc. These files contains commands, that will be executed, when the shell is started, such as when the user logs into the system.

In this example, the global configuration sets the blocksize for default file operations, ccache settings, the default editor, he default pager and a prompt. The prompt shows a “$” for a normal user and a “#” for root.

# nano /etc/profile
BLOCKSIZE=K
CCACHE=1
CCACHE_DIR=/var/cache/ccache
EDITOR=/usr/local/bin/nano
PAGER=less
VISUAL=$EDITOR
if [ "$(id -u)" -eq 0 ]; then
  PS1='# '
else
  PS1='$ '
fi
export BLOCKSIZE CCACHE CCACHE_DIR EDITOR PAGER PS1 VISUAL

If the user would like to add or change custom settings, then this can be set in the local user configuration file. If this is not relavant, the file should be deleted, because it does contain settings, that could interfere with the global settings.

$ rm .shrc
# rm .shrc

Testing.

The Bourne shell can now be tested. In this example, a user log in and switch to root.

$ whoami
jennifer
$ su -
Password: Pencil
# whoami
root
# echo $EDITOR
/usr/local/bin/nano

The different kinds of shells.

There are different kinds of shells, such as login shells and sub-shells. The sub-shells are also known as non-login shells. The difference is, that a login shell reads global configuration files, while sub-shells just inherits the settings from the original shell. In this example, the first shell will be a login-shell, while the second will be a sub-shell.

FreeBSD/amd64 (wopr) (ttyv0)

Login: stephen
Password: Pencil
__ __________ ____________________
/ \ / \_____ \\______ \______ \
\ \/\/ // | \| ___/| _/
\ // | \ | | | \
\__/\ / \_______ /____| |____|_ /
\/ \/ \/
Greetings, professor Falken. How about a nice game of chess?
$ sh
$ su stephen
$ logout
$ logout

More about shells.

DOAS for FreeBSD

What is DOAS?

doas is a utility, that can permit users to execute commands as root or as another user. Groups as well as users can be permitted to do.

Installing DOAS on FreeBSD.

# pkg install doas

The manual for doas is nice and simple.

# man doas.conf

Configuring DOAS.

In this example, I will configure doas to permit members of the wheel group to use the FreeBSD service command script, that can start and stop services, such as an nginx web server, without a password. This is a safe and trivial command to disable password requirement for.

# nano /usr/local/etc/doas.conf
permit nopass :wheel as root cmd service

If I wanted to limit, which arguments, that can be passed to the command, I could specifiy this with the args feature.

# nano /usr/local/etc/doas.conf
permit nopass :wheel as root cmd service args nginx onestart

Testing.

$ doas service nginx onestart
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Starting nginx

Be aware, that doas requires, that the command is matched exactly. The following definition will not work.

# nano /usr/local/etc/doas.conf
permit nopass :wheel as root cmd /usr/sbin/service args nginx onestart
$ doas service nginx onestart
doas: Operation not permitted