Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for specifying the Growl alert title #153

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

joe714
Copy link

@joe714 joe714 commented Dec 15, 2013

Support using the RECORD SEPARATOR (036) control character
to split the growl message string into multiple parts to
more explicitly control the growl behavior. With this change,
the first part is used as the alert title and the second part
is the message, mostly backwards-compatible with prior
releases:
"\e]9;Alert Title \036Growl Notification\007"

If no record separator is present, the entire string is used
as the user's message as before.

Records past the first two are currently ignored for future
compatibility.

Support using the RECORD SEPARATOR (036) control character
to split the growl message string into multiple parts to
more explicitly control the growl behavior. With this change,
the first part is used as the alert title and the second part
is the message, mostly backwards-compatible with prior
releases:
    "\e]9;Alert Title \036Growl Notification\007"

If no record separator is present, the entire string is used
as the user's message as before.

Records past the first two are currently ignored for future
compatibility.
@gnachman
Copy link
Owner

Why not use newline as the separator? I don't think I've ever seen \036 used for anything.

@joe714
Copy link
Author

joe714 commented Dec 16, 2013

\n could conceivably already be in use by someone to create embedded newlines in the alert dialog. To support that case, only the first split should probably be considered with additional newlines kept in the remainder rather than reserving it for future use, and anyone already sending embedded newlines would have to update to add a title.

Record Separator seemed to be a harmless, non-printable control character that wouldn't likely be found in existing alerts and was somewhat descriptive, and if it was sent to a prior version (for example, by a script targeting a supporting version) it just results in a longer message.

If it doesn't seem likely someone's already using newlines in their alert text, I'm ok with changing it.

@gnachman
Copy link
Owner

I think the benefit from ease of use exceeds the cost of any possible backward-compatibility breakage (which is trivial) that might ensue. Let's use newline as the separator. As you say, only the first newline would be used to delimit titles, which must be a single line long.

@joe714
Copy link
Author

joe714 commented Dec 16, 2013

Ok, I can rework it.

Change to detecting the first newline sequence in the growl
alert message to signify a custom title, rather than RS.
@joe714
Copy link
Author

joe714 commented Dec 16, 2013

Ok, updated to use newline sequences (As I discovered on my first attempt, \n alone is likely to get turned into \r\n by various things in the pipeline)

Tests:
echo -e $'\e]9;line1\007'
echo -e $'\e]9;line1\n\007'
echo -e $'\e]9;\nline1\007'
echo -e $'\e]9;\nline1\nline2\007'
echo -e $'\e]9;title\nline1\007'
echo -e $'\e]9;title\nline1\nline2\007'
echo -e $'\e]9;title\n\nline1\nline2\007'

@gnachman
Copy link
Owner

Looks good. Can you add the tests in your comment to an executable script in tests/growl.sh? I'd pull now but there was a merge conflict, so please rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants