Skip to content

Instantly share code, notes, and snippets.

@googya
Created November 8, 2019 04:46
Show Gist options
  • Save googya/7b066f83b8915e53d89e0899ba739762 to your computer and use it in GitHub Desktop.
Save googya/7b066f83b8915e53d89e0899ba739762 to your computer and use it in GitHub Desktop.

Revisions

  1. googya created this gist Nov 8, 2019.
    20 changes: 20 additions & 0 deletions cocoa_alert.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #!/usr/bin/env ruby

    require 'cocoa'

    Cocoa::NSAutoreleasePool.new

    app = Cocoa::NSApplication.sharedApplication
    app.setActivationPolicy Cocoa::NSApplicationActivationPolicyRegular
    app.activateIgnoringOtherApps true

    alert = Cocoa::NSAlert.alloc.init.autorelease
    i = ARGV[0]&.to_i || 3
    wait_time = i * 60

    sleep wait_time

    msg = ARGV[1] || "Tell me what do you want to show, man"

    alert.setMessageText msg
    alert.runModal