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 m_fsWatcher.addPath(wizardEnabledPath());
35 connect(&m_fsWatcher, SIGNAL(fileChanged(const QString &)),
36 this, SIGNAL(wizardEnabledChanged()));
39QString System::wizardEnabledPath()
41 // Uses ubuntu-system-settings namespace for historic compatibility reasons
42 return QDir::home().filePath(".config/ubuntu-system-settings/wizard-has-run");
45bool System::wizardEnabled() const
47 return !QFile::exists(wizardEnabledPath());
50void 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();
65void System::setSessionVariable(const QString &variable, const QString &value)
67 // We need to update both upstart's and DBus's environment
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));
80void System::updateSessionLanguage(const QString &locale)
82 QString language = locale.split(".")[0];
84 setSessionVariable("LANGUAGE", language);
85 setSessionVariable("LANG", locale);
86 setSessionVariable("LC_ALL", locale);
88 // QLocale caches the default locale on startup, and Qt uses that cached
89 // copy when formatting dates. So manually update it here.
90 QLocale::setDefault(QLocale(locale));
92 // Restart bits of the session to pick up new language.
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\"");
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