diff --git a/ghosteel.pro b/ghosteel.pro index 117dcdd..533c3f2 100644 --- a/ghosteel.pro +++ b/ghosteel.pro @@ -20,6 +20,10 @@ DEFINES += SAILFISH_SECRETS INCLUDEPATH += /usr/include/Sailfish LIBS += -lsailfishsecrets -lsailfishcrypto +# Non-graphical feedback daemon (ngfd) client for the terminal bell +INCLUDEPATH += /usr/include/ngf-qt5 +LIBS += -lngf-qt5 + # Centralized app identity — change these to rename the app APP_NAME = $$TARGET APP_ORG = com.zackslash @@ -56,6 +60,7 @@ LIBS += -lpthread -lm -ldl -lutil -lrt -lGLESv2 -lEGL RESOURCES += shaders/shaders.qrc HEADERS += \ + src/bellfeedback.h \ src/ghosteeladapter.h \ src/ghosttyvt.h \ src/glrenderer.h \ @@ -72,6 +77,7 @@ HEADERS += \ src/textutil.h SOURCES += \ + src/bellfeedback.cpp \ src/ghosteel.cpp \ src/ghosteeladapter.cpp \ src/ghosttyvt.cpp \ diff --git a/qml/pages/TerminalPage.qml b/qml/pages/TerminalPage.qml index 0a94d21..f157f38 100644 --- a/qml/pages/TerminalPage.qml +++ b/qml/pages/TerminalPage.qml @@ -1,7 +1,6 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 import Sailfish.Share 1.0 -import QtMultimedia 5.0 import Nemo.Notifications 1.0 import com.zackslash.ghosteel 1.0 import "KeyCatalog.js" as KeyCatalog @@ -132,12 +131,6 @@ Page { property string pendingClipboardSessionName: "" property bool clipboardDialogActive: false // Guards against stacking read dialogs - // Bell sound for terminal BEL character - SoundEffect { - id: bellSound - source: "/usr/share/sounds/jolla-ambient/stereo/jolla-notification.wav" - } - // Haptic feedback notification — publishing a notification triggers system vibration Notification { id: bellNotification @@ -678,7 +671,7 @@ Page { // Sound: mode 2 or 3 if (mode === 2 || mode === 3) { - bellSound.play() + bellFeedback.playBell() } } diff --git a/rpm/ghosteel.spec b/rpm/ghosteel.spec index cf84954..e14dded 100644 --- a/rpm/ghosteel.spec +++ b/rpm/ghosteel.spec @@ -17,6 +17,7 @@ Requires: nemo-qml-plugin-notifications-qt5 Requires: sailfishsecretsdaemon Requires: sailfishsecretsdaemon-cryptoplugins-default Requires: sailfishsecretsdaemon-secretsplugins-default +Requires: libngf-qt5 BuildRequires: pkgconfig(sailfishapp) >= 1.0.2 BuildRequires: pkgconfig(Qt5Core) BuildRequires: pkgconfig(Qt5DBus) @@ -29,6 +30,7 @@ BuildRequires: pkgconfig(freetype2) BuildRequires: pkgconfig(harfbuzz) BuildRequires: pkgconfig(sailfishsecrets) BuildRequires: pkgconfig(sailfishcrypto) +BuildRequires: pkgconfig(ngf-qt5) BuildRequires: desktop-file-utils BuildRequires: xz BuildRequires: patch diff --git a/src/bellfeedback.cpp b/src/bellfeedback.cpp new file mode 100644 index 0000000..84cab3a --- /dev/null +++ b/src/bellfeedback.cpp @@ -0,0 +1,27 @@ +#include "bellfeedback.h" + +#include +#include + +BellFeedback::BellFeedback(QObject *parent) + : QObject(parent) +{ +} + +void BellFeedback::ensureClient() +{ + if (m_client) + return; + // Lazy: skip the D-Bus connection until first bell. + // Ngf::Client auto-reconnects if the daemon appears after the first failure. + m_client = new Ngf::Client(this); + if (!m_client->connect()) { + qWarning() << "BellFeedback: ngfd connection failed; bell will be silent"; + } +} + +void BellFeedback::playBell() +{ + ensureClient(); + m_client->play(QStringLiteral("default")); +} diff --git a/src/bellfeedback.h b/src/bellfeedback.h new file mode 100644 index 0000000..2ce2c1e --- /dev/null +++ b/src/bellfeedback.h @@ -0,0 +1,23 @@ +#ifndef BELLFEEDBACK_H +#define BELLFEEDBACK_H + +#include + +namespace Ngf { class Client; } + +// Terminal bell via ngfd (SailfishOS feedback daemon). Chosen over a bundled +// WAV because community ports lack the proprietary jolla-ambient-sound-theme. +class BellFeedback : public QObject +{ + Q_OBJECT +public: + explicit BellFeedback(QObject *parent = nullptr); + + Q_INVOKABLE void playBell(); + +private: + void ensureClient(); + Ngf::Client *m_client = nullptr; +}; + +#endif // BELLFEEDBACK_H diff --git a/src/ghosteel.cpp b/src/ghosteel.cpp index 68535ee..1d06a0b 100644 --- a/src/ghosteel.cpp +++ b/src/ghosteel.cpp @@ -27,6 +27,7 @@ #undef emit #endif +#include "bellfeedback.h" #include "ghosteeladapter.h" #include "kittyimagedecoder.h" @@ -113,6 +114,10 @@ int main(int argc, char *argv[]) SessionManager *sessionManager = new SessionManager(app.data()); view->rootContext()->setContextProperty(QStringLiteral("SessionManager"), sessionManager); + // Expose the bell feedback (ngfd client) to QML + BellFeedback *bellFeedback = new BellFeedback(app.data()); + view->rootContext()->setContextProperty(QStringLiteral("bellFeedback"), bellFeedback); + // Store CLI args for deferred processing after QML restoreSessions() if (!execCommand.isEmpty() || !sessionName.isEmpty()) sessionManager->setCliArgs(execCommand, execArgs, sessionName);