Skip to content

Commit 220bb6f

Browse files
committed
Add sound support for linux/macOS when build success or failed.
1 parent a994dc8 commit 220bb6f

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/sentry.cr

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ module Sentry
145145
property display_name : String
146146
property should_build = true
147147
property files = [] of String
148+
@sound_player : String = ""
149+
@success_wav = "#{__DIR__}/sounds/drip.wav"
150+
@error_wav = "#{__DIR__}/sounds/error.wav"
148151

149152
def initialize(
150153
@display_name : String,
@@ -163,6 +166,14 @@ module Sentry
163166
@app_built = false
164167
@should_install_shards = install_shards
165168
@colorize = colorize
169+
170+
if File.exists?(@success_wav) && File.exists?(@error_wav)
171+
{% if flag?(:linux) %}
172+
@sound_player = `which aplay 2>/dev/null`.chomp
173+
{% elsif flag(:darwin) %}
174+
@sound_player = `which afplay 2>/dev/null`.chomp
175+
{% end %}
176+
end
166177
end
167178

168179
private def stdout(str : String)
@@ -214,9 +225,13 @@ module Sentry
214225
if build_result && build_result.success?
215226
@app_built = true
216227
create_app_process()
228+
`#{@sound_player} #{@success_wav} 2>/dev/null` unless @sound_player.blank?
217229
elsif !@app_built # if build fails on first time compiling, then exit
218230
stdout "🤖 Compile time errors detected. SentryBot shutting down..."
231+
`#{@sound_player} #{@error_wav} 2>/dev/null` unless @sound_player.blank?
219232
exit 1
233+
else
234+
`#{@sound_player} #{@error_wav} 2>/dev/null` unless @sound_player.blank?
220235
end
221236
end
222237

src/sounds/drip.wav

27.6 KB
Binary file not shown.

src/sounds/error.wav

43.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)