mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
envmanager: Add overlay configs through XDG_CONFIG_DIRS
We currently directly write our settings to ~/.config/kwinrc and ~/.config/ksmserver. Instead, create a separate config file with our settings (in ~/.config/plasma-mobile), and in startplasmamobile, add that path to XDG_CONFIG_DIRS. These options will be applied in the mobile session, unless the user explicitly sets the config option.
This commit is contained in:
parent
72284989f8
commit
0e6221ce52
4 changed files with 56 additions and 20 deletions
|
|
@ -16,6 +16,9 @@ export QT_QUICK_CONTROLS_MOBILE=true
|
||||||
export PLASMA_INTEGRATION_USE_PORTAL=1
|
export PLASMA_INTEGRATION_USE_PORTAL=1
|
||||||
export PLASMA_PLATFORM=phone:handset
|
export PLASMA_PLATFORM=phone:handset
|
||||||
|
|
||||||
|
# Set ~/.config/plasma-mobile/... as location for default mobile configs (i.e. envmanager generated)
|
||||||
|
export XDG_CONFIG_DIRS="$HOME/.config/plasma-mobile:/etc/xdg:$XDG_CONFIG_DIRS"
|
||||||
|
|
||||||
# if coredumpd knows about the dumps, make sure drkonqi catches them
|
# if coredumpd knows about the dumps, make sure drkonqi catches them
|
||||||
if grep -q '/systemd-coredump' /proc/sys/kernel/core_pattern
|
if grep -q '/systemd-coredump' /proc/sys/kernel/core_pattern
|
||||||
then
|
then
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ const QMap<QString, QMap<QString, QVariant>> KDEGLOBALS_DEFAULT_SETTINGS = {{"Ge
|
||||||
|
|
||||||
const QMap<QString, QMap<QString, QVariant>> KDEGLOBALS_SETTINGS = {{"KDE", {{"LookAndFeelPackage", "org.kde.breeze.mobile"}}}};
|
const QMap<QString, QMap<QString, QVariant>> KDEGLOBALS_SETTINGS = {{"KDE", {{"LookAndFeelPackage", "org.kde.breeze.mobile"}}}};
|
||||||
|
|
||||||
// kwinrc
|
// plasma-mobile/kwinrc
|
||||||
QMap<QString, QMap<QString, QVariant>> getKwinrcSettings(KSharedConfig::Ptr m_mobileConfig)
|
QMap<QString, QMap<QString, QVariant>> getKwinrcSettings(KSharedConfig::Ptr m_mobileConfig)
|
||||||
{
|
{
|
||||||
auto group = KConfigGroup{m_mobileConfig, QStringLiteral("General")};
|
auto group = KConfigGroup{m_mobileConfig, QStringLiteral("General")};
|
||||||
|
|
@ -72,5 +72,5 @@ QMap<QString, QMap<QString, QVariant>> getKwinrcSettings(KSharedConfig::Ptr m_mo
|
||||||
const QList<QString> KWIN_EFFECTS = {"blur", "mobiletaskswitcher", "screenedge"};
|
const QList<QString> KWIN_EFFECTS = {"blur", "mobiletaskswitcher", "screenedge"};
|
||||||
const QList<QString> KWIN_SCRIPTS = {"convergentwindows"};
|
const QList<QString> KWIN_SCRIPTS = {"convergentwindows"};
|
||||||
|
|
||||||
//ksmserver
|
// plasma-mobile/ksmserver
|
||||||
const QMap<QString, QMap<QString, QVariant>> KSMSERVER_SETTINGS = {{"General", {{"loginMode", "emptySession"}}}};
|
const QMap<QString, QMap<QString, QVariant>> KSMSERVER_SETTINGS = {{"General", {{"loginMode", "emptySession"}}}};
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,19 @@ using namespace Qt::Literals::StringLiterals;
|
||||||
const QString CONFIG_FILE = u"plasmamobilerc"_s;
|
const QString CONFIG_FILE = u"plasmamobilerc"_s;
|
||||||
const QString SAVED_CONFIG_GROUP = u"SavedConfig"_s;
|
const QString SAVED_CONFIG_GROUP = u"SavedConfig"_s;
|
||||||
|
|
||||||
|
// In bin/startplasmamobile, we add `~/.config/plasma-mobile` to XDG_CONFIG_DIRS to overlay our own configs
|
||||||
|
const QString MOBILE_KWINRC_FILE = u"plasma-mobile/kwinrc"_s;
|
||||||
|
const QString MOBILE_KSMSERVERRC_FILE = u"plasma-mobile/ksmserverrc"_s;
|
||||||
|
|
||||||
Settings::Settings(QObject *parent)
|
Settings::Settings(QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
, m_isMobilePlatform{KRuntimePlatform::runtimePlatform().contains(u"phone"_s)}
|
, m_isMobilePlatform{KRuntimePlatform::runtimePlatform().contains(u"phone"_s)}
|
||||||
, m_mobileConfig{KSharedConfig::openConfig(CONFIG_FILE, KConfig::SimpleConfig)}
|
, m_mobileConfig{KSharedConfig::openConfig(CONFIG_FILE, KConfig::SimpleConfig)}
|
||||||
, m_kwinrcConfig{KSharedConfig::openConfig(u"kwinrc"_s, KConfig::SimpleConfig)}
|
, m_kwinrcConfig{KSharedConfig::openConfig(MOBILE_KWINRC_FILE, KConfig::SimpleConfig)}
|
||||||
, m_appBlacklistConfig{KSharedConfig::openConfig(u"applications-blacklistrc"_s, KConfig::SimpleConfig)}
|
, m_appBlacklistConfig{KSharedConfig::openConfig(u"applications-blacklistrc"_s, KConfig::SimpleConfig)}
|
||||||
, m_kdeglobalsConfig{KSharedConfig::openConfig(u"kdeglobals"_s, KConfig::SimpleConfig)}
|
, m_kdeglobalsConfig{KSharedConfig::openConfig(u"kdeglobals"_s, KConfig::SimpleConfig)}
|
||||||
, m_ksmServerConfig{KSharedConfig::openConfig(u"ksmserverrc"_s, KConfig::SimpleConfig)}
|
, m_ksmServerConfig{KSharedConfig::openConfig(MOBILE_KSMSERVERRC_FILE, KConfig::SimpleConfig)}
|
||||||
|
, m_originalKwinrcConfig{KSharedConfig::openConfig(u"kwinrc"_s, KConfig::SimpleConfig)}
|
||||||
, m_configWatcher{KConfigWatcher::create(m_mobileConfig)}
|
, m_configWatcher{KConfigWatcher::create(m_mobileConfig)}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -51,9 +56,9 @@ void Settings::applyConfiguration()
|
||||||
|
|
||||||
void Settings::loadSavedConfiguration()
|
void Settings::loadSavedConfiguration()
|
||||||
{
|
{
|
||||||
// kwinrc
|
// kwinrc (legacy, we only write in the plasma-mobile/kwinrc file now)
|
||||||
loadKeys(u"kwinrc"_s, m_kwinrcConfig, getKwinrcSettings(m_mobileConfig));
|
loadKeys(u"kwinrc"_s, m_originalKwinrcConfig, getKwinrcSettings(m_mobileConfig));
|
||||||
m_kwinrcConfig->sync();
|
m_originalKwinrcConfig->sync();
|
||||||
reloadKWinConfig();
|
reloadKWinConfig();
|
||||||
|
|
||||||
// applications-blacklistrc
|
// applications-blacklistrc
|
||||||
|
|
@ -71,33 +76,51 @@ void Settings::loadSavedConfiguration()
|
||||||
|
|
||||||
void Settings::applyMobileConfiguration()
|
void Settings::applyMobileConfiguration()
|
||||||
{
|
{
|
||||||
// kwinrc
|
// kwinrc-plasma-mobile
|
||||||
writeKeys(u"kwinrc"_s, m_kwinrcConfig, getKwinrcSettings(m_mobileConfig), false);
|
writeKeys(MOBILE_KWINRC_FILE, m_kwinrcConfig, getKwinrcSettings(m_mobileConfig));
|
||||||
m_kwinrcConfig->sync();
|
m_kwinrcConfig->sync();
|
||||||
reloadKWinConfig();
|
reloadKWinConfig();
|
||||||
|
|
||||||
// applications-blacklistrc
|
// applications-blacklistrc
|
||||||
writeKeys(u"applications-blacklistrc"_s,
|
writeKeysAndSave(u"applications-blacklistrc"_s,
|
||||||
m_appBlacklistConfig,
|
m_appBlacklistConfig,
|
||||||
APPLICATIONS_BLACKLIST_DEFAULT_SETTINGS,
|
APPLICATIONS_BLACKLIST_DEFAULT_SETTINGS,
|
||||||
true); // only write entries if they are not already defined in the config
|
true); // only write entries if they are not already defined in the config
|
||||||
m_appBlacklistConfig->sync();
|
m_appBlacklistConfig->sync();
|
||||||
|
|
||||||
// kdeglobals
|
// kdeglobals
|
||||||
writeKeys(u"kdeglobals"_s, m_kdeglobalsConfig, KDEGLOBALS_DEFAULT_SETTINGS,
|
writeKeysAndSave(u"kdeglobals"_s,
|
||||||
true); // only write entries if they are not already defined in the config
|
m_kdeglobalsConfig,
|
||||||
writeKeys(u"kdeglobals"_s, m_kdeglobalsConfig, KDEGLOBALS_SETTINGS, false);
|
KDEGLOBALS_DEFAULT_SETTINGS,
|
||||||
|
true); // only write entries if they are not already defined in the config
|
||||||
|
writeKeysAndSave(u"kdeglobals"_s, m_kdeglobalsConfig, KDEGLOBALS_SETTINGS, false);
|
||||||
m_kdeglobalsConfig->sync();
|
m_kdeglobalsConfig->sync();
|
||||||
|
|
||||||
// ksmserver
|
// ksmserver
|
||||||
writeKeys(u"ksmserverrc"_s, m_ksmServerConfig, KSMSERVER_SETTINGS, false);
|
writeKeys(MOBILE_KSMSERVERRC_FILE, m_ksmServerConfig, KSMSERVER_SETTINGS);
|
||||||
m_ksmServerConfig->sync();
|
m_ksmServerConfig->sync();
|
||||||
|
|
||||||
// save our changes
|
// save our changes
|
||||||
m_mobileConfig->sync();
|
m_mobileConfig->sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::writeKeys(const QString &fileName, KSharedConfig::Ptr &config, const QMap<QString, QMap<QString, QVariant>> &settings, bool overwriteOnlyIfEmpty)
|
void Settings::writeKeys(const QString &fileName, KSharedConfig::Ptr &config, const QMap<QString, QMap<QString, QVariant>> &settings)
|
||||||
|
{
|
||||||
|
const auto groupNames = settings.keys();
|
||||||
|
for (const auto &groupName : groupNames) {
|
||||||
|
auto group = KConfigGroup{config, groupName};
|
||||||
|
|
||||||
|
const auto keys = settings[groupName].keys();
|
||||||
|
for (const auto &key : keys) {
|
||||||
|
group.writeEntry(key, settings[groupName][key], KConfigGroup::Notify);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::writeKeysAndSave(const QString &fileName,
|
||||||
|
KSharedConfig::Ptr &config,
|
||||||
|
const QMap<QString, QMap<QString, QVariant>> &settings,
|
||||||
|
bool overwriteOnlyIfEmpty)
|
||||||
{
|
{
|
||||||
const auto groupNames = settings.keys();
|
const auto groupNames = settings.keys();
|
||||||
for (const auto &groupName : groupNames) {
|
for (const auto &groupName : groupNames) {
|
||||||
|
|
@ -209,4 +232,8 @@ void Settings::reloadKWinConfig()
|
||||||
// Call "start" to load enabled KWin scripts.
|
// Call "start" to load enabled KWin scripts.
|
||||||
QDBusMessage message = QDBusMessage::createMethodCall(u"org.kde.KWin"_s, u"/Scripting"_s, u"org.kde.kwin.Scripting"_s, u"start"_s);
|
QDBusMessage message = QDBusMessage::createMethodCall(u"org.kde.KWin"_s, u"/Scripting"_s, u"org.kde.kwin.Scripting"_s, u"start"_s);
|
||||||
QDBusConnection::sessionBus().send(message);
|
QDBusConnection::sessionBus().send(message);
|
||||||
|
|
||||||
|
// Call reconfigure
|
||||||
|
QDBusMessage reconfigureMessage = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reconfigure");
|
||||||
|
QDBusConnection::sessionBus().send(reconfigureMessage);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,10 @@ private:
|
||||||
// applies our mobile configuration
|
// applies our mobile configuration
|
||||||
void applyMobileConfiguration();
|
void applyMobileConfiguration();
|
||||||
|
|
||||||
void writeKeys(const QString &fileName, KSharedConfig::Ptr &config, const QMap<QString, QMap<QString, QVariant>> &settings, bool overwriteOnlyIfEmpty);
|
void writeKeys(const QString &fileName, KSharedConfig::Ptr &config, const QMap<QString, QMap<QString, QVariant>> &settings);
|
||||||
|
|
||||||
|
void
|
||||||
|
writeKeysAndSave(const QString &fileName, KSharedConfig::Ptr &config, const QMap<QString, QMap<QString, QVariant>> &settings, bool overwriteOnlyIfEmpty);
|
||||||
void loadKeys(const QString &fileName, KSharedConfig::Ptr &config, const QMap<QString, QMap<QString, QVariant>> &settings);
|
void loadKeys(const QString &fileName, KSharedConfig::Ptr &config, const QMap<QString, QMap<QString, QVariant>> &settings);
|
||||||
void saveConfigSetting(const QString &fileName, const QString &group, const QString &key, const QVariant value);
|
void saveConfigSetting(const QString &fileName, const QString &group, const QString &key, const QVariant value);
|
||||||
const QString loadSavedConfigSetting(KSharedConfig::Ptr &config, const QString &fileName, const QString &group, const QString &key, bool write = true);
|
const QString loadSavedConfigSetting(KSharedConfig::Ptr &config, const QString &fileName, const QString &group, const QString &key, bool write = true);
|
||||||
|
|
@ -39,10 +42,13 @@ private:
|
||||||
bool m_isMobilePlatform;
|
bool m_isMobilePlatform;
|
||||||
|
|
||||||
KSharedConfig::Ptr m_mobileConfig;
|
KSharedConfig::Ptr m_mobileConfig;
|
||||||
KSharedConfig::Ptr m_kwinrcConfig;
|
KSharedConfig::Ptr m_kwinrcConfig; // (~/.config/kwinrc-plasma-mobile)
|
||||||
KSharedConfig::Ptr m_appBlacklistConfig;
|
KSharedConfig::Ptr m_appBlacklistConfig;
|
||||||
KSharedConfig::Ptr m_kdeglobalsConfig;
|
KSharedConfig::Ptr m_kdeglobalsConfig;
|
||||||
KSharedConfig::Ptr m_ksmServerConfig;
|
KSharedConfig::Ptr m_ksmServerConfig;
|
||||||
|
|
||||||
|
// For legacy upgrade purposes (~/.config/kwinrc)
|
||||||
|
KSharedConfig::Ptr m_originalKwinrcConfig;
|
||||||
|
|
||||||
KConfigWatcher::Ptr m_configWatcher;
|
KConfigWatcher::Ptr m_configWatcher;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue