From 2a74fc423fa7559a24a1fa74f37f743a83c992f8 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Mon, 26 Sep 2016 10:57:23 +0200 Subject: [PATCH] Make writeEtcDefaultKeyboard an option in keyboard.conf. --- src/modules/keyboard/KeyboardPage.cpp | 6 ++++-- src/modules/keyboard/KeyboardPage.h | 3 ++- src/modules/keyboard/KeyboardViewStep.cpp | 14 +++++++++++++- src/modules/keyboard/KeyboardViewStep.h | 1 + src/modules/keyboard/SetKeyboardLayoutJob.cpp | 6 ++++-- src/modules/keyboard/SetKeyboardLayoutJob.h | 4 +++- src/modules/keyboard/keyboard.conf | 6 ++++++ 7 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/modules/keyboard/KeyboardPage.cpp b/src/modules/keyboard/KeyboardPage.cpp index d1b62b4d6..9dafae8b7 100644 --- a/src/modules/keyboard/KeyboardPage.cpp +++ b/src/modules/keyboard/KeyboardPage.cpp @@ -202,7 +202,8 @@ KeyboardPage::prettyStatus() const QList< Calamares::job_ptr > KeyboardPage::createJobs( const QString& xOrgConfFileName, - const QString& convertedKeymapPath ) + const QString& convertedKeymapPath, + bool writeEtcDefaultKeyboard ) { QList< Calamares::job_ptr > list; QString selectedModel = m_models.value( ui->comboBoxModel->currentText(), @@ -212,7 +213,8 @@ KeyboardPage::createJobs( const QString& xOrgConfFileName, m_selectedLayout, m_selectedVariant, xOrgConfFileName, - convertedKeymapPath ); + convertedKeymapPath, + writeEtcDefaultKeyboard ); list.append( Calamares::job_ptr( j ) ); return list; diff --git a/src/modules/keyboard/KeyboardPage.h b/src/modules/keyboard/KeyboardPage.h index a2243e957..c60d62b2b 100644 --- a/src/modules/keyboard/KeyboardPage.h +++ b/src/modules/keyboard/KeyboardPage.h @@ -50,7 +50,8 @@ public: QString prettyStatus() const; QList< Calamares::job_ptr > createJobs( const QString& xOrgConfFileName, - const QString& convertedKeymapPath ); + const QString& convertedKeymapPath, + bool writeEtcDefaultKeyboard ); void onActivate(); void finalize(); diff --git a/src/modules/keyboard/KeyboardViewStep.cpp b/src/modules/keyboard/KeyboardViewStep.cpp index fa6f60c81..e6521e1ab 100644 --- a/src/modules/keyboard/KeyboardViewStep.cpp +++ b/src/modules/keyboard/KeyboardViewStep.cpp @@ -123,7 +123,9 @@ void KeyboardViewStep::onLeave() { m_widget->finalize(); - m_jobs = m_widget->createJobs( m_xOrgConfFileName, m_convertedKeymapPath ); + m_jobs = m_widget->createJobs( m_xOrgConfFileName, + m_convertedKeymapPath, + m_writeEtcDefaultKeyboard ); m_prettyStatus = m_widget->prettyStatus(); } @@ -157,4 +159,14 @@ KeyboardViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { m_convertedKeymapPath = QString(); } + + if ( configurationMap.contains( "writeEtcDefaultKeyboard" ) && + configurationMap.value( "writeEtcDefaultKeyboard" ).type() == QVariant::Bool ) + { + m_writeEtcDefaultKeyboard = configurationMap.value( "writeEtcDefaultKeyboard" ).toBool(); + } + else + { + m_writeEtcDefaultKeyboard = true; + } } diff --git a/src/modules/keyboard/KeyboardViewStep.h b/src/modules/keyboard/KeyboardViewStep.h index 476d71a3c..239639251 100644 --- a/src/modules/keyboard/KeyboardViewStep.h +++ b/src/modules/keyboard/KeyboardViewStep.h @@ -64,6 +64,7 @@ private: QString m_xOrgConfFileName; QString m_convertedKeymapPath; + bool m_writeEtcDefaultKeyboard; QList< Calamares::job_ptr > m_jobs; }; diff --git a/src/modules/keyboard/SetKeyboardLayoutJob.cpp b/src/modules/keyboard/SetKeyboardLayoutJob.cpp index 80024cfa5..430a227eb 100644 --- a/src/modules/keyboard/SetKeyboardLayoutJob.cpp +++ b/src/modules/keyboard/SetKeyboardLayoutJob.cpp @@ -40,13 +40,15 @@ SetKeyboardLayoutJob::SetKeyboardLayoutJob( const QString& model, const QString& layout, const QString& variant, const QString& xOrgConfFileName, - const QString& convertedKeymapPath ) + const QString& convertedKeymapPath, + bool writeEtcDefaultKeyboard) : Calamares::Job() , m_model( model ) , m_layout( layout ) , m_variant( variant ) , m_xOrgConfFileName( xOrgConfFileName ) , m_convertedKeymapPath( convertedKeymapPath ) + , m_writeEtcDefaultKeyboard( writeEtcDefaultKeyboard ) { } @@ -322,7 +324,7 @@ SetKeyboardLayoutJob::exec() return Calamares::JobResult::error( tr( "Failed to write keyboard configuration for X11." ), tr( "Failed to write to %1" ).arg( keyboardConfPath ) ); - if ( !defaultKeyboardPath.isEmpty() ) + if ( !defaultKeyboardPath.isEmpty() && m_writeEtcDefaultKeyboard ) { if ( !writeDefaultKeyboardData( defaultKeyboardPath ) ) return Calamares::JobResult::error( tr( "Failed to write keyboard configuration to existing /etc/default directory." ), diff --git a/src/modules/keyboard/SetKeyboardLayoutJob.h b/src/modules/keyboard/SetKeyboardLayoutJob.h index fb5628139..8cafdeb29 100644 --- a/src/modules/keyboard/SetKeyboardLayoutJob.h +++ b/src/modules/keyboard/SetKeyboardLayoutJob.h @@ -31,7 +31,8 @@ public: const QString& layout, const QString& variant, const QString& xOrgConfFileName, - const QString& convertedKeymapPath ); + const QString& convertedKeymapPath, + bool writeEtcDefaultKeyboard ); QString prettyName() const override; Calamares::JobResult exec() override; @@ -49,6 +50,7 @@ private: QString m_variant; QString m_xOrgConfFileName; QString m_convertedKeymapPath; + const bool m_writeEtcDefaultKeyboard; }; #endif /* SETKEYBOARDLAYOUTJOB_H */ diff --git a/src/modules/keyboard/keyboard.conf b/src/modules/keyboard/keyboard.conf index a2606b94e..9f8f27524 100644 --- a/src/modules/keyboard/keyboard.conf +++ b/src/modules/keyboard/keyboard.conf @@ -3,6 +3,12 @@ # The default value is the name used by upstream systemd-localed. # Relative paths are assumed to be relative to /etc/X11/xorg.conf.d xOrgConfFileName: "/etc/X11/xorg.conf.d/00-keyboard.conf" + # The path to search for keymaps converted from X11 to kbd format # Leave this empty if the setting does not make sense on your distribution. convertedKeymapPath: "/lib/kbd/keymaps/xkb" + +# Write keymap configuration to /etc/default/keyboard, usually +# found on Debian-related systems. +# Defaults to true if nothing is set. +#writeEtcDefaultKeyboard: true