Commit ed060770 authored by Janet Blackquill's avatar Janet Blackquill 🌈
Browse files

Makeshift systemd integration

parent 66f23123
......@@ -12,10 +12,6 @@ qt5_add_dbus_interface(SOURCES
DBusProtocols/org.freedesktop.Accounts.User.xml
User
)
qt5_add_dbus_interface(SOURCES
DBusProtocols/systemd.xml
systemd
)
add_executable(org.kde.initialsystemsetup
${SOURCES}
......@@ -33,7 +29,7 @@ target_link_libraries(org.kde.initialsystemsetup
configure_file(org.kde.initialsystemsetup.service.in org.kde.initialsystemsetup.service @ONLY)
install(
FILES org.kde.initialsystemsetup.service
FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.initialsystemsetup.service
DESTINATION ${KDE_INSTALL_SYSTEMDUNITDIR}
)
......
......@@ -14,4 +14,13 @@ ApplicationWindow {
initialItem: "pages/locale/Page.qml"
}
Connections {
target: KISS
function onFinished(success) {
if (success) {
staccy.replace("qrc:/pages/ready/Page.qml")
}
}
}
}
......@@ -3,5 +3,6 @@
<file>Main.qml</file>
<file>pages/user/Page.qml</file>
<file>pages/locale/Page.qml</file>
<file>pages/ready/Page.qml</file>
</qresource>
</RCC>
import QtQuick 2.5
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.10
import org.kde.kirigami 2.10 as Kirigami
Item {
ColumnLayout {
anchors.centerIn: parent
Kirigami.Heading {
text: "All Done!"
}
Button {
text: "Let's get started"
onClicked: {
KISS.disableSelf()
}
}
}
}
......@@ -11,12 +11,15 @@
#include "User.h"
#undef org
#include "systemd.h"
class KISS : public QObject
{
Q_OBJECT
QStringList m_locales;
OrgFreedesktopAccountsInterface* m_accountsInterface;
Systemd m_systemd;
public: KISS(QObject* parent = nullptr) : QObject(parent)
{
......@@ -49,4 +52,11 @@ class KISS : public QObject
Q_EMIT finished(true);
});
}
public: Q_INVOKABLE void disableSelf()
{
m_systemd.disableService("org.kde.initialsystemsetup");
m_systemd.enableService("sddm");
m_systemd.startService("sddm");
}
};
#pragma once
#include <QDBusConnection>
#include <QDBusInterface>
class Systemd
{
QDBusInterface* m_daemon;
public: Systemd()
{
m_daemon = new QDBusInterface("org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", QDBusConnection::systemBus());
}
public: ~Systemd()
{
delete m_daemon;
}
private: QString s(const QString& unit)
{
return unit + ".service";
}
private: void checkCall(QDBusMessage msg)
{
if (msg.type() == QDBusMessage::ErrorMessage) {
qWarning() << "dbus call failed (" << msg.errorName() << "):" << msg.errorMessage();
}
}
public: void enableService(const QString& name)
{
checkCall(m_daemon->call("EnableUnitFiles", QStringList{s(name)}, false, true));
}
public: void disableService(const QString& name)
{
checkCall(m_daemon->call("DisableUnitFiles", QStringList{s(name)}, false));
}
public: void startService(const QString& name)
{
checkCall(m_daemon->call("StartUnit", s(name), "replace"));
}
public: void stopService(const QString& name)
{
checkCall(m_daemon->call("StopUnit", s(name), "replace"));
}
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment