forked from Mirror/pmbootstrap
Add setting for device keymap for devices with keymaps (#379)
* Added rx51_us keymap to nokia n900 * Added keymap option to init * Made install command run setup-keymap when neccesary * Validate keymap on install
This commit is contained in:
parent
c1a1f35239
commit
c536e4ea58
6 changed files with 180 additions and 6 deletions
|
@ -25,6 +25,7 @@ import pmb.helpers.cli
|
|||
import pmb.helpers.devices
|
||||
import pmb.helpers.ui
|
||||
import pmb.chroot.zap
|
||||
import pmb.parse.deviceinfo
|
||||
|
||||
|
||||
def ask_for_work_path(args):
|
||||
|
@ -60,6 +61,24 @@ def ask_for_ui(args):
|
|||
" one from the list above.")
|
||||
|
||||
|
||||
def ask_for_keymaps(args, device):
|
||||
info = pmb.parse.deviceinfo(args, device=device)
|
||||
if "keymaps" not in info or info["keymaps"].strip() == "":
|
||||
return ""
|
||||
options = info["keymaps"].split(' ')
|
||||
logging.info("Available keymaps for device (" + str(len(options)) +
|
||||
"): " + ", ".join(options))
|
||||
if args.keymap is "":
|
||||
args.keymap = options[0]
|
||||
|
||||
while True:
|
||||
ret = pmb.helpers.cli.ask(args, "Keymap", None, args.keymap, True)
|
||||
if ret in options:
|
||||
return ret
|
||||
logging.fatal("ERROR: Invalid keymap specified, please type in"
|
||||
" one from the list above.")
|
||||
|
||||
|
||||
def init(args):
|
||||
cfg = pmb.config.load(args)
|
||||
|
||||
|
@ -74,6 +93,10 @@ def init(args):
|
|||
|
||||
device_exists = os.path.exists(args.aports + "/device/device-" + cfg["pmbootstrap"]["device"] + "/deviceinfo")
|
||||
|
||||
# Device keymap
|
||||
if device_exists:
|
||||
cfg["pmbootstrap"]["keymap"] = ask_for_keymaps(args, device=cfg["pmbootstrap"]["device"])
|
||||
|
||||
# UI and work folder
|
||||
cfg["pmbootstrap"]["ui"] = ask_for_ui(args)
|
||||
cfg["pmbootstrap"]["work"] = ask_for_work_path(args)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue