19 #include <QDBusInterface>
20 #include <QDBusMetaType>
32 qDBusRegisterMetaType<QMap<QString,QString>>();
34 m_fsWatcher.addPath(wizardEnabledPath());
35 connect(&m_fsWatcher, SIGNAL(fileChanged(
const QString &)),
36 this, SIGNAL(wizardEnabledChanged()));
39 QString System::wizardEnabledPath()
42 return QDir::home().filePath(
".config/ubuntu-system-settings/wizard-has-run");
45 bool System::wizardEnabled()
const
47 return !QFile::exists(wizardEnabledPath());
50 void System::setWizardEnabled(
bool enabled)
52 if (wizardEnabled() == enabled)
56 QFile::remove(wizardEnabledPath());
58 QDir(wizardEnabledPath()).mkpath(
"..");
59 QFile(wizardEnabledPath()).open(QIODevice::WriteOnly);
60 m_fsWatcher.addPath(wizardEnabledPath());
61 wizardEnabledChanged();
65 void System::setSessionVariable(
const QString &variable,
const QString &value)
68 QProcess::execute(QString(
"initctl set-env --global %1=%2").arg(variable, value));
70 QDBusInterface iface(
"org.freedesktop.DBus",
71 "/org/freedesktop/DBus",
72 "org.freedesktop.DBus",
73 QDBusConnection::sessionBus());
75 QMap<QString,QString> valueMap;
76 valueMap.insert(variable, value);
77 iface.call(
"UpdateActivationEnvironment", QVariant::fromValue(valueMap));
80 void System::updateSessionLanguage(
const QString &locale)
82 QString language = locale.split(
".")[0];
84 setSessionVariable(
"LANGUAGE", language);
85 setSessionVariable(
"LANG", locale);
86 setSessionVariable(
"LC_ALL", locale);
90 QLocale::setDefault(QLocale(locale));
93 QProcess::startDetached(
"sh -c \"initctl emit indicator-services-end; \
94 initctl stop scope-registry; \
95 initctl stop smart-scopes-proxy; \
96 initctl emit --no-wait indicator-services-start; \
97 initctl restart --no-wait maliit-server; \
98 initctl restart --no-wait unity8-dash\"");