mirror of
https://github.com/meshtastic/firmware.git
synced 2026-05-25 01:12:45 -04:00
Notifications: Use libnotify
Use libnotify for meshtasticd desktop notifications. Add "HAS_LIBNOTIFY" macro to guard for builds where libnotify is expected. This is not included in buildroot/openwrt builds. (no libnotify except when extra repos are added). Install desktop icon in the correct location on Debian and Fedora packages. Update dependencies in packaging and dockerfiles.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 \
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 13 KiB |
3
debian/control
vendored
3
debian/control
vendored
@@ -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
|
||||
|
||||
2
debian/meshtasticd.install
vendored
2
debian/meshtasticd.install
vendored
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
#include "mesh/generated/meshtastic/rtttl.pb.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
#if HAS_LIBNOTIFY
|
||||
#include <libnotify/notify.h>
|
||||
#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
|
||||
#endif
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user