Add support for writing keymap data to /etc/default/keyboard.
This commit is contained in:
parent
b6811c65e8
commit
027ba074ed
@ -1,6 +1,6 @@
|
|||||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
/* === 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>
|
* Copyright 2014, Kevin Kofler <kevin.kofler@chello.at>
|
||||||
*
|
*
|
||||||
* Portions from systemd (localed.c):
|
* 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
|
Calamares::JobResult
|
||||||
SetKeyboardLayoutJob::exec()
|
SetKeyboardLayoutJob::exec()
|
||||||
{
|
{
|
||||||
@ -271,6 +299,12 @@ SetKeyboardLayoutJob::exec()
|
|||||||
}
|
}
|
||||||
destDir.mkpath( xorgConfDPath );
|
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
|
// Get the path to the destination's path to the converted key mappings
|
||||||
QString convertedKeymapPath = m_convertedKeymapPath;
|
QString convertedKeymapPath = m_convertedKeymapPath;
|
||||||
if ( !convertedKeymapPath.isEmpty() )
|
if ( !convertedKeymapPath.isEmpty() )
|
||||||
@ -288,5 +322,12 @@ SetKeyboardLayoutJob::exec()
|
|||||||
return Calamares::JobResult::error( tr( "Failed to write keyboard configuration for X11." ),
|
return Calamares::JobResult::error( tr( "Failed to write keyboard configuration for X11." ),
|
||||||
tr( "Failed to write to %1" ).arg( keyboardConfPath ) );
|
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();
|
return Calamares::JobResult::ok();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
/* === 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>
|
* Copyright 2014, Kevin Kofler <kevin.kofler@chello.at>
|
||||||
*
|
*
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
@ -42,6 +42,7 @@ private:
|
|||||||
bool writeVConsoleData( const QString& vconsoleConfPath,
|
bool writeVConsoleData( const QString& vconsoleConfPath,
|
||||||
const QString& convertedKeymapPath ) const;
|
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_model;
|
||||||
QString m_layout;
|
QString m_layout;
|
||||||
|
Loading…
Reference in New Issue
Block a user