mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:37:46 +00:00
Userland: Preserve keyboard mapping preference on reboot (#6955)
This commit is contained in:
parent
4c43fc0515
commit
d922c2f5f3
6 changed files with 68 additions and 1 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibKeyboard/CharacterMap.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -12,7 +13,7 @@
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (pledge("stdio setkeymap getkeymap rpath", nullptr) < 0) {
|
||||
if (pledge("stdio setkeymap getkeymap rpath wpath cpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
@ -22,6 +23,11 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (unveil("/etc/Keyboard.ini", "rwc") < 0) {
|
||||
perror("unveil /etc/Keyboard.ini");
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* path = nullptr;
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_positional_argument(path, "The mapping file to be used", "file", Core::ArgsParser::Required::No);
|
||||
|
@ -60,7 +66,12 @@ int main(int argc, char** argv)
|
|||
int rc = character_map.value().set_system_map();
|
||||
if (rc != 0) {
|
||||
perror("setkeymap");
|
||||
return rc;
|
||||
}
|
||||
|
||||
auto mapper_config(Core::ConfigFile::open("/etc/Keyboard.ini"));
|
||||
mapper_config->write_entry("Mapping", "Keymap", path);
|
||||
mapper_config->sync();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue