siriproxy-appcontroller 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/lib/app_brain.rb +30 -0
- data/lib/siriproxy-appcontroller.rb +88 -0
- data/siriproxy-appcontroller.gemspec +19 -0
- metadata +46 -25
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/app_brain.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
class AppBrain
|
2
|
+
def initialize()
|
3
|
+
# Put init stuff here.
|
4
|
+
end
|
5
|
+
|
6
|
+
def appstatus?(app)
|
7
|
+
isrunning = `/usr/bin/killall -s "#{app}"`
|
8
|
+
if (isrunning =~ /kill/)
|
9
|
+
return true
|
10
|
+
else
|
11
|
+
return false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def startapp?(app)
|
16
|
+
if (appstatus?(app))
|
17
|
+
return true
|
18
|
+
else
|
19
|
+
`/usr/bin/open -a "#{app}"`
|
20
|
+
return appstatus?(app)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def stopapp?(app)
|
25
|
+
if (appstatus?(app))
|
26
|
+
status = `/usr/bin/killall "#{app}"`
|
27
|
+
end
|
28
|
+
return appstatus?(app)
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'cora'
|
2
|
+
require 'siri_objects'
|
3
|
+
require 'app_brain'
|
4
|
+
|
5
|
+
|
6
|
+
class SiriProxy::Plugin::AppController < SiriProxy::Plugin
|
7
|
+
def initialize(config)
|
8
|
+
@app_ctl = AppBrain.new()
|
9
|
+
end
|
10
|
+
# Spoken name to real application name translation
|
11
|
+
def spoketoreal(spoken)
|
12
|
+
case
|
13
|
+
when (spoken =~ /i[Tt]unes/)
|
14
|
+
realapp = "iTunes"
|
15
|
+
when (spoken =~ /[Pp]lex/)
|
16
|
+
realapp = "Plex"
|
17
|
+
when (spoken =~ /[Ww]eb[Cc]am/)
|
18
|
+
realapp = "iCamSource"
|
19
|
+
else
|
20
|
+
realapp = "unknown"
|
21
|
+
end
|
22
|
+
return realapp
|
23
|
+
end
|
24
|
+
|
25
|
+
## App Controller high level
|
26
|
+
listen_for /applications .* control/i do
|
27
|
+
say "I can start, stop and give you status on itunes, plex and your webcam"
|
28
|
+
request_completed
|
29
|
+
end
|
30
|
+
|
31
|
+
## iTunes status/up/down
|
32
|
+
listen_for /status of (.*)/i do |spokenapp|
|
33
|
+
app = spoketoreal(spokenapp)
|
34
|
+
if (app == "unknown")
|
35
|
+
say "I haven't been programmed to manage #{spokenapp}."
|
36
|
+
else
|
37
|
+
if (@app_ctl.appstatus?(app))
|
38
|
+
say "#{spokenapp} is up"
|
39
|
+
else
|
40
|
+
say "#{spokenapp} is down"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
request_completed
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
listen_for /start (.*)/i do |spokenapp|
|
48
|
+
app = spoketoreal(spokenapp)
|
49
|
+
if (app == "unknown")
|
50
|
+
say "I'm sorry, I don't know how to start #{spokenapp}."
|
51
|
+
else
|
52
|
+
if (@app_ctl.appstatus?(app))
|
53
|
+
say "#{spokenapp} is already running"
|
54
|
+
request_completed
|
55
|
+
else
|
56
|
+
@app_ctl.startapp?(app)
|
57
|
+
sleep 5
|
58
|
+
end
|
59
|
+
if (@app_ctl.appstatus?(app))
|
60
|
+
say "#{spokenapp} has been started"
|
61
|
+
else
|
62
|
+
say "I'm sorry, I was not able to start #{spokenapp}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
request_completed
|
66
|
+
end
|
67
|
+
|
68
|
+
listen_for /stop (.*)/i do |spokenapp|
|
69
|
+
app = spoketoreal(spokenapp)
|
70
|
+
if (app == "unknown")
|
71
|
+
say "I'm sorry, I don't know how to stop #{spokenapp}."
|
72
|
+
else
|
73
|
+
if (@app_ctl.appstatus?(app))
|
74
|
+
@app_ctl.stopapp?(app)
|
75
|
+
sleep 5
|
76
|
+
unless (@app_ctl.appstatus?(app))
|
77
|
+
say "#{spokenapp} has been stopped"
|
78
|
+
request_completed
|
79
|
+
else
|
80
|
+
say "I'm sorry, I was not able to stop #{spokenapp}"
|
81
|
+
end
|
82
|
+
else
|
83
|
+
say "#{spokenapp} is not running"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
request_completed
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "siriproxy-appcontroller"
|
6
|
+
s.version = "0.0.2"
|
7
|
+
s.authors = ["rckcrlr"]
|
8
|
+
s.email = ["rckcrlr@gmail.com"]
|
9
|
+
s.homepage = ""
|
10
|
+
s.summary = %q{App Controller for OSX}
|
11
|
+
s.description = %q{This plugin lets you start/stop and get status of Mac OSX apps through Siri commands}
|
12
|
+
|
13
|
+
s.rubyforge_project = "siriproxy-appcontroller"
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
end
|
metadata
CHANGED
@@ -1,46 +1,67 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: siriproxy-appcontroller
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
6
10
|
platform: ruby
|
7
|
-
authors:
|
11
|
+
authors:
|
8
12
|
- rckcrlr
|
9
13
|
autorequire:
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
|
-
|
16
|
+
|
17
|
+
date: 2011-12-04 00:00:00 -08:00
|
18
|
+
default_executable:
|
13
19
|
dependencies: []
|
14
|
-
|
15
|
-
|
16
|
-
email:
|
20
|
+
|
21
|
+
description: This plugin lets you start/stop and get status of Mac OSX apps through Siri commands
|
22
|
+
email:
|
17
23
|
- rckcrlr@gmail.com
|
18
24
|
executables: []
|
25
|
+
|
19
26
|
extensions: []
|
27
|
+
|
20
28
|
extra_rdoc_files: []
|
21
|
-
|
22
|
-
|
29
|
+
|
30
|
+
files:
|
31
|
+
- Gemfile
|
32
|
+
- Rakefile
|
33
|
+
- lib/app_brain.rb
|
34
|
+
- lib/siriproxy-appcontroller.rb
|
35
|
+
- siriproxy-appcontroller.gemspec
|
36
|
+
has_rdoc: true
|
37
|
+
homepage: ""
|
23
38
|
licenses: []
|
39
|
+
|
24
40
|
post_install_message:
|
25
41
|
rdoc_options: []
|
26
|
-
|
42
|
+
|
43
|
+
require_paths:
|
27
44
|
- lib
|
28
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
requirements:
|
37
|
-
- -
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
segments:
|
50
|
+
- 0
|
51
|
+
version: "0"
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
40
59
|
requirements: []
|
60
|
+
|
41
61
|
rubyforge_project: siriproxy-appcontroller
|
42
|
-
rubygems_version: 1.
|
62
|
+
rubygems_version: 1.3.6
|
43
63
|
signing_key:
|
44
64
|
specification_version: 3
|
45
65
|
summary: App Controller for OSX
|
46
66
|
test_files: []
|
67
|
+
|