Skip to content

Commit

Permalink
Add sound support for linux/macOS when build success or failed.
Browse files Browse the repository at this point in the history
  • Loading branch information
zw963 committed Aug 8, 2022
1 parent a994dc8 commit c92105d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/sentry.cr
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ module Sentry
property display_name : String
property should_build = true
property files = [] of String
@sound_player : String = ""

def initialize(
@display_name : String,
Expand All @@ -163,6 +164,12 @@ module Sentry
@app_built = false
@should_install_shards = install_shards
@colorize = colorize

{% if flag?(:linux) %}
@sound_player = `which aplay 2>/dev/null`.chomp
{% elsif flag(:darwin) %}
@sound_player = `which afplay 2>/dev/null`.chomp
{% end %}
end

private def stdout(str : String)
Expand Down Expand Up @@ -191,6 +198,7 @@ module Sentry
app_process.signal(:kill)
app_process.wait
end
`#{@sound_player} #{__DIR__}/sounds/drip.wav` unless @sound_player.blank?
end

stdout "🤖 starting #{display_name}..."
Expand All @@ -217,6 +225,8 @@ module Sentry
elsif !@app_built # if build fails on first time compiling, then exit
stdout "🤖 Compile time errors detected. SentryBot shutting down..."
exit 1
else
`#{@sound_player} #{__DIR__}/sounds/error.wav` unless @sound_player.blank?
end
end

Expand Down
Binary file added src/sounds/drip.wav
Binary file not shown.
Binary file added src/sounds/error.wav
Binary file not shown.

0 comments on commit c92105d

Please sign in to comment.