-
Notifications
You must be signed in to change notification settings - Fork 19
/
execute.php
32 lines (28 loc) · 885 Bytes
/
execute.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
$dirname = dirname(__FILE__);
include $dirname . '/autoload.php';
include $dirname . '/shared/commands.php';
include $dirname . '/shared/query.php';
$app_dir = $dirname . '/applescripts/';
$query = trim(str_replace($key, '', $query));
if (array_key_exists($key, $commands)) {
if (isset($commands[$key]['bash'])) {
$command = $commands[$key]['bash'];
}
else {
$command = str_replace('{query}', $query, $commands[$key]['command']);
if (stristr($command, '.scpt')) {
$command = 'q=' . $query . ' osascript "' . $app_dir . $command . '"';
}
else {
$command = 'osascript -e \'tell application "Spotify"' . "\n" . $command . "\n" . 'end tell\'';
}
}
$output = trim(shell_exec($command));
if (! empty($output)) {
print $output;
}
}
else {
print "Command not found.";
}