summaryrefslogtreecommitdiff
path: root/hscript
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-11-04 18:15:50 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-11-04 18:15:50 -0600
commit8fd273ac2810c4ffed616877b191dba86355ca6c (patch)
tree930df514b7ad9d059a9fdf5f60c77c8d4575ce41 /hscript
parent7c5c18d46757416f44a0baedbe880f6634213625 (diff)
downloadhorizon-8fd273ac2810c4ffed616877b191dba86355ca6c.tar.gz
horizon-8fd273ac2810c4ffed616877b191dba86355ca6c.tar.bz2
horizon-8fd273ac2810c4ffed616877b191dba86355ca6c.tar.xz
horizon-8fd273ac2810c4ffed616877b191dba86355ca6c.zip
hscript: Implement Keymap::execute
Diffstat (limited to 'hscript')
-rw-r--r--hscript/meta.cc36
-rw-r--r--hscript/script_e.cc5
2 files changed, 39 insertions, 2 deletions
diff --git a/hscript/meta.cc b/hscript/meta.cc
index 4cb25bb..b5c2beb 100644
--- a/hscript/meta.cc
+++ b/hscript/meta.cc
@@ -339,7 +339,41 @@ bool Keymap::validate(ScriptOptions) const {
return true;
}
-bool Keymap::execute(ScriptOptions) const {
+bool Keymap::execute(ScriptOptions opts) const {
+ const std::string conf("# KEYBOARD CONFIGURATION FILE\n\
+\n\
+# Consult the keyboard(5) manual page.\n\
+\n\
+XKBMODEL=pc105\n\
+XKBLAYOUT=" + _value + "\n\
+XKBVARIANT=\n\
+XKBOPTIONS=\n\
+\n\
+BACKSPACE=guess"
+ );
+
+ output_info("installfile:" + std::to_string(line),
+ "keymap: setting system keyboard map to " + _value);
+
+ if(opts.test(Simulate)) {
+ std::cout << "cat >/target/etc/default/keyboard <<-KEYCONF"
+ << std::endl;
+ std::cout << conf << std::endl;
+ std::cout << "KEYCONF" << std::endl;
+ return true;
+ }
+
+#ifdef HAS_INSTALL_ENV
+ std::ofstream keyconf("/target/etc/default/keyboard",
+ std::ios_base::trunc);
+ if(!keyconf) {
+ output_error("installfile:" + std::to_string(line),
+ "keymap: cannot write target keyboard configuration");
+ return false;
+ }
+
+ keyconf << conf;
+#endif /* HAS_INSTALL_ENV */
return true;
}
diff --git a/hscript/script_e.cc b/hscript/script_e.cc
index ef43bba..e03b4ad 100644
--- a/hscript/script_e.cc
+++ b/hscript/script_e.cc
@@ -455,7 +455,10 @@ bool Script::execute() const {
return false;
}
- /* keymap */
+ if(internal->keymap && !internal->keymap->execute(opts)) {
+ EXECUTE_FAILURE("keymap");
+ return false;
+ }
/* UserAccounts */
if(!internal->tzone->execute(opts)) {