Lokyr
Documentation

Notification codes

On this page

macOS · for program authors

A program can ask Lokyr to show a desktop notification, such as when a long build ends, so that you hear of it while you work in another app. This page describes the three codes that Lokyr reads for that, in the notation of Escape codes.

Try it

Run this command, then switch to another app within three seconds:

sleep 3; printf '\033]777;notify;Build;Finished in 42 seconds\033\\'

A notification shows "Build" and "Finished in 42 seconds". Click it to bring the pane that sent it forward.

How Lokyr shows them

Each code below ends in the same notification, as macOS shows it:

macOS shows them once you allow Lokyr's notifications in System Settings › Notifications.

OSC 9, a notification

Platforms: macOS · Since 0.2 · Specification

OSC 9 ; body ST
ParameterValuesMeaning
bodyTextThe notification's text

What Lokyr does: it shows a notification of body, titled with the window's title. OSC 9 ; 4 is a progress, not a notification. Any other text after 9 ; is the body, other terminals' commands that start with a number among them.

Try it: run this command, then switch to another app within three seconds:

sleep 3; printf '\033]9;The tests passed\033\\'

A notification shows "The tests passed", titled with the window's title.

OSC 777, a notification with a title

Platforms: macOS · Since 0.2

OSC 777 ; notify ; title ; body ST
ParameterValuesMeaning
titleText, without ;The notification's title
bodyText, ; includedThe notification's text

What Lokyr does: it shows a notification of title and body. An empty title takes the window's. Lokyr ignores an OSC 777 other than notify.

Try it: the command of Try it above.

OSC 99, a notification in parts

Platforms: macOS · Since 1.3 · Specification

OSC 99 ; metadata ; payload ST

The metadata is a list of key=value pairs separated by :, which can be empty, but the two ; are required.

KeyValuesMeaning
iLetters, digits and _ - + ., up to 64The notification's id, which ties its parts together
ptitle, body, icon, buttons, ?What the payload is: title by default, and ? a query of what Lokyr supports
e0, 11 when the payload is in base64
d0, 10 when more parts of the notification follow; 1, the default, shows it

What Lokyr does: it gathers the title's and the body's parts of each i, and shows the notification when a part of d=1 comes, its body alone when it has no title. It takes no icon, buttons or actions: their parts count only for d. It ignores p=close and p=alive, and a part of a p that it doesn't know.

Lokyr answers a query, p=?, with what it supports, ended as the query was: a click brings the pane forward, notifications show while the window is in the background, and they hold a title and a body.

OSC 99 ; i=id : p=? ; a=focus : o=unfocused : p=title,body ST

Bounds: a part of more than 4096 bytes is ignored. A title gathers up to 1024 bytes and a body up to 4096. Lokyr holds the parts of 16 notifications at most; past them, the oldest goes.

Try it: a title and a body in two parts. Run this command, then switch to another app within three seconds:

sleep 3; printf '\033]99;i=1:d=0;Build\033\\'; printf '\033]99;i=1:p=body;Finished in 42 seconds\033\\'

A notification shows "Build" and "Finished in 42 seconds".

Ask Lokyr what it supports:

printf '\033]99;i=q:p=?;\033\\'; IFS= read -rs -t 1 -d '\' reply; reply=${reply#*]}; printf '%s\n' "${reply%$'\033'}"

You should see:

99;i=q:p=?;a=focus:o=unfocused:p=title,body

See also