add alfred plugins
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
@@ -0,0 +1,119 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>bundleid</key>
|
||||
<string>jdfwarrior.getip</string>
|
||||
<key>connections</key>
|
||||
<dict>
|
||||
<key>4DE38804-DD3A-4619-B68A-D9290EC54602</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>B21F5F58-454A-4396-A924-15452A297612</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>createdby</key>
|
||||
<string>David Ferguson</string>
|
||||
<key>description</key>
|
||||
<string>What is my IP address?</string>
|
||||
<key>disabled</key>
|
||||
<false/>
|
||||
<key>name</key>
|
||||
<string>IP Address v1.2.0</string>
|
||||
<key>objects</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>autopaste</key>
|
||||
<true/>
|
||||
<key>clipboardtext</key>
|
||||
<string>{query}</string>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.output.clipboard</string>
|
||||
<key>uid</key>
|
||||
<string>B21F5F58-454A-4396-A924-15452A297612</string>
|
||||
<key>version</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>argumenttype</key>
|
||||
<integer>2</integer>
|
||||
<key>escaping</key>
|
||||
<integer>63</integer>
|
||||
<key>keyword</key>
|
||||
<string>ip</string>
|
||||
<key>queuedelaycustom</key>
|
||||
<integer>1</integer>
|
||||
<key>queuedelayimmediatelyinitially</key>
|
||||
<false/>
|
||||
<key>queuedelaymode</key>
|
||||
<integer>0</integer>
|
||||
<key>queuemode</key>
|
||||
<integer>1</integer>
|
||||
<key>runningsubtext</key>
|
||||
<string>Reading ip address</string>
|
||||
<key>script</key>
|
||||
<string>LOCAL=$(ifconfig | grep -A 1 "en" | grep broadcast | cut -d " " -f 2 | tr "\\n" " ")
|
||||
EXTERNAL=$(curl --silent http://icanhazip.com)
|
||||
|
||||
cat<<EOB
|
||||
<?xml version="1.0"?>
|
||||
<items>
|
||||
<item uid="localip" arg="$LOCAL">
|
||||
<title>Local IP: $LOCAL</title>
|
||||
<subtitle>Press Enter to paste, or Cmd+C to copy</subtitle>
|
||||
<icon>icon.png</icon>
|
||||
</item>
|
||||
<item uid="externalip" arg="$EXTERNAL">
|
||||
<title>External IP: $EXTERNAL</title>
|
||||
<subtitle>Press Enter to paste, or Cmd+C to copy</subtitle>
|
||||
<icon>icon.png</icon>
|
||||
</item>
|
||||
</items>
|
||||
EOB</string>
|
||||
<key>subtext</key>
|
||||
<string>Get your local and external IP address</string>
|
||||
<key>title</key>
|
||||
<string>Get IP Address</string>
|
||||
<key>type</key>
|
||||
<integer>5</integer>
|
||||
<key>withspace</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.input.scriptfilter</string>
|
||||
<key>uid</key>
|
||||
<string>4DE38804-DD3A-4619-B68A-D9290EC54602</string>
|
||||
<key>version</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>readme</key>
|
||||
<string>Updated by Andreas Stokholm to be able to handle multiple local IP-addresses.</string>
|
||||
<key>uidata</key>
|
||||
<dict>
|
||||
<key>4DE38804-DD3A-4619-B68A-D9290EC54602</key>
|
||||
<dict>
|
||||
<key>ypos</key>
|
||||
<real>10</real>
|
||||
</dict>
|
||||
<key>B21F5F58-454A-4396-A924-15452A297612</key>
|
||||
<dict>
|
||||
<key>ypos</key>
|
||||
<real>10</real>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>webaddress</key>
|
||||
<string>jdfwarrior.tumblr.com</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
//header ("Content-Type:text/xml");
|
||||
//syslog(LOG_ERR, "message to send to log");
|
||||
|
||||
//$query = "%5D & > \u0058"; // URL,
|
||||
// ****************
|
||||
|
||||
require_once('workflows.php');
|
||||
|
||||
$w = new Workflows();
|
||||
if (!isset($query)) {
|
||||
$query = $argv[1];
|
||||
}
|
||||
|
||||
function force_utf8_safe($str) {
|
||||
$res = mb_convert_encoding($str, "UTF-8", "UTF-8" ); // replace invalid characters with ?
|
||||
$res = preg_replace('/\p{Cc}+/u', '?', $res); // replace control characters with ?
|
||||
return $res;
|
||||
}
|
||||
|
||||
function prepare_output($items) {
|
||||
$res = [];
|
||||
foreach ($items as $key => $value) {
|
||||
// Make UTF-8 safe results.
|
||||
$safe_value = force_utf8_safe($value);
|
||||
if ($value != $safe_value) {
|
||||
$key .= ' (Invalid characters replaced with ?)';
|
||||
$value = $safe_value;
|
||||
}
|
||||
$res[$key] = $value;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
function replace_unicode_escape_sequence($match) {
|
||||
return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
|
||||
}
|
||||
|
||||
function html_decode($str) {
|
||||
return str_replace(array("<", ">", '&', ''', '"','<', '>'), array("<", ">",'&','\'','"','<','>'), htmlspecialchars_decode($str, ENT_NOQUOTES));
|
||||
}
|
||||
|
||||
if (0) {
|
||||
echo "".$query."\n";
|
||||
echo "urlencode = ".urldecode($query)."\n";
|
||||
echo "utf8_encode = ".utf8_decode($query)."\n";
|
||||
echo "unicode = ".preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $query)."\n";
|
||||
echo "htmlentities = ".html_entity_decode($query)."\n";
|
||||
echo "base64_encode = ".base64_decode($query)."\n";
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
$decodes = array();
|
||||
// url
|
||||
$url_decode = urldecode($query);
|
||||
if ($url_decode != $query) $decodes["URL Decoded"] = $url_decode;
|
||||
|
||||
// unicode
|
||||
$unicode_decode = preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $query);
|
||||
if ($unicode_decode != $query) $decodes["Unicode Decoded"] = $unicode_decode;
|
||||
|
||||
// HTML
|
||||
$html_decode = html_entity_decode($query, ENT_QUOTES, 'UTF-8');
|
||||
if ($html_decode != $query) $decodes["HTML Decoded"] = $html_decode;
|
||||
|
||||
// base64
|
||||
$base64_decode = base64_decode($query, true);
|
||||
if ($base64_decode && $base64_decode != $query) { $decodes["base64 Decoded"] = $base64_decode; }
|
||||
|
||||
//$dencodes["UTF-8 Decoded"] = utf8_decode($query);
|
||||
|
||||
$decodes = prepare_output($decodes);
|
||||
|
||||
foreach($decodes as $key => $value) {
|
||||
$w->result( $key, $value, $value, $key, 'icon.png', 'yes' );
|
||||
}
|
||||
|
||||
if ( count( $w->results() ) == 0 ) {
|
||||
$w->result( 'decode', $query, 'Nothing useful resulted', 'The decoded strings were the same as your query', 'icon.png', 'yes' );
|
||||
}
|
||||
|
||||
echo $w->toxml();
|
||||
// ****************
|
||||
?>
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
//header ("Content-Type:text/xml");
|
||||
//syslog(LOG_ERR, "message to send to log");
|
||||
|
||||
// alfred encode.php test\"\'<é
|
||||
|
||||
// ****************
|
||||
|
||||
function str_split_unicode($str, $l = 0) {
|
||||
if ($l > 0) {
|
||||
$ret = array();
|
||||
$len = mb_strlen($str, "UTF-8");
|
||||
for ($i = 0; $i < $len; $i += $l) {
|
||||
$ret[] = mb_substr($str, $i, $l, "UTF-8");
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
return preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
|
||||
require_once('workflows.php');
|
||||
|
||||
$w = new Workflows();
|
||||
if (!isset($query)) {
|
||||
$query = $argv[1];
|
||||
}
|
||||
|
||||
function force_utf8_safe($str) {
|
||||
$res = mb_convert_encoding($str, "UTF-8", "UTF-8" ); // replace invalid characters with ?
|
||||
$res = preg_replace('/\p{Cc}+/u', '?', $res); // replace control characters with ?
|
||||
return $res;
|
||||
}
|
||||
|
||||
function prepare_output($items) {
|
||||
$res = [];
|
||||
foreach ($items as $key => $value) {
|
||||
// Make UTF-8 safe results.
|
||||
$safe_value = force_utf8_safe($value);
|
||||
if ($value != $safe_value) {
|
||||
$key .= ' (Invalid characters replaced with ?)';
|
||||
$value = $safe_value;
|
||||
}
|
||||
$res[$key] = $value;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
$chars = str_split_unicode($query);
|
||||
|
||||
if (0) {
|
||||
echo "".$query." - ".implode("", $chars)."\n";
|
||||
echo "urlencode = ".urlencode($query)."\n";
|
||||
echo "utf8_encode = ".utf8_encode($query)."\n";
|
||||
echo "htmlentities = ".htmlentities($query, ENT_QUOTES, 'UTF-8', false)."\n";
|
||||
$html_encode = '';
|
||||
$table = get_html_translation_table(HTML_ENTITIES);
|
||||
for ($i = 0, $l = sizeof($chars); $i < $l; $i++) {
|
||||
echo $chars[$i]." -> ".$table[$chars[$i]]."\n";
|
||||
$html_encode .= $table[$chars[$i]] ? $table[$chars[$i]] : $chars[$i];
|
||||
}
|
||||
$html_encode = htmlentities($html_encode, ENT_QUOTES, 'UTF-8', false);
|
||||
echo " = ".$html_encode."\n";
|
||||
echo "base64_encode = ".base64_encode($query)."\n";
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
$encodes = array();
|
||||
|
||||
// url
|
||||
$url_encode = urlencode($query);
|
||||
if ($url_encode != $query) $encodes["URL Encoded"] = $url_encode;
|
||||
|
||||
// HTML
|
||||
/*$html_encode = '';
|
||||
$table = get_html_translation_table(HTML_ENTITIES);
|
||||
for ($i = 0, $l = sizeof($chars); $i < $l; $i++) {
|
||||
$html_encode .= $table[$chars[$i]] ? $table[$chars[$i]] : $chars[$i];
|
||||
}
|
||||
$html_encode = htmlentities($html_encode, ENT_QUOTES, 'UTF-8', false);*/
|
||||
$html_encode = htmlentities($query, ENT_QUOTES, 'UTF-8');
|
||||
if ($html_encode != $query) $encodes["HTML Encoded"] = $html_encode;
|
||||
|
||||
// base64
|
||||
$base64_encode = base64_encode($query);
|
||||
if ($base64_encode != $query) $encodes["base64 Encoded"] = $base64_encode;
|
||||
|
||||
|
||||
$encodes = prepare_output($encodes);
|
||||
|
||||
foreach($encodes as $key => $value) {
|
||||
$w->result( $key, $value, $value, $key, 'icon.png', 'yes' );
|
||||
}
|
||||
|
||||
if ( count( $w->results() ) == 0 ) {
|
||||
$w->result( 'encode', $query, 'Nothing useful resulted', 'The encoded strings were the same as your query', 'icon.png', 'yes' );
|
||||
}
|
||||
|
||||
echo $w->toxml();
|
||||
// ****************
|
||||
?>
|
||||
|
After Width: | Height: | Size: 55 KiB |
@@ -0,0 +1,231 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>bundleid</key>
|
||||
<string>com.farrell.encode-decode.alfredworkflow</string>
|
||||
<key>category</key>
|
||||
<string>Productivity</string>
|
||||
<key>connections</key>
|
||||
<dict>
|
||||
<key>807BFA1D-EAEC-4DB7-B04E-6371C601A9E7</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>72E910A8-F09C-4863-9F54-F60E273C59AB</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>1EB2B864-2602-4BF2-AEE5-80092DCE02FF</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>96A609DD-13FB-44C7-9ADB-F3BC94017A65</key>
|
||||
<array/>
|
||||
<key>D9450D59-0E2F-4E83-9BDD-7EAF0878E5DC</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>72E910A8-F09C-4863-9F54-F60E273C59AB</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>1EB2B864-2602-4BF2-AEE5-80092DCE02FF</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>createdby</key>
|
||||
<string>Will Farrell</string>
|
||||
<key>description</key>
|
||||
<string>Encode/Decode Strings</string>
|
||||
<key>disabled</key>
|
||||
<false/>
|
||||
<key>name</key>
|
||||
<string>Encode / Decode v1.8.0</string>
|
||||
<key>objects</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>action</key>
|
||||
<integer>0</integer>
|
||||
<key>argument</key>
|
||||
<integer>0</integer>
|
||||
<key>leftcursor</key>
|
||||
<false/>
|
||||
<key>modsmode</key>
|
||||
<integer>0</integer>
|
||||
<key>relatedAppsMode</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.trigger.hotkey</string>
|
||||
<key>uid</key>
|
||||
<string>96A609DD-13FB-44C7-9ADB-F3BC94017A65</string>
|
||||
<key>version</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>argumenttype</key>
|
||||
<integer>0</integer>
|
||||
<key>escaping</key>
|
||||
<integer>102</integer>
|
||||
<key>keyword</key>
|
||||
<string>encode</string>
|
||||
<key>queuedelaycustom</key>
|
||||
<integer>1</integer>
|
||||
<key>queuedelayimmediatelyinitially</key>
|
||||
<false/>
|
||||
<key>queuedelaymode</key>
|
||||
<integer>0</integer>
|
||||
<key>queuemode</key>
|
||||
<integer>1</integer>
|
||||
<key>runningsubtext</key>
|
||||
<string>Encoding "{query}"</string>
|
||||
<key>script</key>
|
||||
<string>php encode.php "$(./normalise -form NFC "{query}")"</string>
|
||||
<key>subtext</key>
|
||||
<string>Encode "{query}"</string>
|
||||
<key>title</key>
|
||||
<string>Encode</string>
|
||||
<key>type</key>
|
||||
<integer>0</integer>
|
||||
<key>withspace</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.input.scriptfilter</string>
|
||||
<key>uid</key>
|
||||
<string>807BFA1D-EAEC-4DB7-B04E-6371C601A9E7</string>
|
||||
<key>version</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>autopaste</key>
|
||||
<false/>
|
||||
<key>clipboardtext</key>
|
||||
<string>{query}</string>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.output.clipboard</string>
|
||||
<key>uid</key>
|
||||
<string>72E910A8-F09C-4863-9F54-F60E273C59AB</string>
|
||||
<key>version</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>argumenttype</key>
|
||||
<integer>0</integer>
|
||||
<key>escaping</key>
|
||||
<integer>102</integer>
|
||||
<key>keyword</key>
|
||||
<string>decode</string>
|
||||
<key>queuedelaycustom</key>
|
||||
<integer>1</integer>
|
||||
<key>queuedelayimmediatelyinitially</key>
|
||||
<false/>
|
||||
<key>queuedelaymode</key>
|
||||
<integer>0</integer>
|
||||
<key>queuemode</key>
|
||||
<integer>1</integer>
|
||||
<key>runningsubtext</key>
|
||||
<string>Decoding "{query}"</string>
|
||||
<key>script</key>
|
||||
<string>php decode.php "$(./normalise -form NFC "{query}")"</string>
|
||||
<key>subtext</key>
|
||||
<string>Decode "{query}"</string>
|
||||
<key>title</key>
|
||||
<string>Decode</string>
|
||||
<key>type</key>
|
||||
<integer>0</integer>
|
||||
<key>withspace</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.input.scriptfilter</string>
|
||||
<key>uid</key>
|
||||
<string>D9450D59-0E2F-4E83-9BDD-7EAF0878E5DC</string>
|
||||
<key>version</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>lastpathcomponent</key>
|
||||
<false/>
|
||||
<key>onlyshowifquerypopulated</key>
|
||||
<true/>
|
||||
<key>output</key>
|
||||
<integer>0</integer>
|
||||
<key>removeextension</key>
|
||||
<false/>
|
||||
<key>sticky</key>
|
||||
<false/>
|
||||
<key>text</key>
|
||||
<string>{query}</string>
|
||||
<key>title</key>
|
||||
<string>Added to Clipboard</string>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.output.notification</string>
|
||||
<key>uid</key>
|
||||
<string>1EB2B864-2602-4BF2-AEE5-80092DCE02FF</string>
|
||||
<key>version</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>readme</key>
|
||||
<string></string>
|
||||
<key>uidata</key>
|
||||
<dict>
|
||||
<key>1EB2B864-2602-4BF2-AEE5-80092DCE02FF</key>
|
||||
<dict>
|
||||
<key>ypos</key>
|
||||
<real>140</real>
|
||||
</dict>
|
||||
<key>72E910A8-F09C-4863-9F54-F60E273C59AB</key>
|
||||
<dict>
|
||||
<key>ypos</key>
|
||||
<real>10</real>
|
||||
</dict>
|
||||
<key>807BFA1D-EAEC-4DB7-B04E-6371C601A9E7</key>
|
||||
<dict>
|
||||
<key>ypos</key>
|
||||
<real>10</real>
|
||||
</dict>
|
||||
<key>96A609DD-13FB-44C7-9ADB-F3BC94017A65</key>
|
||||
<dict>
|
||||
<key>ypos</key>
|
||||
<real>10</real>
|
||||
</dict>
|
||||
<key>D9450D59-0E2F-4E83-9BDD-7EAF0878E5DC</key>
|
||||
<dict>
|
||||
<key>ypos</key>
|
||||
<real>140</real>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>webaddress</key>
|
||||
<string>github.com/willfarrell</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"version": 1.8,
|
||||
"remote_json": "https://raw.github.com/willfarrell/alfred-encode-decode-workflow/master/current-version.json"
|
||||
}
|
||||
@@ -0,0 +1,487 @@
|
||||
<?php
|
||||
/**
|
||||
* Name: Workflows
|
||||
* Description: This PHP class object provides several useful functions for retrieving, parsing,
|
||||
* and formatting data to be used with Alfred 2 Workflows.
|
||||
* Author: David Ferguson (@jdfwarrior)
|
||||
* Revised: 2/9/2013
|
||||
* Version: 0.3
|
||||
*/
|
||||
class Workflows {
|
||||
|
||||
private $cache;
|
||||
private $data;
|
||||
private $bundle;
|
||||
private $path;
|
||||
private $home;
|
||||
private $results;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Class constructor function. Intializes all class variables. Accepts one optional parameter
|
||||
* of the workflow bundle id in the case that you want to specify a different bundle id. This
|
||||
* would adjust the output directories for storing data.
|
||||
*
|
||||
* @param $bundleid - optional bundle id if not found automatically
|
||||
* @return none
|
||||
*/
|
||||
function __construct( $bundleid=null )
|
||||
{
|
||||
$this->path = exec('pwd');
|
||||
$this->home = exec('printf $HOME');
|
||||
|
||||
if ( file_exists( 'info.plist' ) ):
|
||||
$this->bundle = $this->get( 'bundleid', 'info.plist' );
|
||||
endif;
|
||||
|
||||
if ( !is_null( $bundleid ) ):
|
||||
$this->bundle = $bundleid;
|
||||
endif;
|
||||
|
||||
$this->cache = $this->home. "/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/".$this->bundle;
|
||||
$this->data = $this->home. "/Library/Application Support/Alfred 2/Workflow Data/".$this->bundle;
|
||||
|
||||
if ( !file_exists( $this->cache ) ):
|
||||
exec("mkdir '".$this->cache."'");
|
||||
endif;
|
||||
|
||||
if ( !file_exists( $this->data ) ):
|
||||
exec("mkdir '".$this->data."'");
|
||||
endif;
|
||||
|
||||
$this->results = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Accepts no parameter and returns the value of the bundle id for the current workflow.
|
||||
* If no value is available, then false is returned.
|
||||
*
|
||||
* @param none
|
||||
* @return false if not available, bundle id value if available.
|
||||
*/
|
||||
public function bundle()
|
||||
{
|
||||
if ( is_null( $this->bundle ) ):
|
||||
return false;
|
||||
else:
|
||||
return $this->bundle;
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Accepts no parameter and returns the value of the path to the cache directory for your
|
||||
* workflow if it is available. Returns false if the value isn't available.
|
||||
*
|
||||
* @param none
|
||||
* @return false if not available, path to the cache directory for your workflow if available.
|
||||
*/
|
||||
public function cache()
|
||||
{
|
||||
if ( is_null( $this->bundle ) ):
|
||||
return false;
|
||||
else:
|
||||
if ( is_null( $this->cache ) ):
|
||||
return false;
|
||||
else:
|
||||
return $this->cache;
|
||||
endif;
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Accepts no parameter and returns the value of the path to the storage directory for your
|
||||
* workflow if it is available. Returns false if the value isn't available.
|
||||
*
|
||||
* @param none
|
||||
* @return false if not available, path to the storage directory for your workflow if available.
|
||||
*/
|
||||
public function data()
|
||||
{
|
||||
if ( is_null( $this->bundle ) ):
|
||||
return false;
|
||||
else:
|
||||
if ( is_null( $this->data ) ):
|
||||
return false;
|
||||
else:
|
||||
return $this->data;
|
||||
endif;
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Accepts no parameter and returns the value of the path to the current directory for your
|
||||
* workflow if it is available. Returns false if the value isn't available.
|
||||
*
|
||||
* @param none
|
||||
* @return false if not available, path to the current directory for your workflow if available.
|
||||
*/
|
||||
public function path()
|
||||
{
|
||||
if ( is_null( $this->path ) ):
|
||||
return false;
|
||||
else:
|
||||
return $this->path;
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Accepts no parameter and returns the value of the home path for the current user
|
||||
* Returns false if the value isn't available.
|
||||
*
|
||||
* @param none
|
||||
* @return false if not available, home path for the current user if available.
|
||||
*/
|
||||
public function home()
|
||||
{
|
||||
if ( is_null( $this->home ) ):
|
||||
return false;
|
||||
else:
|
||||
return $this->home;
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Returns an array of available result items
|
||||
*
|
||||
* @param none
|
||||
* @return array - list of result items
|
||||
*/
|
||||
public function results()
|
||||
{
|
||||
return $this->results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Convert an associative array into XML format
|
||||
*
|
||||
* @param $a - An associative array to convert
|
||||
* @param $format - format of data being passed (json or array), defaults to array
|
||||
* @return - XML string representation of the array
|
||||
*/
|
||||
public function toxml( $a=null, $format='array' ) {
|
||||
|
||||
if ( $format == 'json' ):
|
||||
$a = json_decode( $a, TRUE );
|
||||
endif;
|
||||
|
||||
if ( is_null( $a ) && !empty( $this->results ) ):
|
||||
$a = $this->results;
|
||||
elseif ( is_null( $a ) && empty( $this->results ) ):
|
||||
return false;
|
||||
endif;
|
||||
|
||||
$items = new SimpleXMLElement("<items></items>"); // Create new XML element
|
||||
|
||||
foreach( $a as $b ): // Lop through each object in the array
|
||||
$c = $items->addChild( 'item' ); // Add a new 'item' element for each object
|
||||
$c_keys = array_keys( $b ); // Grab all the keys for that item
|
||||
foreach( $c_keys as $key ): // For each of those keys
|
||||
if ( $key == 'uid' ):
|
||||
$c->addAttribute( 'uid', $b[$key] );
|
||||
elseif ( $key == 'arg' ):
|
||||
$c->addAttribute( 'arg', $b[$key] );
|
||||
elseif ( $key == 'type' ):
|
||||
$c->addAttribute( 'type', $b[$key] );
|
||||
elseif ( $key == 'valid' ):
|
||||
if ( $b[$key] == 'yes' || $b[$key] == 'no' ):
|
||||
$c->addAttribute( 'valid', $b[$key] );
|
||||
endif;
|
||||
elseif ( $key == 'autocomplete' ):
|
||||
$c->addAttribute( 'autocomplete', $b[$key] );
|
||||
elseif ( $key == 'icon' ):
|
||||
if ( substr( $b[$key], 0, 9 ) == 'fileicon:' ):
|
||||
$val = substr( $b[$key], 9 );
|
||||
$c->$key = $val;
|
||||
$c->$key->addAttribute( 'type', 'fileicon' );
|
||||
elseif ( substr( $b[$key], 0, 9 ) == 'filetype:' ):
|
||||
$val = substr( $b[$key], 9 );
|
||||
$c->$key = $val;
|
||||
$c->$key->addAttribute( 'type', 'filetype' );
|
||||
else:
|
||||
$c->$key = $b[$key];
|
||||
endif;
|
||||
else:
|
||||
$c->$key = $b[$key];
|
||||
endif;
|
||||
endforeach;
|
||||
endforeach;
|
||||
|
||||
return $items->asXML(); // Return XML string representation of the array
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Remove all items from an associative array that do not have a value
|
||||
*
|
||||
* @param $a - Associative array
|
||||
* @return bool
|
||||
*/
|
||||
private function empty_filter( $a ) {
|
||||
if ( $a == '' || $a == null ): // if $a is empty or null
|
||||
return false; // return false, else, return true
|
||||
else:
|
||||
return true;
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Save values to a specified plist. If the first parameter is an associative
|
||||
* array, then the second parameter becomes the plist file to save to. If the
|
||||
* first parameter is string, then it is assumed that the first parameter is
|
||||
* the label, the second parameter is the value, and the third parameter is
|
||||
* the plist file to save the data to.
|
||||
*
|
||||
* @param $a - associative array of values to save
|
||||
* @param $b - the value of the setting
|
||||
* @param $c - the plist to save the values into
|
||||
* @return string - execution output
|
||||
*/
|
||||
public function set( $a=null, $b=null, $c=null )
|
||||
{
|
||||
if ( is_array( $a ) ):
|
||||
if ( file_exists( $b ) ):
|
||||
if ( file_exists( $this->path.'/'.$b ) ):
|
||||
$b = $this->path.'/'.$b;
|
||||
endif;
|
||||
elseif ( file_exists( $this->data."/".$b ) ):
|
||||
$b = $this->data."/".$b;
|
||||
elseif ( file_exists( $this->cache."/".$b ) ):
|
||||
$b = $this->cache."/".$b;
|
||||
else:
|
||||
$b = $this->data."/".$b;
|
||||
endif;
|
||||
else:
|
||||
if ( file_exists( $c ) ):
|
||||
if ( file_exists( $this->path.'/'.$c ) ):
|
||||
$c = $this->path.'/'.$c;
|
||||
endif;
|
||||
elseif ( file_exists( $this->data."/".$c ) ):
|
||||
$c = $this->data."/".$c;
|
||||
elseif ( file_exists( $this->cache."/".$c ) ):
|
||||
$c = $this->cache."/".$c;
|
||||
else:
|
||||
$c = $this->data."/".$c;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
if ( is_array( $a ) ):
|
||||
foreach( $a as $k => $v ):
|
||||
exec( 'defaults write "'. $b .'" '. $k .' "'. $v .'"');
|
||||
endforeach;
|
||||
else:
|
||||
exec( 'defaults write "'. $c .'" '. $a .' "'. $b .'"');
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Read a value from the specified plist
|
||||
*
|
||||
* @param $a - the value to read
|
||||
* @param $b - plist to read the values from
|
||||
* @return bool false if not found, string if found
|
||||
*/
|
||||
public function get( $a, $b ) {
|
||||
|
||||
if ( file_exists( $b ) ):
|
||||
if ( file_exists( $this->path.'/'.$b ) ):
|
||||
$b = $this->path.'/'.$b;
|
||||
endif;
|
||||
elseif ( file_exists( $this->data."/".$b ) ):
|
||||
$b = $this->data."/".$b;
|
||||
elseif ( file_exists( $this->cache."/".$b ) ):
|
||||
$b = $this->cache."/".$b;
|
||||
else:
|
||||
return false;
|
||||
endif;
|
||||
|
||||
exec( 'defaults read "'. $b .'" '.$a, $out ); // Execute system call to read plist value
|
||||
|
||||
if ( $out == "" ):
|
||||
return false;
|
||||
endif;
|
||||
|
||||
$out = $out[0];
|
||||
return $out; // Return item value
|
||||
}
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Read data from a remote file/url, essentially a shortcut for curl
|
||||
*
|
||||
* @param $url - URL to request
|
||||
* @param $options - Array of curl options
|
||||
* @return result from curl_exec
|
||||
*/
|
||||
public function request( $url=null, $options=null )
|
||||
{
|
||||
if ( is_null( $url ) ):
|
||||
return false;
|
||||
endif;
|
||||
|
||||
$defaults = array( // Create a list of default curl options
|
||||
CURLOPT_RETURNTRANSFER => true, // Returns the result as a string
|
||||
CURLOPT_URL => $url, // Sets the url to request
|
||||
CURLOPT_FRESH_CONNECT => true
|
||||
);
|
||||
|
||||
if ( $options ):
|
||||
foreach( $options as $k => $v ):
|
||||
$defaults[$k] = $v;
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
array_filter( $defaults, // Filter out empty options from the array
|
||||
array( $this, 'empty_filter' ) );
|
||||
|
||||
$ch = curl_init(); // Init new curl object
|
||||
curl_setopt_array( $ch, $defaults ); // Set curl options
|
||||
$out = curl_exec( $ch ); // Request remote data
|
||||
$err = curl_error( $ch );
|
||||
curl_close( $ch ); // End curl request
|
||||
|
||||
if ( $err ):
|
||||
return $err;
|
||||
else:
|
||||
return $out;
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Allows searching the local hard drive using mdfind
|
||||
*
|
||||
* @param $query - search string
|
||||
* @return array - array of search results
|
||||
*/
|
||||
public function mdfind( $query )
|
||||
{
|
||||
exec('mdfind "'.$query.'"', $results);
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Accepts data and a string file name to store data to local file as cache
|
||||
*
|
||||
* @param array - data to save to file
|
||||
* @param file - filename to write the cache data to
|
||||
* @return none
|
||||
*/
|
||||
public function write( $a, $b )
|
||||
{
|
||||
if ( file_exists( $b ) ):
|
||||
if ( file_exists( $this->path.'/'.$b ) ):
|
||||
$b = $this->path.'/'.$b;
|
||||
endif;
|
||||
elseif ( file_exists( $this->data."/".$b ) ):
|
||||
$b = $this->data."/".$b;
|
||||
elseif ( file_exists( $this->cache."/".$b ) ):
|
||||
$b = $this->cache."/".$b;
|
||||
else:
|
||||
$b = $this->data."/".$b;
|
||||
endif;
|
||||
|
||||
if ( is_array( $a ) ):
|
||||
$a = json_encode( $a );
|
||||
file_put_contents( $b, $a );
|
||||
return true;
|
||||
elseif ( is_string( $a ) ):
|
||||
file_put_contents( $b, $a );
|
||||
return true;
|
||||
else:
|
||||
return false;
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Returns data from a local cache file
|
||||
*
|
||||
* @param file - filename to read the cache data from
|
||||
* @return false if the file cannot be found, the file data if found. If the file
|
||||
* format is json encoded, then a json object is returned.
|
||||
*/
|
||||
public function read( $a )
|
||||
{
|
||||
if ( file_exists( $a ) ):
|
||||
if ( file_exists( $this->path.'/'.$a ) ):
|
||||
$a = $this->path.'/'.$a;
|
||||
endif;
|
||||
elseif ( file_exists( $this->data."/".$a ) ):
|
||||
$a = $this->data."/".$a;
|
||||
elseif ( file_exists( $this->cache."/".$a ) ):
|
||||
$a = $this->cache."/".$a;
|
||||
else:
|
||||
return false;
|
||||
endif;
|
||||
|
||||
$out = file_get_contents( $a );
|
||||
if ( !is_null( json_decode( $out ) ) ):
|
||||
$out = json_decode( $out );
|
||||
endif;
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function filetime( $a )
|
||||
{
|
||||
if ( file_exists( $a ) ):
|
||||
if ( file_exists( $this->path.'/'.$a ) ):
|
||||
return filemtime($this->path.'/'.$a);
|
||||
endif;
|
||||
elseif ( file_exists( $this->data."/".$a ) ):
|
||||
return filemtime($this->data.'/'.$a);
|
||||
elseif ( file_exists( $this->cache."/".$a ) ):
|
||||
return filemtime($this->cache.'/'.$a);
|
||||
endif;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Helper function that just makes it easier to pass values into a function
|
||||
* and create an array result to be passed back to Alfred
|
||||
*
|
||||
* @param $uid - the uid of the result, should be unique
|
||||
* @param $arg - the argument that will be passed on
|
||||
* @param $title - The title of the result item
|
||||
* @param $sub - The subtitle text for the result item
|
||||
* @param $icon - the icon to use for the result item
|
||||
* @param $valid - sets whether the result item can be actioned
|
||||
* @param $auto - the autocomplete value for the result item
|
||||
* @return array - array item to be passed back to Alfred
|
||||
*/
|
||||
public function result( $uid, $arg, $title, $sub, $icon, $valid='yes', $auto=null, $type=null )
|
||||
{
|
||||
$temp = array(
|
||||
'uid' => $uid,
|
||||
'arg' => $arg,
|
||||
'title' => $title,
|
||||
'subtitle' => $sub,
|
||||
'icon' => $icon,
|
||||
'valid' => $valid,
|
||||
'autocomplete' => $auto,
|
||||
'type' => $type
|
||||
);
|
||||
|
||||
if ( is_null( $type ) ):
|
||||
unset( $temp['type'] );
|
||||
endif;
|
||||
|
||||
array_push( $this->results, $temp );
|
||||
|
||||
return $temp;
|
||||
}
|
||||
|
||||
}
|
||||
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 7.7 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 30 KiB |
@@ -0,0 +1,119 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>bundleid</key>
|
||||
<string>dk.aiyo.VirtualBoxControl</string>
|
||||
<key>connections</key>
|
||||
<dict>
|
||||
<key>86FD7F90-FA0B-4C1C-B13B-346309B0E5D3</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>destinationuid</key>
|
||||
<string>301581C1-995D-4A74-90CD-8B3D929EBF23</string>
|
||||
<key>modifiers</key>
|
||||
<integer>0</integer>
|
||||
<key>modifiersubtext</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>createdby</key>
|
||||
<string>Jonas Eriksen</string>
|
||||
<key>description</key>
|
||||
<string>Control Your VirtualBox VMs From Alfred.app</string>
|
||||
<key>disabled</key>
|
||||
<false/>
|
||||
<key>name</key>
|
||||
<string>VirtualBox v2.0.1</string>
|
||||
<key>objects</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>concurrently</key>
|
||||
<false/>
|
||||
<key>escaping</key>
|
||||
<integer>62</integer>
|
||||
<key>script</key>
|
||||
<string>if [[ ":$PATH:" != *"usr/local/bin"* ]]; then
|
||||
PATH=$PATH:/usr/local/bin
|
||||
fi
|
||||
|
||||
VBoxManage {query}</string>
|
||||
<key>type</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.action.script</string>
|
||||
<key>uid</key>
|
||||
<string>301581C1-995D-4A74-90CD-8B3D929EBF23</string>
|
||||
<key>version</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>config</key>
|
||||
<dict>
|
||||
<key>argumenttype</key>
|
||||
<integer>1</integer>
|
||||
<key>escaping</key>
|
||||
<integer>62</integer>
|
||||
<key>keyword</key>
|
||||
<string>vm</string>
|
||||
<key>queuedelaycustom</key>
|
||||
<integer>1</integer>
|
||||
<key>queuedelayimmediatelyinitially</key>
|
||||
<false/>
|
||||
<key>queuedelaymode</key>
|
||||
<integer>0</integer>
|
||||
<key>queuemode</key>
|
||||
<integer>1</integer>
|
||||
<key>runningsubtext</key>
|
||||
<string>Searching for Virtual Machines...</string>
|
||||
<key>script</key>
|
||||
<string>sh virtualbox_control.sh "{query}"</string>
|
||||
<key>subtext</key>
|
||||
<string>Start, Stop, Pause, Resume, Reset and more</string>
|
||||
<key>title</key>
|
||||
<string>VirtualBox Control</string>
|
||||
<key>type</key>
|
||||
<integer>0</integer>
|
||||
<key>withspace</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>type</key>
|
||||
<string>alfred.workflow.input.scriptfilter</string>
|
||||
<key>uid</key>
|
||||
<string>86FD7F90-FA0B-4C1C-B13B-346309B0E5D3</string>
|
||||
<key>version</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>readme</key>
|
||||
<string>Control your VirualBox VMs from Alfred.
|
||||
|
||||
Surported commands are:
|
||||
- Start
|
||||
- Power Off
|
||||
- ACPI Shutdown
|
||||
- Reset
|
||||
- Pause / Resume
|
||||
- Save State
|
||||
- Take a Screen Shot</string>
|
||||
<key>uidata</key>
|
||||
<dict>
|
||||
<key>301581C1-995D-4A74-90CD-8B3D929EBF23</key>
|
||||
<dict>
|
||||
<key>ypos</key>
|
||||
<real>10</real>
|
||||
</dict>
|
||||
<key>86FD7F90-FA0B-4C1C-B13B-346309B0E5D3</key>
|
||||
<dict>
|
||||
<key>ypos</key>
|
||||
<real>10</real>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>webaddress</key>
|
||||
<string>www.aiyo.dk/alfredapp/v2</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 13 KiB |
@@ -0,0 +1,264 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ ":$PATH:" != *"usr/local/bin"* ]]; then
|
||||
PATH=$PATH:/usr/local/bin
|
||||
fi
|
||||
|
||||
function VMicon {
|
||||
# Choose Icon based on OS type
|
||||
case "$1" in
|
||||
Windows*)
|
||||
echo windows
|
||||
;;
|
||||
"Mac OS X"*)
|
||||
echo osx
|
||||
;;
|
||||
OpenBSD*)
|
||||
echo openbsd
|
||||
;;
|
||||
FreeBSD*)
|
||||
echo freebsd
|
||||
;;
|
||||
NetBSD*)
|
||||
echo netbsd
|
||||
;;
|
||||
Ubuntu*)
|
||||
echo ubuntu
|
||||
;;
|
||||
Fedora*)
|
||||
echo fedora
|
||||
;;
|
||||
"Red Hat"*)
|
||||
echo redhat
|
||||
;;
|
||||
openSUSE*)
|
||||
echo suse
|
||||
;;
|
||||
Debian*)
|
||||
echo debian
|
||||
;;
|
||||
Gentoo*|Mandriva*|Turbulinux*|Xandos*|Oracle*|Linux*)
|
||||
echo linux
|
||||
;;
|
||||
*)
|
||||
echo icon
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Case insensitive compare
|
||||
shopt -s nocasematch
|
||||
|
||||
|
||||
# cache list of vms
|
||||
let "TIME=$(date +%s)-10" # keep VMs cache in 10 seconds
|
||||
if [ -z "$1" ] || [ $(stat -f "%m" ~/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow\ Data/dk.aiyo.VirtualBoxControl/vms) -ge $TIME ]
|
||||
then
|
||||
# cache the VMs
|
||||
if [ ! -d ~/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow\ Data/dk.aiyo.VirtualBoxControl/ ]
|
||||
then
|
||||
mkdir ~/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow\ Data/dk.aiyo.VirtualBoxControl
|
||||
fi
|
||||
VBoxManage list vms -l | sed -n -e '/^Name/N' -e '/\nGroups/P' -e '/\nGuest OS/p' -e '/^Guest OS/P' -e '/^UUID/P' -e '/^State/P' > ~/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow\ Data/dk.aiyo.VirtualBoxControl/vms
|
||||
fi
|
||||
|
||||
#------------
|
||||
|
||||
# check if a VM is selected
|
||||
if [[ $(echo "$1" | grep -c " >" ) -gt 0 ]]
|
||||
then
|
||||
# Try to extract VM name from query
|
||||
NAME=${1%%" >"*}
|
||||
# try to find VM in cache (only match the full name)
|
||||
VMINFO=$(grep -A 3 "$NAME$" ~/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow\ Data/dk.aiyo.VirtualBoxControl/vms)
|
||||
if [[ ! -z "$VMINFO" ]]
|
||||
then
|
||||
# get UUID for reference
|
||||
UUID=$(echo $VMINFO | egrep -o '[0-9abcdef]{8}-[0-9abcdef]{4}-[0-9abcdef]{4}-[0-9abcdef]{4}-[0-9abcdef]{12}')
|
||||
ICON=$(VMicon "$(echo ${VMINFO#*'Guest OS: '})")
|
||||
# make sure name is xml valid
|
||||
NAME=$(printf "$NAME" | sed -e 's/&/&/g')
|
||||
fi
|
||||
fi
|
||||
|
||||
# prepare query for fuzzy match
|
||||
QUERY=$(echo "$1" | sed -e 's/^ *//' -e 's/ *$//' -e 's/ /*\\ /g')
|
||||
|
||||
echo '<?xml version="1.0"?>'
|
||||
echo '<items>'
|
||||
|
||||
# if $UUID is set then a VM is selected - check if status is 'running' if so then show options for VM
|
||||
if [ ! -z "$UUID" ] && [ $(echo $VMINFO | egrep -c " running ") -gt 0 ]
|
||||
then
|
||||
# the VM is Running
|
||||
|
||||
# remove vm name from query
|
||||
QUERY="${QUERY#*' >'}"
|
||||
|
||||
# list options available for the VM with fuzzymatch search
|
||||
if [[ " power off" == $QUERY* ]]
|
||||
then
|
||||
# Power Off
|
||||
echo "<item uid=\"virtualbox power off\" arg=\"controlvm $UUID poweroff\" autocomplete=\"$NAME > Power Off\">"
|
||||
echo "<title>Power Off</title>"
|
||||
echo "<icon>$ICON.png</icon>"
|
||||
echo "</item>"
|
||||
fi
|
||||
if [[ " acpi shutdown" == $QUERY* ]]
|
||||
then
|
||||
# ACPI Shutdown
|
||||
echo "<item uid=\"virtualbox acpi\" arg=\"controlvm $UUID acpipowerbutton\" autocomplete=\"$NAME > ACPI Shutdown\">"
|
||||
echo "<title>ACPI Shutdown</title>"
|
||||
echo "<icon>$ICON.png</icon>"
|
||||
echo "</item>"
|
||||
fi
|
||||
if [[ " pause" == $QUERY* ]]
|
||||
then
|
||||
# Pause
|
||||
echo "<item uid=\"virtualbox pause\" arg=\"controlvm $UUID pause\" autocomplete=\"$NAME > Pause\">"
|
||||
echo "<title>Pause</title>"
|
||||
echo "<icon>$ICON.png</icon>"
|
||||
echo "</item>"
|
||||
fi
|
||||
if [[ " save state" == $QUERY* ]]
|
||||
then
|
||||
# Save Machine State
|
||||
echo "<item uid=\"virtualbox savestate\" arg=\"controlvm $UUID savestate\" autocomplete=\"$NAME > Save State\">"
|
||||
echo "<title>Save State</title>"
|
||||
echo "<icon>$ICON.png</icon>"
|
||||
echo "</item>"
|
||||
fi
|
||||
if [[ " reset" == $QUERY* ]]
|
||||
then
|
||||
# Reset
|
||||
echo "<item uid=\"virtualbox reset\" arg=\"controlvm $UUID reset\" autocomplete=\"$NAME > Reset\">"
|
||||
echo "<title>Reset</title>"
|
||||
echo "<icon>$ICON.png</icon>"
|
||||
echo "</item>"
|
||||
fi
|
||||
if [[ " take a screenshot" == $QUERY* ]]
|
||||
then
|
||||
# Screen Shot
|
||||
FILENAME=$(echo "~/Desktop/$NAME - Screen Shot $(date +"%Y-%m-%d at %H.%M.%S").png" | sed -e 's/ /\\ /g' -e 's/&/\\&/g')
|
||||
echo "<item uid=\"virtualbox screenshot\" arg=\"controlvm $UUID screenshotpng $FILENAME\" autocomplete=\"$NAME > Reset\">"
|
||||
echo "<title>Take a Screenshot</title>"
|
||||
echo "<icon>$ICON.png</icon>"
|
||||
echo "</item>"
|
||||
fi
|
||||
# make a Back item. this links back to VM options or list of VMs
|
||||
if [[ "> " == $QUERY* ]]
|
||||
then
|
||||
BACK=""
|
||||
else
|
||||
BACK="$NAME > "
|
||||
fi
|
||||
echo "<item uid=\"virtualbox back\" autocomplete=\"$BACK\" valid=\"no\">"
|
||||
echo "<title>Back...</title>"
|
||||
echo "<icon>icon.png</icon>"
|
||||
echo "</item>"
|
||||
|
||||
elif [ ! -z "$UUID" ] && [ $(echo $VMINFO | egrep -c " saved ") -gt 0 ]
|
||||
then
|
||||
# the VM is in Saved State mode
|
||||
|
||||
# remove vm name from query
|
||||
QUERY="${QUERY#*' >'}"
|
||||
|
||||
# list options available for the VM with fuzzymatch search
|
||||
if [[ " Start VM" == $QUERY* ]]
|
||||
then
|
||||
# ACPI Shutdown
|
||||
echo "<item uid=\"virtualbox start\" arg=\"startvm $UUID\" autocomplete=\"$NAME > Start VM\">"
|
||||
echo "<title>Start VM</title>"
|
||||
echo "<icon>$ICON.png</icon>"
|
||||
echo "</item>"
|
||||
fi
|
||||
if [[ " Discard Saved State" == $QUERY* ]]
|
||||
then
|
||||
# Pause
|
||||
echo "<item uid=\"virtualbox discard\" arg=\"discardstate $UUID\" autocomplete=\"$NAME > Discard Saved State\">"
|
||||
echo "<title>Discard Saved State</title>"
|
||||
echo "<icon>$ICON.png</icon>"
|
||||
echo "</item>"
|
||||
fi
|
||||
# make a Back item. this links back to VM options or list of VMs
|
||||
if [[ "> " == $QUERY* ]]
|
||||
then
|
||||
BACK=""
|
||||
else
|
||||
BACK="$NAME > "
|
||||
fi
|
||||
echo "<item uid=\"virtualbox back\" autocomplete=\"$BACK\" valid=\"no\">"
|
||||
echo "<title>Back...</title>"
|
||||
echo "<icon>icon.png</icon>"
|
||||
echo "</item>"
|
||||
|
||||
else
|
||||
# no VM was selected, get VMs and list them
|
||||
|
||||
while read LINE
|
||||
do
|
||||
|
||||
case "$LINE" in
|
||||
"Name:"*)
|
||||
NAME=$(echo $LINE | sed -e 's/^Name: *//' -e 's/&/&/g' -e 's/</\</g' -e 's/>/\>/g')
|
||||
;;
|
||||
"UUID:"*)
|
||||
UUID=$(echo $LINE | sed -e 's/UUID: *//')
|
||||
;;
|
||||
"Guest OS:"*)
|
||||
ICON=$(VMicon "$(echo $LINE | sed -e 's/Guest OS: *//')")
|
||||
;;
|
||||
"State:"*)
|
||||
if [ ! -z "$NAME" ] && [ ! -z "$UUID" ] && [ ! -z "$ICON" ]
|
||||
then
|
||||
# fuzzy match query
|
||||
if [[ " $NAME" == *\ $QUERY* ]]
|
||||
then
|
||||
if [[ $(echo $LINE | grep -c "powered off") -gt 0 ]]
|
||||
then
|
||||
# VM is not running make a start link
|
||||
echo "<item uid=\"$UUID\" arg=\"startvm $UUID\" autocomplete=\"$NAME\">"
|
||||
echo "<title>$NAME</title>"
|
||||
echo "<subtitle>Start Virtual Machine</subtitle>"
|
||||
|
||||
elif [[ $(echo $LINE | grep -c "aborted") -gt 0 ]]
|
||||
then
|
||||
# VM is aborted make a start link
|
||||
echo "<item uid=\"$UUID\" arg=\"startvm $UUID\" autocomplete=\"$NAME\">"
|
||||
echo "<title>$NAME (Aborted)</title>"
|
||||
echo "<subtitle>Start Virtual Machine</subtitle>"
|
||||
|
||||
elif [[ $(echo $LINE | grep -c "paused") -gt 0 ]]
|
||||
then
|
||||
# VM is paused, make a resume link
|
||||
echo "<item uid=\"$UUID\" arg=\"controlvm $UUID resume\" autocomplete=\"$NAME\">"
|
||||
echo "<title>$NAME (Paused)</title>"
|
||||
echo "<subtitle>Resume Virtual Machine</subtitle>"
|
||||
|
||||
elif [[ $(echo $LINE | grep -c "saved") -gt 0 ]]
|
||||
then
|
||||
# VM is in a saved state, link to list of options
|
||||
echo "<item uid=\"$UUID\" autocomplete=\"$NAME > \" valid=\"no\">"
|
||||
echo "<title>$NAME (Saved State)</title>"
|
||||
echo "<subtitle>Start or Discard Saved State of Virtual Machine</subtitle>"
|
||||
|
||||
else
|
||||
# VM is running, link to list of options
|
||||
echo "<item uid=\"$UUID\" autocomplete=\"$NAME > \" valid=\"no\">"
|
||||
echo "<title>$NAME (Running)</title>"
|
||||
echo "<subtitle>Pause, Save State, Power Off or Reset Virtual Machine</subtitle>"
|
||||
fi
|
||||
|
||||
echo "<icon>$ICON.png</icon>"
|
||||
echo "</item>"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
done < ~/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow\ Data/dk.aiyo.VirtualBoxControl/vms
|
||||
fi
|
||||
|
||||
echo '</items>'
|
||||
shopt -u nocasematch
|
||||
|
After Width: | Height: | Size: 9.3 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>Spotify Mini Player</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>appIcon.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.spotify.miniplayer.green</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>Spotify Mini Player</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.7.0</string>
|
||||
<key>LSUIElement</key>
|
||||
<false/>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>© 2017 vdesabou</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>AcceptsFiles</key>
|
||||
<true/>
|
||||
<key>AcceptsText</key>
|
||||
<false/>
|
||||
<key>Authentication</key>
|
||||
<false/>
|
||||
<key>Creator</key>
|
||||
<string>Platypus-5.1</string>
|
||||
<key>Droppable</key>
|
||||
<false/>
|
||||
<key>Interpreter</key>
|
||||
<string>/bin/sh</string>
|
||||
<key>InterpreterArgs</key>
|
||||
<array/>
|
||||
<key>Output</key>
|
||||
<string>None</string>
|
||||
<key>PromptForFileOnLaunch</key>
|
||||
<false/>
|
||||
<key>RemainRunning</key>
|
||||
<false/>
|
||||
<key>ScriptArgs</key>
|
||||
<array/>
|
||||
<key>Secure</key>
|
||||
<false/>
|
||||
<key>Suffixes</key>
|
||||
<array/>
|
||||
<key>TextBackground</key>
|
||||
<string>#ffffff</string>
|
||||
<key>TextEncoding</key>
|
||||
<integer>4</integer>
|
||||
<key>TextFont</key>
|
||||
<string>Monaco</string>
|
||||
<key>TextForeground</key>
|
||||
<string>#000000</string>
|
||||
<key>TextSize</key>
|
||||
<real>13</real>
|
||||
<key>UniformTypes</key>
|
||||
<array>
|
||||
<string>public.item</string>
|
||||
<string>public.folder</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo ""
|
||||
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 18 KiB |