Add support for writing keymap data to /etc/default/keyboard.
This commit is contained in:
parent
8632c3d609
commit
ec2094d768
@ -1,6 +1,6 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2014, Kevin Kofler <kevin.kofler@chello.at>
|
||||
*
|
||||
* Portions from systemd (localed.c):
|
||||
@ -240,6 +240,34 @@ SetKeyboardLayoutJob::writeX11Data( const QString& keyboardConfPath ) const
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SetKeyboardLayoutJob::writeDefaultKeyboardData( const QString& defaultKeyboardPath ) const
|
||||
{
|
||||
QFile file( defaultKeyboardPath );
|
||||
file.open( QIODevice::WriteOnly | QIODevice::Text );
|
||||
QTextStream stream( &file );
|
||||
|
||||
stream << "# KEYBOARD CONFIGURATION FILE\n\n"
|
||||
"# Consult the keyboard(5) manual page.\n\n";
|
||||
|
||||
stream << "XKBMODEL=\"" << m_model << "\"\n";
|
||||
stream << "XKBLAYOUT=\"" << m_layout << "\"\n";
|
||||
stream << "XKBVARIANT=\"" << m_variant << "\"\n";
|
||||
stream << "XKBOPTIONS=\"\"\n\n";
|
||||
stream << "BACKSPACE=\"guess\"\n";
|
||||
stream.flush();
|
||||
|
||||
file.close();
|
||||
|
||||
cDebug() << "Written XKBMODEL" << m_model <<
|
||||
"; XKBLAYOUT" << m_layout <<
|
||||
"; XKBVARIANT" << m_variant <<
|
||||
"to /etc/default/keyboard file" << defaultKeyboardPath;
|
||||
|
||||
return ( stream.status() == QTextStream::Ok );
|
||||
}
|
||||
|
||||
|
||||
Calamares::JobResult
|
||||
SetKeyboardLayoutJob::exec()
|
||||
{
|
||||
@ -271,6 +299,12 @@ SetKeyboardLayoutJob::exec()
|
||||
}
|
||||
destDir.mkpath( xorgConfDPath );
|
||||
|
||||
QString defaultKeyboardPath;
|
||||
if ( QDir( destDir.absoluteFilePath( "etc/default" ) ).exists() )
|
||||
{
|
||||
defaultKeyboardPath = destDir.absoluteFilePath( "etc/default/keyboard" );
|
||||
}
|
||||
|
||||
// Get the path to the destination's path to the converted key mappings
|
||||
QString convertedKeymapPath = m_convertedKeymapPath;
|
||||
if ( !convertedKeymapPath.isEmpty() )
|
||||
@ -288,5 +322,12 @@ 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 ( !writeDefaultKeyboardData( defaultKeyboardPath ) )
|
||||
return Calamares::JobResult::error( tr( "Failed to write keyboard configuration to existing /etc/default directory." ),
|
||||
tr( "Failed to write to %1" ).arg( keyboardConfPath ) );
|
||||
}
|
||||
|
||||
return Calamares::JobResult::ok();
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2014, Kevin Kofler <kevin.kofler@chello.at>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
@ -41,7 +41,8 @@ private:
|
||||
QString findLegacyKeymap() const;
|
||||
bool writeVConsoleData( const QString& vconsoleConfPath,
|
||||
const QString& convertedKeymapPath ) const;
|
||||
bool writeX11Data( const QString& keyboardConfPath ) const;
|
||||
bool writeX11Data( const QString& keyboardConfPath ) const;
|
||||
bool writeDefaultKeyboardData( const QString& defaultKeyboardPath ) const;
|
||||
|
||||
QString m_model;
|
||||
QString m_layout;
|
||||
|
Loading…
Reference in New Issue
Block a user