Skip to content

PAPERSIZE is hardcoded to a4 and overrides the paper size of the chosen region #104

Description

@Fantu

mintlocale writes PAPERSIZE=a4 into ~/.pam_environment and ~/.xsessionrc (the two templates/*_pam_environment.template files, plus mintlocale.py:777 and mintlocale.py:823 when the variable is not there yet). The value is hardcoded and never follows the region, which the same files set through LC_PAPER=$region.

Since PAPERSIZE in the environment takes precedence over everything else libpaper looks at, that hardcoded a4 wins over the paper size the region implies. Someone in the US or Canada who picks their own region in mintlocale ends up with LC_PAPER saying Letter and PAPERSIZE saying A4, and A4 is what programs get.

What I checked

LC_PAPER does carry the right size, per glibc (Debian unstable chroot):

$ LC_PAPER=en_US.UTF-8 locale -k LC_PAPER
height=279 width=216 paper-codeset="UTF-8"        # Letter
$ LC_PAPER=it_IT.UTF-8 locale -k LC_PAPER
height=297 width=210 paper-codeset="UTF-8"        # A4

Debian unstable and trixie (libpaper 2.2.5). paper(1) documents the order as PAPERSIZE$XDG_CONFIG_HOME/papersize → the current locale's paper size → /etc/papersize, so the locale is consulted, but only if PAPERSIZE is unset:

$ LC_PAPER=en_US.UTF-8 paper
Letter: 8.5x11 in
$ LC_PAPER=en_US.UTF-8 PAPERSIZE=a4 paper
A4: 210x297 mm

Ubuntu 26.04 LTS, so the base of Mint 23, carries libpaper 2.2.5 as well (2.2.5-0.3maysync1, whose only difference from Debian's 2.2.5-0.3 is a build fix), so it behaves the same way. libpaper 1 stops at Ubuntu 24.04.

Linux Mint 22.x and Ubuntu 24.04 (libpaper 1.1.29). This version ignores the locale altogether, but PAPERSIZE still overrides the system default in /etc/papersize:

$ cat /etc/papersize
letter
$ paperconf
letter
$ PAPERSIZE=a4 paperconf
a4

So on Debian and on Mint 23 the hardcoded value overrides the region, and on Mint 22.x it overrides whatever the system was configured with.

Possible fixes

Dropping PAPERSIZE from both files looks like the right thing wherever libpaper 2 is in use, which now means Debian and Mint 23 alike: LC_PAPER is already set from the region and libpaper picks it up on its own. On Mint 22.x it would mean falling back to /etc/papersize, which is a change in behaviour, so it is your call whether that is acceptable there.

Otherwise the value can be derived instead of hardcoded: read LC_PAPER for the chosen region and write letter when its height is 279 mm, a4 otherwise.

Either way I am happy to send a PR once you have said which of the two you prefer.


EDIT:

Prior report

#79 is the same defect seen from the user side, on Mint 21.1: LC_PAPER=en_CA.UTF-8 together with PAPERSIZE=a4 while /etc/papersize said letter, and "every piece of software I am running defaults to A4 paper size before I set it right". It got no answer and the stale bot closed it in April 2026.

Ubuntu already derives it

The second option above is what Ubuntu settled on for the same problem in 2013, in LP #1130690 ("Default papersize should be in sync with regional formats"). Their accountsservice ships /usr/share/language-tools/locale2papersize, which is the whole of the logic:

export LC_PAPER=$1
height=$( locale height )
width=$( locale width )
if [ "$height" = 279 -a "$width" = 216 ]; then
    size=letter
else
    size=a4
fi

save-to-pam-env writes PAPERSIZE from its output, and language-selector updates /etc/papersize when the formats are applied system wide. On Mint 22.3 the helper is present (accountsservice 23.13.9-2ubuntu6.1) and answers letter for en_CA and en_US, a4 for en_GB and it_IT.

It is an Ubuntu delta, though: Debian's accountsservice (23.13.9-8+b2 in unstable) does not ship it, so mintlocale cannot call it and would have to carry those few lines itself. locale -k LC_PAPER gives the same two numbers on either distribution.

That precedent also suggests a system-wide counterpart, if you want the parity: Apply System-Wide could write /etc/papersize too, which is the file libpaper 1 reads on Mint 22.x and libpaper 2 falls back to.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions