From 8a551339cbfaf106ac7d6f1ca5230196be539167 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 8 Sep 2025 20:00:22 +0200 Subject: ... --- .../shell/quickshell-plugins/CMakeLists.txt | 24 ++++++++++++++++++---- .../shell/quickshell-plugins/KeePassXC.cpp | 18 ++++++++++++++++ .../shell/quickshell-plugins/KeePassXC.hpp | 21 +++++++++++++++++++ .../shell/quickshell-plugins/Systemd.cpp | 16 +++++++++++++++ .../shell/quickshell-plugins/Systemd.hpp | 13 ++++++++++++ .../shell/quickshell-plugins/default.nix | 8 ++++++++ 6 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 accounts/gkleen@sif/shell/quickshell-plugins/KeePassXC.cpp create mode 100644 accounts/gkleen@sif/shell/quickshell-plugins/KeePassXC.hpp create mode 100644 accounts/gkleen@sif/shell/quickshell-plugins/Systemd.cpp create mode 100644 accounts/gkleen@sif/shell/quickshell-plugins/Systemd.hpp (limited to 'accounts/gkleen@sif/shell/quickshell-plugins') diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/CMakeLists.txt b/accounts/gkleen@sif/shell/quickshell-plugins/CMakeLists.txt index 2123ed35..a7e88fa7 100644 --- a/accounts/gkleen@sif/shell/quickshell-plugins/CMakeLists.txt +++ b/accounts/gkleen@sif/shell/quickshell-plugins/CMakeLists.txt @@ -92,7 +92,7 @@ endfunction() cmake_minimum_required(VERSION 3.20) project(custom LANGUAGES CXX) -find_package(Qt6 REQUIRED COMPONENTS Core Qml) +find_package(Qt6 REQUIRED COMPONENTS Core Qml DBus) qt_standard_project_setup(REQUIRES 6.6) @@ -102,16 +102,32 @@ qt6_add_qml_module(customplugin PLUGIN_TARGET customplugin ) -target_sources(customplugin PRIVATE - Chrono.cpp Chrono.hpp - FileSelector.cpp FileSelector.hpp +set_source_files_properties(org.keepassxc.KeePassXC.MainWindow.xml PROPERTIES + CLASSNAME DBusKeePassXC + NO_NAMESPACE TRUE ) +qt_add_dbus_interface(DBUS_INTERFACES + org.keepassxc.KeePassXC.MainWindow.xml + dbus_keepassxc +) + +include_directories(${CMAKE_SOURCE_DIR}/build) + target_compile_features(customplugin PUBLIC cxx_std_26) target_link_libraries(customplugin PRIVATE Qt6::Core Qt6::Qml + Qt6::DBus +) + +target_sources(customplugin PRIVATE + Chrono.cpp Chrono.hpp + FileSelector.cpp FileSelector.hpp + KeePassXC.cpp KeePassXC.hpp + Systemd.cpp Systemd.hpp + ${DBUS_INTERFACES} ) install_qml_module(customplugin) diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/KeePassXC.cpp b/accounts/gkleen@sif/shell/quickshell-plugins/KeePassXC.cpp new file mode 100644 index 00000000..f6e4dd6e --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell-plugins/KeePassXC.cpp @@ -0,0 +1,18 @@ +#include "KeePassXC.hpp" + +#include + +KeePassXC::KeePassXC() { + this->service = new DBusKeePassXC(DBusKeePassXC::staticInterfaceName(), "/keepassxc", QDBusConnection::sessionBus(), this); +} +KeePassXC::~KeePassXC() { + if (this->service) + delete this->service; +} + +void KeePassXC::lockAllDatabases() { + if (!this->service) + return; + + this->service->lockAllDatabases(); +} diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/KeePassXC.hpp b/accounts/gkleen@sif/shell/quickshell-plugins/KeePassXC.hpp new file mode 100644 index 00000000..c4cd71e0 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell-plugins/KeePassXC.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include "dbus_keepassxc.h" + +#include +#include + +class KeePassXC : public QObject { + Q_OBJECT; + QML_SINGLETON; + QML_ELEMENT; + +public: + explicit KeePassXC(); + ~KeePassXC(); + + Q_INVOKABLE void lockAllDatabases(); + +private: + DBusKeePassXC* service = nullptr; +}; diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/Systemd.cpp b/accounts/gkleen@sif/shell/quickshell-plugins/Systemd.cpp new file mode 100644 index 00000000..9ccd8ba0 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell-plugins/Systemd.cpp @@ -0,0 +1,16 @@ +#include "Systemd.hpp" + +#include +#include + +void Systemd::stopUserUnit(const QString& unit, const QString& mode) { + QDBusMessage m = QDBusMessage::createMethodCall( + "org.freedesktop.systemd1", + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", + "StopUnit" + ); + m << unit; + m << mode; + QDBusConnection::sessionBus().send(m); +} diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/Systemd.hpp b/accounts/gkleen@sif/shell/quickshell-plugins/Systemd.hpp new file mode 100644 index 00000000..883a96f3 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell-plugins/Systemd.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include +#include + +class Systemd : public QObject { + Q_OBJECT; + QML_SINGLETON; + QML_ELEMENT; + +public: + Q_INVOKABLE void stopUserUnit(const QString& unit, const QString& mode); +}; diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/default.nix b/accounts/gkleen@sif/shell/quickshell-plugins/default.nix index fafea90e..33b76f61 100644 --- a/accounts/gkleen@sif/shell/quickshell-plugins/default.nix +++ b/accounts/gkleen@sif/shell/quickshell-plugins/default.nix @@ -3,11 +3,19 @@ , cmake , qt6 , fmt +, keepassxc +, systemd }: + stdenv.mkDerivation rec { name = "quickshell-custom"; src = ./.; + + prePatch = '' + cp ${keepassxc.src}/src/gui/org.keepassxc.KeePassXC.MainWindow.xml . + ''; + nativeBuildInputs = [ cmake qt6.wrapQtAppsHook ]; buildInputs = [ qt6.qtbase -- cgit v1.2.3