Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/locale_helpers.py
blob: 2db429fd6b3a3b547efaa861a1894831b4830124 (plain)
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
import os
import subprocess

from .exceptions import *


# from .general import sys_command


def list_keyboard_languages():
	locale_dir = '/usr/share/kbd/keymaps/'

	if not os.path.isdir(locale_dir):
		raise RequirementError(f'Directory containing locales does not exist: {locale_dir}')

	for root, folders, files in os.walk(locale_dir):

		for file in files:
			if os.path.splitext(file)[1] == '.gz':
				yield file.strip('.gz').strip('.map')


def verify_keyboard_layout(layout):
	for language in list_keyboard_languages():
		if layout.lower() == language.lower():
			return True
	return False


def search_keyboard_layout(layout_filter):
	for language in list_keyboard_languages():
		if layout_filter.lower() in language.lower():
			yield language


def set_keyboard_language(locale):
	return subprocess.call(['loadkeys', locale]) == 0