diff options
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell-plugins')
6 files changed, 96 insertions, 4 deletions
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() | |||
92 | cmake_minimum_required(VERSION 3.20) | 92 | cmake_minimum_required(VERSION 3.20) |
93 | project(custom LANGUAGES CXX) | 93 | project(custom LANGUAGES CXX) |
94 | 94 | ||
95 | find_package(Qt6 REQUIRED COMPONENTS Core Qml) | 95 | find_package(Qt6 REQUIRED COMPONENTS Core Qml DBus) |
96 | 96 | ||
97 | qt_standard_project_setup(REQUIRES 6.6) | 97 | qt_standard_project_setup(REQUIRES 6.6) |
98 | 98 | ||
@@ -102,16 +102,32 @@ qt6_add_qml_module(customplugin | |||
102 | PLUGIN_TARGET customplugin | 102 | PLUGIN_TARGET customplugin |
103 | ) | 103 | ) |
104 | 104 | ||
105 | target_sources(customplugin PRIVATE | 105 | set_source_files_properties(org.keepassxc.KeePassXC.MainWindow.xml PROPERTIES |
106 | Chrono.cpp Chrono.hpp | 106 | CLASSNAME DBusKeePassXC |
107 | FileSelector.cpp FileSelector.hpp | 107 | NO_NAMESPACE TRUE |
108 | ) | 108 | ) |
109 | 109 | ||
110 | qt_add_dbus_interface(DBUS_INTERFACES | ||
111 | org.keepassxc.KeePassXC.MainWindow.xml | ||
112 | dbus_keepassxc | ||
113 | ) | ||
114 | |||
115 | include_directories(${CMAKE_SOURCE_DIR}/build) | ||
116 | |||
110 | target_compile_features(customplugin PUBLIC cxx_std_26) | 117 | target_compile_features(customplugin PUBLIC cxx_std_26) |
111 | 118 | ||
112 | target_link_libraries(customplugin PRIVATE | 119 | target_link_libraries(customplugin PRIVATE |
113 | Qt6::Core | 120 | Qt6::Core |
114 | Qt6::Qml | 121 | Qt6::Qml |
122 | Qt6::DBus | ||
123 | ) | ||
124 | |||
125 | target_sources(customplugin PRIVATE | ||
126 | Chrono.cpp Chrono.hpp | ||
127 | FileSelector.cpp FileSelector.hpp | ||
128 | KeePassXC.cpp KeePassXC.hpp | ||
129 | Systemd.cpp Systemd.hpp | ||
130 | ${DBUS_INTERFACES} | ||
115 | ) | 131 | ) |
116 | 132 | ||
117 | install_qml_module(customplugin) | 133 | 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 @@ | |||
1 | #include "KeePassXC.hpp" | ||
2 | |||
3 | #include <QDBusConnection> | ||
4 | |||
5 | KeePassXC::KeePassXC() { | ||
6 | this->service = new DBusKeePassXC(DBusKeePassXC::staticInterfaceName(), "/keepassxc", QDBusConnection::sessionBus(), this); | ||
7 | } | ||
8 | KeePassXC::~KeePassXC() { | ||
9 | if (this->service) | ||
10 | delete this->service; | ||
11 | } | ||
12 | |||
13 | void KeePassXC::lockAllDatabases() { | ||
14 | if (!this->service) | ||
15 | return; | ||
16 | |||
17 | this->service->lockAllDatabases(); | ||
18 | } | ||
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 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include "dbus_keepassxc.h" | ||
4 | |||
5 | #include <QObject> | ||
6 | #include <QtQmlIntegration/qqmlintegration.h> | ||
7 | |||
8 | class KeePassXC : public QObject { | ||
9 | Q_OBJECT; | ||
10 | QML_SINGLETON; | ||
11 | QML_ELEMENT; | ||
12 | |||
13 | public: | ||
14 | explicit KeePassXC(); | ||
15 | ~KeePassXC(); | ||
16 | |||
17 | Q_INVOKABLE void lockAllDatabases(); | ||
18 | |||
19 | private: | ||
20 | DBusKeePassXC* service = nullptr; | ||
21 | }; | ||
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 @@ | |||
1 | #include "Systemd.hpp" | ||
2 | |||
3 | #include <QDBusConnection> | ||
4 | #include <QDBusMessage> | ||
5 | |||
6 | void Systemd::stopUserUnit(const QString& unit, const QString& mode) { | ||
7 | QDBusMessage m = QDBusMessage::createMethodCall( | ||
8 | "org.freedesktop.systemd1", | ||
9 | "/org/freedesktop/systemd1", | ||
10 | "org.freedesktop.systemd1.Manager", | ||
11 | "StopUnit" | ||
12 | ); | ||
13 | m << unit; | ||
14 | m << mode; | ||
15 | QDBusConnection::sessionBus().send(m); | ||
16 | } | ||
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 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include <QObject> | ||
4 | #include <QtQmlIntegration/qqmlintegration.h> | ||
5 | |||
6 | class Systemd : public QObject { | ||
7 | Q_OBJECT; | ||
8 | QML_SINGLETON; | ||
9 | QML_ELEMENT; | ||
10 | |||
11 | public: | ||
12 | Q_INVOKABLE void stopUserUnit(const QString& unit, const QString& mode); | ||
13 | }; | ||
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 @@ | |||
3 | , cmake | 3 | , cmake |
4 | , qt6 | 4 | , qt6 |
5 | , fmt | 5 | , fmt |
6 | , keepassxc | ||
7 | , systemd | ||
6 | }: | 8 | }: |
9 | |||
7 | stdenv.mkDerivation rec { | 10 | stdenv.mkDerivation rec { |
8 | name = "quickshell-custom"; | 11 | name = "quickshell-custom"; |
9 | 12 | ||
10 | src = ./.; | 13 | src = ./.; |
14 | |||
15 | prePatch = '' | ||
16 | cp ${keepassxc.src}/src/gui/org.keepassxc.KeePassXC.MainWindow.xml . | ||
17 | ''; | ||
18 | |||
11 | nativeBuildInputs = [ cmake qt6.wrapQtAppsHook ]; | 19 | nativeBuildInputs = [ cmake qt6.wrapQtAppsHook ]; |
12 | buildInputs = [ | 20 | buildInputs = [ |
13 | qt6.qtbase | 21 | qt6.qtbase |