# Input without blocking

**URL:** <https://rubytalk.org/t/input-without-blocking/26135>\
**Category:** ruby-talk\
**Created:** [27 March 2006 02:52 UTC](https://rubytalk.org/t/input-without-blocking/26135 "2006-03-27T02:52:10Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![Alpha\_Chen](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@Alpha\_Chen](https://rubytalk.org/u/Alpha_Chen)\
**Post date:** [28 March 2006 16:52 UTC](https://rubytalk.org/t/input-without-blocking/26135/21 "2006-03-28T16:52:35Z")

</div>

You could always try RubyCocoa. From the main page ([http://rubycocoa.sourceforge.net/doc/\](http://rubycocoa.sourceforge.net/doc/%5C)):

The next script plays all the system sounds.

require 'osx/cocoa'  
snd\_files =`ls /System/Library/Sounds/*.aiff`.split  
snd\_files.each do |path|  
&nbsp;&nbsp;&nbsp;snd = OSX::NSSound.alloc.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;initWithContentsOfFile\_byReference (path, true)  
&nbsp;&nbsp;&nbsp;snd.play  
&nbsp;&nbsp;&nbsp;sleep 0.5  
end

Alpha Chen  
0xCDE1AD58 on keyserver.net

> **···**
>
> On Mar 28, 2006, at 11:21 AM, Ernest Obusek wrote:
> 
> > I wrote a little timer application and I would like it to play a sound when the timer has counted down to 0.

---

<div class="post-metadata">

**Author:** ![Chris\_Alfeld](https://avatars.discourse-cdn.com/v4/letter/c/ce73a5/32.png) [@Chris\_Alfeld](https://rubytalk.org/u/Chris_Alfeld)\
**Post date:** [28 March 2006 16:55 UTC](https://rubytalk.org/t/input-without-blocking/26135/22 "2006-03-28T16:55:05Z")

</div>

exec "osascript -e 'beep 1'"

Or, better yet, get ahold of osx/aeosa and use those bindings.

---

<div class="post-metadata">

**Author:** ![Ernest\_Obusek](https://avatars.discourse-cdn.com/v4/letter/e/c68b51/32.png) [@Ernest\_Obusek](https://rubytalk.org/u/Ernest_Obusek)\
**Post date:** [28 March 2006 20:05 UTC](https://rubytalk.org/t/input-without-blocking/26135/23 "2006-03-28T20:05:28Z")

</div>

This is awesome! Thank you!

> **···**
>
> On Mar 28, 2006, at 11:52 AM, Alpha Chen wrote:
> 
> > -----BEGIN PGP SIGNED MESSAGE-----  
> > Hash: SHA1
> > 
> > On Mar 28, 2006, at 11:21 AM, Ernest Obusek wrote:
> > 
> > > I wrote a little timer application and I would like it to play a sound when the timer has counted down to 0.
> > 
> > You could always try RubyCocoa. From the main page ([http://rubycocoa.sourceforge.net/doc/\](http://rubycocoa.sourceforge.net/doc/%5C)):
> > 
> > The next script plays all the system sounds.
> > 
> > require 'osx/cocoa'  
> > snd\_files =`ls /System/Library/Sounds/*.aiff`.split  
> > snd\_files.each do |path|  
> > &nbsp;&nbsp;snd = OSX::NSSound.alloc.  
> > &nbsp;&nbsp;&nbsp;&nbsp;initWithContentsOfFile\_byReference (path, true)  
> > &nbsp;&nbsp;snd.play  
> > &nbsp;&nbsp;sleep 0.5  
> > end
> > 
> > Alpha Chen  
> > 0xCDE1AD58 on keyserver.net
> > 
> > -----BEGIN PGP SIGNATURE-----  
> > Version: GnuPG v1.4.1 (Darwin)
> > 
> > iD8DBQFEKWnCTm5GrM3hrVgRAj3zAJ4tiRkOE4YgVoQQYP3f5opN7yjgmACgmpSK  
> > dRXzk95XsgMd4kJvuoHq+WY=  
> > =CMM9  
> > -----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![brian\_yahn](https://avatars.discourse-cdn.com/v4/letter/b/65b543/32.png) [@brian\_yahn](https://rubytalk.org/u/brian_yahn)\
**Post date:** [28 March 2006 19:42 UTC](https://rubytalk.org/t/input-without-blocking/26135/24 "2006-03-28T19:42:26Z")

</div>

Chris Alfeld wrote:

> exec "osascript -e 'beep 1'"
> 
> Or, better yet, get ahold of osx/aeosa and use those bindings.

cin \>\> blocks. cin is basically the same thing as gets. I guess I will  
just use a thread, but it seems kind of pointless to make the processor  
have to schedule just for input.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Logan\_Capaldo](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@Logan\_Capaldo](https://rubytalk.org/u/Logan_Capaldo)\
**Post date:** [29 March 2006 04:25 UTC](https://rubytalk.org/t/input-without-blocking/26135/25 "2006-03-29T04:25:18Z")

</div>

I hope you never want to return after beeping

> **···**
>
> On Mar 28, 2006, at 11:55 AM, Chris Alfeld wrote:
> 
> > exec "osascript -e 'beep 1'"

---

<div class="post-metadata">

**Author:** ![Chris\_Alfeld](https://avatars.discourse-cdn.com/v4/letter/c/ce73a5/32.png) [@Chris\_Alfeld](https://rubytalk.org/u/Chris_Alfeld)\
**Post date:** [29 March 2006 04:47 UTC](https://rubytalk.org/t/input-without-blocking/26135/26 "2006-03-29T04:47:39Z")

</div>

It isn't so much that I never want to return as that I want to become  
one with the osascript and exit after beeping =)

My bad, meant 'system' not 'exec'; too much tcl in my past.

> **···**
>
> On 3/28/06, Logan Capaldo \<logancapaldo@gmail.com\> wrote:
> 
> > On Mar 28, 2006, at 11:55 AM, Chris Alfeld wrote:
> > 
> > \> exec "osascript -e 'beep 1'"
> > 
> > I hope you never want to return after beeping

[Previous page](https://rubytalk.org/t/input-without-blocking/26135.md?page=1)
