summaryrefslogtreecommitdiff
path: root/hscript/meta.cc
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/meta.cc
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/meta.cc')
-rw-r--r--hscript/meta.cc36
1 files changed, 35 insertions, 1 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;
}