1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:07:34 +00:00

LibKeyboard+keymap: Support querying the keymap via commandline

This commit is contained in:
Ben Wiederhake 2021-01-30 22:01:34 +01:00 committed by Andreas Kling
parent a2c21a55e1
commit dd4e670f72
4 changed files with 52 additions and 7 deletions

View file

@ -49,13 +49,26 @@ int main(int argc, char** argv)
const char* path = nullptr;
Core::ArgsParser args_parser;
args_parser.add_positional_argument(path, "The mapping file to be used", "file");
args_parser.add_positional_argument(path, "The mapping file to be used", "file", Core::ArgsParser::Required::No);
args_parser.parse(argc, argv);
dbgln("path is at {:p}, and contains {}", path, path);
if (!path) {
auto keymap = Keyboard::CharacterMap::fetch_system_map();
if (keymap.is_error()) {
warnln("getkeymap: {}", keymap.error());
return 1;
}
outln("{}", keymap.value().character_map_name());
return 0;
}
Keyboard::CharacterMap character_map(path);
int rc = character_map.set_system_map();
if (rc != 0)
fprintf(stderr, "%s\n", strerror(-rc));
perror("setkeymap");
return rc;
}