Sublime Forum

Play a sound when Find is unable to find match

#1

Is this possible? Similar to Find in Chrome. Handy if you’re looking at keyboard while typing. I found this, but no luck there.

0 Likes

Warning bell required
#2

I’m guessing ST doesn’t have cross-platform sound-playing support, so will be quite a lot of work to implement in core, meaning that plugin approach suggested previously would have to cater for each different platform manually, which seems to be non-trivial. But the API doesn’t make it easy to find the current find string/regex atm, so even with that hurdle overcome, it won’t be easy to do.

0 Likes

#3

Ok thanks mate.

0 Likes

#4

Just an FYI, the cross platform sound shouldn’t be an overwhelming task to complete. SubNotify does this:

OSX: https://github.com/facelessuser/SubNotify/blob/master/lib/notify/notify_osx.py#L74
WIN: https://github.com/facelessuser/SubNotify/blob/master/lib/notify/notify_windows.py#L112
LINUX: https://github.com/facelessuser/SubNotify/blob/master/lib/notify/notify_linux.py#L30

You’ll notice in OSX I have an alternate method that taps in to OSX libraries commented out, that is because it simply doesn’t work in the Sublime environment. Outside of Sublime it works fine: https://github.com/facelessuser/Rummage/blob/master/rummage/lib/gui/notify/notify_osx.py#L85. So we opt to use a subprocess in Sublime instead.

Linux is the main tricky one. I haven’t tested every distro created or anything, but is should be easy enough to accommodate a special case when you come across them.

As for the find part, yeah, the API just doesn’t provide those kind of events. But people shouldn’t get overwhelmed with the sound part. That part is doable.

3 Likes

#5

I defer to the ST plugin expert :slight_smile:

IIRC the view used for the find panel input box always has the same ID for the first ST window (though as an internal implementation detail, it could always change), and there may be a way to query whether the find panel is shown or not, and whether or not regex mode is toggled on, but it would be such a hack that I’d really recommend submitting a feature request for it - much like I did for requesting that plugins be given the ability to set the find/replace patterns:

2 Likes

#6

this is great and functionally useful — if i can hear the sound that it couldnt find anything — it is actually faster than looking for it visually on the screen. please add this.

0 Likes