x11/lightdm: Fix ttyv numbering logic
Adapt code from wlroots to correctly generate ttyv device names for
numbers beyond 9.
Upstream pull request: https://github.com/canonical/lightdm/pull/343
PR: 277114
Obtained from: https://github.com/swaywm/wlroots/commit/fc6c0ca12e941d5d7d567834bff3ab7df9447001 (inspired by)
MFH: 2024Q1
(cherry picked from commit c88dffc0c8b6f2c82a522d8eb2dcd2b49e9a4015)