diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp
index 558695dc2..2f0c62faa 100644
--- a/src/gui/MainWindow.cpp
+++ b/src/gui/MainWindow.cpp
@@ -716,6 +716,43 @@ void MainWindow::appExit()
close();
}
+/**
+ * Returns if application was built with hardware key support.
+ * Intented to be used by 3rd-party applications using DBus.
+ *
+ * @return True if built with hardware key support, false otherwise
+ */
+bool MainWindow::isHardwareKeySupported()
+{
+#ifdef WITH_XC_YUBIKEY
+ return true;
+#else
+ return false;
+#endif
+}
+
+/**
+ * Refreshes list of hardware keys known.
+ * Triggers the DatabaseOpenWidget to automatically select the key last used for a database if found.
+ * Intented to be used by 3rd-party applications using DBus.
+ *
+ * @return True if any key was found, false otherwise or if application lacks hardware key support
+ */
+bool MainWindow::refreshHardwareKeys()
+{
+#ifdef WITH_XC_YUBIKEY
+ auto yk = YubiKey::instance();
+ // find keys sync to allow returning if any key was found
+ bool found = yk->findValidKeys();
+ // emit signal so DatabaseOpenWidget can select last used key
+ // emit here manually because sync findValidKeys() cannot do that properly
+ emit yk->detectComplete(found);
+ return found;
+#else
+ return false;
+#endif
+}
+
void MainWindow::updateLastDatabasesMenu()
{
m_ui->menuRecentDatabases->clear();
diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h
index 2fdc43ed1..8102fe0a1 100644
--- a/src/gui/MainWindow.h
+++ b/src/gui/MainWindow.h
@@ -69,6 +69,8 @@ signals:
public slots:
void openDatabase(const QString& filePath, const QString& password = {}, const QString& keyfile = {});
void appExit();
+ bool isHardwareKeySupported();
+ bool refreshHardwareKeys();
void displayGlobalMessage(const QString& text,
MessageWidget::MessageType type,
bool showClosebutton = true,
diff --git a/src/gui/org.keepassxc.KeePassXC.MainWindow.xml b/src/gui/org.keepassxc.KeePassXC.MainWindow.xml
index 635a66b93..651018149 100644
--- a/src/gui/org.keepassxc.KeePassXC.MainWindow.xml
+++ b/src/gui/org.keepassxc.KeePassXC.MainWindow.xml
@@ -15,6 +15,12 @@
+
+
+
+
+
+