diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index f546d4cfd2..589ad8c3ea 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -34,6 +34,7 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ libxcb-xkb-dev \ libxkbcommon-dev \ libinput-dev \ + libnotify-dev \ && apt-get clean && rm -rf /var/lib/apt/lists/* RUN pipx install platformio diff --git a/Dockerfile b/Dockerfile index e00d81658d..211c6e1b91 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ curl wget g++ zip git ca-certificates pkg-config \ libgpiod-dev libyaml-cpp-dev libbluetooth-dev libi2c-dev libuv1-dev \ libusb-1.0-0-dev libulfius-dev liborcania-dev libssl-dev \ - libx11-dev libinput-dev libxkbcommon-x11-dev libsqlite3-dev libsdl2-dev \ + libx11-dev libinput-dev libxkbcommon-x11-dev libsqlite3-dev libsdl2-dev libnotify-dev \ && apt-get clean && rm -rf /var/lib/apt/lists/* \ && pip install --no-cache-dir -U platformio \ && mkdir /tmp/firmware @@ -53,7 +53,7 @@ USER root RUN apt-get update && apt-get --no-install-recommends -y install \ libc-bin libc6 libgpiod3 libyaml-cpp0.8 libi2c0 libuv1t64 libusb-1.0-0-dev \ liborcania2.3 libulfius2.7t64 libssl3t64 \ - libx11-6 libinput10 libxkbcommon-x11-0 libsdl2-2.0-0 \ + libx11-6 libinput10 libxkbcommon-x11-0 libsdl2-2.0-0 libnotify4 \ && apt-get clean && rm -rf /var/lib/apt/lists/* \ && mkdir -p /var/lib/meshtasticd \ && mkdir -p /etc/meshtasticd/config.d \ diff --git a/Dockerfile.test b/Dockerfile.test index 12479b36d4..297c19c6e6 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -9,7 +9,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ g++ git ca-certificates pkg-config \ libgpiod-dev libyaml-cpp-dev libbluetooth-dev libi2c-dev libuv1-dev \ libusb-1.0-0-dev libulfius-dev liborcania-dev libssl-dev \ - libx11-dev libinput-dev libxkbcommon-x11-dev libsqlite3-dev libsdl2-dev \ + libx11-dev libinput-dev libxkbcommon-x11-dev libsqlite3-dev libsdl2-dev libnotify-dev \ && apt-get clean && rm -rf /var/lib/apt/lists/* \ && pip install --no-cache-dir platformio==6.1.19 \ && useradd --create-home --shell /usr/sbin/nologin meshtastic diff --git a/alpine.Dockerfile b/alpine.Dockerfile index 75c9aa594d..ebbf9dab4d 100644 --- a/alpine.Dockerfile +++ b/alpine.Dockerfile @@ -11,7 +11,7 @@ RUN apk --no-cache add \ bash g++ libstdc++-dev linux-headers zip git ca-certificates libbsd-dev \ libgpiod-dev yaml-cpp-dev bluez-dev \ libusb-dev i2c-tools-dev libuv-dev openssl-dev pkgconf argp-standalone \ - libx11-dev libinput-dev libxkbcommon-dev sqlite-dev sdl2-dev \ + libx11-dev libinput-dev libxkbcommon-dev sqlite-dev sdl2-dev libnotify-dev \ && rm -rf /var/cache/apk/* \ && pip install --no-cache-dir -U platformio \ && mkdir /tmp/firmware @@ -42,7 +42,7 @@ USER root RUN apk --no-cache add \ shadow libstdc++ libbsd libgpiod yaml-cpp libusb \ - i2c-tools libuv libx11 libinput libxkbcommon sdl2 \ + i2c-tools libuv libx11 libinput libxkbcommon sdl2 libnotify \ && rm -rf /var/cache/apk/* \ && mkdir -p /var/lib/meshtasticd \ && mkdir -p /etc/meshtasticd/config.d \ diff --git a/bin/org.meshtastic.meshtasticd.png b/bin/org.meshtastic.meshtasticd.png deleted file mode 100644 index d031c10e26..0000000000 Binary files a/bin/org.meshtastic.meshtasticd.png and /dev/null differ diff --git a/debian/control b/debian/control index 8e5f17af99..403b5537a3 100644 --- a/debian/control +++ b/debian/control @@ -27,7 +27,8 @@ Build-Depends: debhelper-compat (= 13), libinput-dev, libxkbcommon-x11-dev, libsqlite3-dev, - libsdl2-dev + libsdl2-dev, + libnotify-dev Standards-Version: 4.6.2 Homepage: https://github.com/meshtastic/firmware Rules-Requires-Root: no diff --git a/debian/meshtasticd.install b/debian/meshtasticd.install index 62c0150dbb..3a30f1d7c6 100644 --- a/debian/meshtasticd.install +++ b/debian/meshtasticd.install @@ -7,3 +7,5 @@ bin/meshtasticd.service lib/systemd/system bin/meshtasticd-start.sh usr/bin web/* usr/share/meshtasticd/web + +bin/org.meshtastic.meshtasticd.svg usr/share/icons/hicolor/scalable/apps diff --git a/meshtasticd.spec.rpkg b/meshtasticd.spec.rpkg index a9eb552d71..3ab9a5a7ac 100644 --- a/meshtasticd.spec.rpkg +++ b/meshtasticd.spec.rpkg @@ -50,6 +50,7 @@ BuildRequires: pkgconfig(x11) BuildRequires: pkgconfig(libinput) BuildRequires: pkgconfig(xkbcommon-x11) BuildRequires: pkgconfig(sdl2) +BuildRequires: pkgconfig(libnotify) # libbsd is needed on older Fedora/RHEL to provide 'strlcpy' %if 0%{?fedora} >= 39 || 0%{?rhel} >= 10 @@ -112,6 +113,10 @@ cp -r web/* %{buildroot}%{_datadir}/meshtasticd/web # Install default SSL storage directory (for web) mkdir -p %{buildroot}%{_sysconfdir}/meshtasticd/ssl +# Install desktop icon +mkdir -p %{buildroot}%{_datadir}/icons/hicolor/scalable/apps +install -m 0644 bin/org.meshtastic.meshtasticd.svg %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/org.meshtastic.meshtasticd.svg + %pre # create spi group (for udev rules) getent group spi > /dev/null || groupadd -r spi @@ -171,6 +176,7 @@ fi %dir %{_datadir}/meshtasticd/web %{_datadir}/meshtasticd/web/* %dir %{_sysconfdir}/meshtasticd/ssl +%{_datadir}/icons/hicolor/scalable/apps/org.meshtastic.meshtasticd.svg %changelog %autochangelog diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 5da3750741..32db733133 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -24,6 +24,10 @@ #include "mesh/generated/meshtastic/rtttl.pb.h" #include +#if HAS_LIBNOTIFY +#include +#endif + #if defined(HAS_RGB_LED) #include "AmbientLightingThread.h" uint8_t red = 0; @@ -408,7 +412,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP if (genericShouldAlert) { LOG_INFO("externalNotificationModule - Generic alert"); setExternalState(0, true); -#if ARCH_PORTDUINO +#if HAS_LIBNOTIFY portduinoNotify(mp); #endif } @@ -525,7 +529,7 @@ int ExternalNotificationModule::handleInputEvent(const InputEvent *event) return 0; } -#if ARCH_PORTDUINO +#if HAS_LIBNOTIFY void ExternalNotificationModule::portduinoNotify(const meshtastic_MeshPacket &mp) { std::string senderName; @@ -541,9 +545,23 @@ void ExternalNotificationModule::portduinoNotify(const meshtastic_MeshPacket &mp } std::string notificationSummary = "From: " + senderName; std::string notificationBody = std::string((char *)mp.decoded.payload.bytes, mp.decoded.payload.size); - std::string command = "notify-send -a Meshtasticd -i org.meshtastic.meshtasticd.png "; - command += "\"" + notificationSummary + "\" \"" + notificationBody + "\""; - LOG_INFO("Executing command: %s", command.c_str()); - exec(command.c_str()); + + if (!notify_is_initted()) { + if (!notify_init("Meshtasticd")) { + LOG_WARN("Failed to initialize libnotify"); + return; + } + } + NotifyNotification *notification = + notify_notification_new(notificationSummary.c_str(), notificationBody.c_str(), "org.meshtastic.meshtasticd"); + if (notification) { + GError *error = nullptr; + if (!notify_notification_show(notification, &error)) { + LOG_WARN("Failed to show notification: %s", error ? error->message : "unknown error"); + if (error) + g_error_free(error); + } + g_object_unref(G_OBJECT(notification)); + } } -#endif \ No newline at end of file +#endif diff --git a/src/modules/ExternalNotificationModule.h b/src/modules/ExternalNotificationModule.h index 1d9c207ad3..bf1e8e6c16 100644 --- a/src/modules/ExternalNotificationModule.h +++ b/src/modules/ExternalNotificationModule.h @@ -78,7 +78,7 @@ class ExternalNotificationModule : public SinglePortModule, private concurrency: meshtastic_AdminMessage *request, meshtastic_AdminMessage *response) override; -#if ARCH_PORTDUINO +#if HAS_LIBNOTIFY void portduinoNotify(const meshtastic_MeshPacket &mp); #endif }; diff --git a/variants/native/portduino/platformio.ini b/variants/native/portduino/platformio.ini index 045e3edead..18b1865cd0 100644 --- a/variants/native/portduino/platformio.ini +++ b/variants/native/portduino/platformio.ini @@ -2,6 +2,8 @@ extends = portduino_base build_flags = ${portduino_base.build_flags} -I variants/native/portduino -I /usr/include + !pkg-config --cflags --libs libnotify + -D HAS_LIBNOTIFY=1 board = cross_platform board_level = extra lib_deps = @@ -27,7 +29,8 @@ build_type = release lib_deps = ${native_base.lib_deps} ${device-ui_base.lib_deps} -build_flags = ${native_base.build_flags} -Os -lX11 -linput -lxkbcommon -ffunction-sections -fdata-sections -Wl,--gc-sections +build_flags = ${native_base.build_flags} + -Os -lX11 -linput -lxkbcommon -ffunction-sections -fdata-sections -Wl,--gc-sections -D RAM_SIZE=16384 -D USE_X11=1 -D HAS_TFT=1 @@ -55,7 +58,8 @@ build_type = release lib_deps = ${native_base.lib_deps} ${device-ui_base.lib_deps} -build_flags = ${native_base.build_flags} -Os -ffunction-sections -fdata-sections -Wl,--gc-sections +build_flags = ${native_base.build_flags} + -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -D RAM_SIZE=8192 -D USE_FRAMEBUFFER=1 -D LV_COLOR_DEPTH=32 @@ -84,7 +88,8 @@ build_type = debug lib_deps = ${native_base.lib_deps} ${device-ui_base.lib_deps} -build_flags = ${native_base.build_flags} -O0 -fsanitize=address -lX11 -linput -lxkbcommon +build_flags = ${native_base.build_flags} + -O0 -fsanitize=address -lX11 -linput -lxkbcommon -D DEBUG_HEAP -D RAM_SIZE=16384 -D USE_X11=1 @@ -112,7 +117,9 @@ build_src_filter = ${env:native-tft.build_src_filter} [env:coverage] extends = env:native -build_flags = -lgcov --coverage -fprofile-abs-path -fsanitize=address ${env:native.build_flags} +build_flags = + -lgcov --coverage -fprofile-abs-path -fsanitize=address + ${env:native.build_flags} ; https://docs.platformio.org/en/latest/projectconf/sections/env/options/test/test_testing_command.html test_testing_command = ${platformio.build_dir}/${this.__env__}/meshtasticd