Skip to content

Commit

Permalink
Escape special chars and some edge case fixes when showing the notifi…
Browse files Browse the repository at this point in the history
…cation's details.
  • Loading branch information
MIvanchev committed Jan 23, 2025
1 parent c4f077b commit 8df1cd2
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions util/notify/notify.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,31 @@
(append fst (list "..."))
fst)))))

(defun escape-special-chars (text)
(stumpwm::escape-caret text))

(defun show-notification (app icon summary body)
"Show the notification using standard STUMPWM::MESSAGE function"
(declare (ignore app icon))
(stumpwm:message "~A~A^0~% ~%~A~A^0"
; Use ^[ and ^] to preserve the selected colors and include
; the noop ^[^] between the color and the text to make sure
; that the notification's texts' are separated from StumpWM's
; color modifier. This becomes an issue when the text begins
; with a digit. Also, escape all special chars in the texts
; to make sure no funny things happen.
(stumpwm:message "^[~A^[^]~A^]~% ~%^[~A^[^]~A^]"
*notify-server-title-color*
(rewrap-body
summary
:max-lines *notify-server-max-title-lines*
:show-ellipsis t)
(escape-special-chars
(rewrap-body
summary
:max-lines *notify-server-max-title-lines*
:show-ellipsis t))
*notify-server-body-color*
(rewrap-body
body
:max-lines *notify-server-max-body-lines*
:show-ellipsis t)))
(escape-special-chars
(rewrap-body
body
:max-lines *notify-server-max-body-lines*
:show-ellipsis t))))

(define-dbus-object notify-dbus-service
(:path "/org/freedesktop/Notifications"))
Expand Down

0 comments on commit 8df1cd2

Please sign in to comment.