This project listens for desktop notifications (e.g., Gmail, WhatsApp Web, Instagram) on a Fedora desktop and forwards them as SMS using a USB GSM modem and Gammu. It’s designed to run autonomously in the background and persist through lid close and modem replugging.
- Captures desktop notifications via
dbus-monitor - Parses app name, sender, and message content
- Sends SMS alerts using Gammu
- Runs persistently via user-level
systemdservice - Survives lid-close by overriding suspend behavior
- Handles modem disconnects using udev symlink
- Autosuspend workaround for reliable modem operation
- Fedora Linux
- USB GSM modem supported by Gammu (e.g. Huawei, ZTE, etc.)
- Python 3.8+
- Packages:
gammu,gammu-smsd,dbus,python3-dbus,dbus-tools
sudo dnf install python3-dbus gammu gammu-smsd dbus-toolsnotify-sms/
├── notify_sms.py # Python script that listens and sends SMS
├── gammu.config # Gammu config with modem details
├── notify_sms.service # systemd user service file
└── README.md
Create notify_sms.py inside the project directory. It listens for notifications and invokes Gammu to send SMS messages.
Make it executable:
chmod +x notify_sms.pyCreate gammu.config in the project folder:
[gammu]
port = /dev/gsm_modem
connection = atThis config assumes your USB modem is symlinked to /dev/gsm_modem.
Handle dynamic USB port assignments by symlinking modem to /dev/gsm_modem.
Create rule:
sudo nano /etc/udev/rules.d/99-gsm-modem.rulesAdd:
SUBSYSTEM=="tty", ATTRS{bInterfaceNumber}=="02", ATTRS{driver}=="option", SYMLINK+="gsm_modem"Reload udev:
sudo udevadm control --reload-rules
sudo udevadm triggerCreate user service file:
mkdir -p ~/.config/systemd/user/
nano ~/.config/systemd/user/notify_sms.servicePaste:
[Unit]
Description=Send Desktop Notifications via SMS
After=default.target
[Service]
ExecStart=/usr/bin/python3 /home/karthikey/notify-sms/notify_sms.py
Restart=always
[Install]
WantedBy=default.targetEnable and start the service:
systemctl --user daemon-reload
systemctl --user enable notify_sms.service
systemctl --user start notify_sms.serviceMonitor logs:
journalctl --user -u notify_sms.service -fMake Fedora ignore lid-close actions:
sudo mkdir -p /etc/systemd/logind.conf.d/
sudo nano /etc/systemd/logind.conf.d/logind.confPaste:
[Login]
HandleLidSwitch=ignore
HandleLidSwitchDocked=ignore
HandleLidSwitchExternalPower=ignore
LidSwitchIgnoreInhibited=noReload:
sudo systemctl restart systemd-logindYou may be logged out temporarily when this is applied.
Prevent GNOME from auto-suspending:
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type 'nothing'Check your modem ID:
lsusbThen create a rule to keep it powered:
sudo nano /etc/udev/rules.d/99-usb-autosuspend.rulesExample rule:
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="XXXX", ATTR{idProduct}=="YYYY", TEST=="power/control", ATTR{power/control}="on"Replace XXXX and YYYY with your modem’s Vendor/Product ID.
Reload:
sudo udevadm control --reload-rules
sudo udevadm triggersudo usermod -aG dialout $USER
newgrp dialoutgammu -c gammu.config --identify
gammu -c gammu.config sendsms TEXT <your-phone-number> -text "Test SMS"notify-send "Test App" "Test SMS body"journalctl --user -u notify_sms.service -f- Tested on Fedora Workstation with GNOME.
- You can easily customize notification filters or message formats in the Python script.
- Can be adapted for other Linux distros with
systemd,gammu, anddbus.