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

Get KISS working as a minimum thing

parent acdf1420
......@@ -6,7 +6,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
......@@ -17,6 +17,7 @@ include(KDEInstallDirs)
find_package(Qt5 COMPONENTS Core Quick QuickControls2 DBus REQUIRED)
find_package(KF5I18n)
find_package(KF5Config)
set(DefaultPermissions
OWNER_WRITE OWNER_READ OWNER_EXECUTE
......
......@@ -23,7 +23,7 @@ target_compile_definitions(org.kde.initialsystemsetup
target_link_libraries(org.kde.initialsystemsetup
PRIVATE
Qt5::Core Qt5::Quick Qt5::QuickControls2 Qt5::DBus
KF5::I18n
KF5::I18n KF5::ConfigCore
)
configure_file(org.kde.initialsystemsetup.service.in org.kde.initialsystemsetup.service @ONLY)
......
#pragma once
#include <QString>
class Backend {
public:
virtual ~Backend() {};
virtual void yeetToSession(const QString& username) = 0;
};
#pragma once
#include <KConfig>
#include <KConfigGroup>
#include "../Backend.h"
#include "../systemd.h"
class SDDMBackend : public Backend {
public: SDDMBackend() {}
public: void yeetToSession(const QString& username) override {
KConfig conf("/etc/sddm.conf");
auto grp = conf.group("Autologin");
grp.writeEntry("User", username);
grp.writeEntry("Session", "plasmawayland.desktop");
Systemd::instance()->enableService("sddm");
Systemd::instance()->startService("sddm");
}
};
......@@ -12,6 +12,8 @@
#undef org
#include "systemd.h"
#include "Backend.h"
#include "DisplayManagerBackends/SDDM.h"
class KISS : public QObject
{
......@@ -19,14 +21,21 @@ class KISS : public QObject
QStringList m_locales;
OrgFreedesktopAccountsInterface* m_accountsInterface;
Systemd m_systemd;
Backend* m_backend;
QString m_name;
public: KISS(QObject* parent = nullptr) : QObject(parent)
{
m_backend = new SDDMBackend;
m_locales = QStringList(KLocalizedString::availableDomainTranslations("plasmashell").values());
m_accountsInterface = new OrgFreedesktopAccountsInterface(QStringLiteral("org.freedesktop.Accounts"), QStringLiteral("/org/freedesktop/Accounts"), QDBusConnection::systemBus(), this);
}
public: ~KISS()
{
delete m_backend;
}
Q_PROPERTY(QStringList locales READ locales)
public: QStringList locales() const
{
......@@ -37,7 +46,7 @@ class KISS : public QObject
public: Q_INVOKABLE void createAccount(const QString& realname, const QString& username, const QString& password, const bool& admin, const QString& language)
{
auto watcher = new QDBusPendingCallWatcher(m_accountsInterface->CreateUser(username, realname, admin ? 1 : 0), this);
connect(watcher, &QDBusPendingCallWatcher::finished, [=](QDBusPendingCallWatcher* self) {
connect(watcher, &QDBusPendingCallWatcher::finished, [=, this](QDBusPendingCallWatcher* self) {
QDBusPendingReply<QDBusObjectPath> reply = *self;
if (reply.isError()) {
......@@ -46,6 +55,7 @@ class KISS : public QObject
}
auto user = OrgFreedesktopAccountsUserInterface(QStringLiteral("org.freedesktop.Accounts"), reply.value().path(), QDBusConnection::systemBus(), this);
m_name = user.userName();
user.SetLanguage(language);
user.SetPassword(password, QString());
......@@ -55,9 +65,10 @@ class KISS : public QObject
public: Q_INVOKABLE void disableSelf()
{
m_systemd.disableService("org.kde.initialsystemsetup");
m_systemd.enableService("sddm");
m_systemd.startService("sddm");
QCoreApplication::exit(0);
Systemd::instance()->disableService("org.kde.initialsystemsetup");
m_backend->yeetToSession(m_name);
Systemd::instance()->stopService("org.kde.initialsystemsetup");
}
};
......@@ -6,6 +6,7 @@
int main(int argc, char *argv[])
{
QCoreApplication::setSetuidAllowed(true);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
......
......@@ -7,14 +7,22 @@ class Systemd
{
QDBusInterface* m_daemon;
public: Systemd()
private: Systemd()
{
m_daemon = new QDBusInterface("org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", QDBusConnection::systemBus());
}
public: ~Systemd()
private: ~Systemd()
{
delete m_daemon;
}
public: static Systemd* instance()
{
static Systemd* inst = nullptr;
if (inst == nullptr) {
inst = new Systemd();
}
return inst;
}
private: QString s(const QString& unit)
{
return unit + ".service";
......
......@@ -4,7 +4,7 @@ Conflicts=getty@tty1.service
After=systemd-user-sessions.service getty@tty1.service plymouth-quit.service systemd-logind.service
[Service]
ExecStart=@KDE_INSTALL_FULL_BINDIR@/org.kde.initialsystemsetup
ExecStart=@KDE_INSTALL_FULL_BINDIR@/org.kde.initialsystemsetup -platform eglfs
Restart=always
[Install]
......
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