19 #include <QDBusPendingCall>
20 #include <QDBusMessage>
21 #include <QDBusConnection>
22 #include <QDBusMetaType>
34 qDBusRegisterMetaType<QMap<QString,QString>>();
36 m_fsWatcher.addPath(wizardEnabledPath());
37 connect(&m_fsWatcher, SIGNAL(fileChanged(
const QString &)),
38 this, SIGNAL(wizardEnabledChanged()));
41 QString System::wizardEnabledPath()
44 return QDir::home().filePath(
".config/ubuntu-system-settings/wizard-has-run");
47 bool System::wizardEnabled()
const
49 return !QFile::exists(wizardEnabledPath());
52 void System::setWizardEnabled(
bool enabled)
54 if (wizardEnabled() == enabled)
58 QFile::remove(wizardEnabledPath());
60 QDir(wizardEnabledPath()).mkpath(
"..");
61 QFile(wizardEnabledPath()).open(QIODevice::WriteOnly);
62 m_fsWatcher.addPath(wizardEnabledPath());
63 wizardEnabledChanged();
67 void System::setSessionVariable(
const QString &variable,
const QString &value)
70 QProcess::startDetached(QStringLiteral(
"initctl set-env --global %1=%2").arg(variable, value));
72 QMap<QString,QString> valueMap;
73 valueMap.insert(variable, value);
75 QDBusMessage msg = QDBusMessage::createMethodCall(
"org.freedesktop.DBus",
76 "/org/freedesktop/DBus",
77 "org.freedesktop.DBus",
78 "UpdateActivationEnvironment");
80 msg << QVariant::fromValue(valueMap);
81 QDBusConnection::sessionBus().asyncCall(msg);
84 void System::updateSessionLanguage(
const QString &locale)
86 const QString language = locale.split(
".")[0];
88 setSessionVariable(
"LANGUAGE", language);
89 setSessionVariable(
"LANG", locale);
90 setSessionVariable(
"LC_ALL", locale);
94 QLocale::setDefault(QLocale(locale));
97 QProcess::startDetached(
"sh -c \"initctl emit indicator-services-end; \
98 initctl stop scope-registry; \
99 initctl stop smart-scopes-proxy; \
100 initctl emit --no-wait indicator-services-start; \
101 initctl restart --no-wait maliit-server; \
102 initctl restart --no-wait unity8-dash\"");