alert (https://github.com/jwiegley/alert) addon to send notifications via Termux.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

alert-termux.el 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. ;;; alert-termux.el --- alert.el notifications on Termux -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2018 Gergely Polonkai
  3. ;; Author: Gergely Polonkai <gergely@polonkai.eu>
  4. ;; Keywords: terminals
  5. ;; Version: 1.0
  6. ;; Package-Requires: ((emacs "24.4"))
  7. ;; URL: https://github.com/gergelypolonkai/alert-termux
  8. ;; This program is free software; you can redistribute it and/or modify
  9. ;; it under the terms of the GNU General Public License as published by
  10. ;; the Free Software Foundation, either version 3 of the License, or
  11. ;; (at your option) any later version.
  12. ;; This program is distributed in the hope that it will be useful,
  13. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;; GNU General Public License for more details.
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. ;;; Commentary:
  19. ;;
  20. ;; Alert style that uses termux-notification to send alerts.
  21. ;;
  22. ;; The the required command, termux-notification can be found in the termux-api package, and
  23. ;; requires the Termux API app to be installed alongside with Termux.
  24. ;;; Code:
  25. (require 'alert)
  26. (defcustom alert-termux-command (executable-find "termux-notification")
  27. "Path to the termux-notification command.
  28. This is found in the termux-api package, and it requires the Termux API addon
  29. app to be installed."
  30. :type 'file
  31. :group 'alert)
  32. (defun alert-termux-notify (info)
  33. "Send INFO using termux-notification.
  34. Handles :TITLE and :MESSAGE keywords from the INFO plist."
  35. (if alert-termux-command
  36. (let ((args (nconc
  37. (when (plist-get info :title)
  38. (list "-t" (alert-encode-string (plist-get info :title))))
  39. (list "-c" (alert-encode-string (plist-get info :message))))))
  40. (apply #'call-process alert-termux-command nil
  41. (list (get-buffer-create " *termux-notification output*") t)
  42. nil args))
  43. (alert-message-notify info)))
  44. (alert-define-style 'termux
  45. :title "Notify using termux"
  46. :notifier #'alert-termux-notify)
  47. (provide 'alert-termux)
  48. ;;; alert-termux.el ends here