2 * Copyright (C) 2014 Canonical Ltd.
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
19#include <QDBusInterface>
20#include <QDBusMetaType>
31 // Register the argument needed for UpdateActivationEnvironment below
32 qDBusRegisterMetaType<QMap<QString,QString>>();
34 if(!wizardEnabled()) {
35 m_fsWatcher.addPath(wizardEnabledPath());
37 connect(&m_fsWatcher, SIGNAL(fileChanged(const QString &)),
38 this, SIGNAL(wizardEnabledChanged()));
41QString System::wizardEnabledPath()
43 // Uses ubuntu-system-settings namespace for historic compatibility reasons
44 return QDir::home().filePath(".config/ubuntu-system-settings/wizard-has-run");
47bool System::wizardEnabled() const
49 return !QFile::exists(wizardEnabledPath());
52void 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();
67void System::setSessionVariable(const QString &variable, const QString &value)
69 // We need to update both upstart's and DBus's environment
70 QProcess::execute(QString("initctl set-env --global %1=%2").arg(variable, value));
72 QDBusInterface iface("org.freedesktop.DBus",
73 "/org/freedesktop/DBus",
74 "org.freedesktop.DBus",
75 QDBusConnection::sessionBus());
77 QMap<QString,QString> valueMap;
78 valueMap.insert(variable, value);
79 iface.call("UpdateActivationEnvironment", QVariant::fromValue(valueMap));
82void System::updateSessionLanguage(const QString &locale)
84 QString language = locale.split(".")[0];
86 setSessionVariable("LANGUAGE", language);
87 setSessionVariable("LANG", locale);
88 setSessionVariable("LC_ALL", locale);
90 // QLocale caches the default locale on startup, and Qt uses that cached
91 // copy when formatting dates. So manually update it here.
92 QLocale::setDefault(QLocale(locale));
94 // Restart bits of the session to pick up new language.
95 QProcess::startDetached("sh -c \"initctl emit indicator-services-end; \
96 initctl stop scope-registry; \
97 initctl stop smart-scopes-proxy; \
98 initctl emit --no-wait indicator-services-start; \
99 initctl restart --no-wait maliit-server; \
100 initctl restart --no-wait unity8-dash\"");
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list