Skip to content

Parsing XRandR output failed with comma-decimal locales (de_DE, fr_FR, ...) #424

Description

@singularix-maker

Summary

autorandr fails to parse xrandr --verbose output when the user's locale uses a comma as decimal separator (e.g. de_DE.UTF-8, fr_FR.UTF-8, sv_SE.UTF-8). The mode-rate regex only accepts [0-9\.]+, but xrandr prints e.g. 90,00Hz under such locales.

Reproduction

LC_NUMERIC=de_DE.UTF-8 xrandr --verbose | grep -m1 'Hz +preferred'
#   2880x1800 (0x4c) 500,840MHz +HSync -VSync +preferred
#                                 ^ comma, not dot

LC_NUMERIC=de_DE.UTF-8 autorandr --detected
# Parsing XRandR output failed, 12585 bytes left unmatched after regular
# expression, starting at byte 1658 with ..'2880x1800 '. (line 415)

Why systemd Environment=LC_ALL=C doesn't help

dispatch_call_to_sessions runs fork_child_autorandr which calls os.environ.clear() (autorandr.py:1283) and replaces the environment with the target user's session env. The systemd-service LC_ALL=C is wiped before xrandr is invoked.

Affected versions

Reproduced on Ubuntu 24.04 LTS, autorandr 1.14-2. Upstream master / 1.15 have the same regex ([0-9\.]+), so the bug exists there too.

Proposed fix

Accept both . and , in the rate regex, and normalize to . when storing the value so downstream xrandr --rate calls always see a dot. PR follows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions