Removed layout filtering

This caused languages such as `be-latin1` to be hidden both in Search and direct input.
Because as an example that layout belongs to `azerty` and not `qwerty`.
This commit is contained in:
Anton Hvornum 2021-04-14 13:16:18 +02:00 committed by GitHub
parent 7f29f9d283
commit 12b43f443b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 9 deletions

View File

@ -4,27 +4,22 @@ import os
from .exceptions import *
# from .general import sys_command
def list_keyboard_languages(layout='qwerty'):
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):
# Since qwerty is under /i386/ but other layouts are
# in different spots, we'll need to filter the last foldername
# of the path to verify against the desired layout.
if os.path.basename(root) != layout:
continue
for file in files:
if os.path.splitext(file)[1] == '.gz':
yield file.strip('.gz').strip('.map')
def search_keyboard_layout(filter, layout='qwerty'):
for language in list_keyboard_languages(layout):
def search_keyboard_layout(filter):
for language in list_keyboard_languages():
if filter.lower() in language.lower():
yield language
def set_keyboard_language(locale):
return subprocess.call(['loadkeys',locale]) == 0
return subprocess.call(['loadkeys', locale]) == 0