-
Notifications
You must be signed in to change notification settings - Fork 1
/
set-custom-locale
executable file
·51 lines (39 loc) · 1004 Bytes
/
set-custom-locale
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
# -*- sh -*-
# vim: syntax=sh
# code: language=shellscript
# Copyright (c) 2024 Michael Federczuk
# SPDX-License-Identifier: MPL-2.0 AND Apache-2.0
#region preamble
case "$-" in
(*'i'*)
\command printf 'script was called interactively\n' >&2
return 124
;;
esac
set -o errexit
set -o nounset
# enabling POSIX-compliant behavior for GNU programs
export POSIXLY_CORRECT=yes POSIX_ME_HARDER=yes
if [ "${0#/}" = "$0" ]; then
argv0="$0"
else
argv0="$(basename -- "$0" && printf x)"
argv0="${argv0%"$(printf '\nx')"}"
fi
readonly argv0
#endregion
if [ $# -gt 0 ]; then
printf '%s: too many arguments: %i\n' "$argv0" $# >&2
exit 4
fi
if ! command -v localectl > '/dev/null'; then
printf '%s: localectl: program missing\n' "$argv0" >&2
exit 27
fi
custom_locale_name='en_AT.UTF-8@custom'
readonly custom_locale_name
localectl set-locale "$custom_locale_name"
if command -v gsettings > '/dev/null'; then
gsettings set 'org.gnome.system.locale' 'region' "$custom_locale_name"
fi