<?php

require_once 'workflows.php';
$w = new Workflows();
$w->set('is_spotifious_active', $argv[1], 'settings.plist');
echo "Spotifious activation has been set to  {$argv['1']}";
Esempio n. 2
0
<?php

require_once 'workflows.php';
$w = new Workflows();
$q = $argv;
$q = explode(" ", $argv[1], 2);
if ($q[0] == 'token') {
    $w->set('token', $q[1], 'settings.plist');
    echo 'Token added';
} else {
    $post['text'] = $argv[1];
    $token = $w->get('token', 'settings.plist');
    $url = 'https://alpha-api.app.net/stream/0/posts';
    $headers = array('Content-Type: application/json', 'Authorization: Bearer ' . $token);
    connect(1, $url, $headers, $post);
}
function connect($type = 1, $url, $headers, $query)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    if ($type == 1) {
        curl_setopt($ch, CURLOPT_POST, 1);
        if (isset($query)) {
            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
        }
    }
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $output = json_decode(curl_exec($ch));
    curl_close($ch);
    if (isset($output->error)) {
<?php

require_once 'workflows.php';
$w = new Workflows();
$w->set('max_results', $argv[1], 'settings.plist');
echo "Max results has been set to {$argv['1']}";
Esempio n. 4
0
function get_data($url)
{
    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}
// Initialize Settings
$s = 'settings.plist';
$key = $w->get('api_key', $s);
if (!$w->get('check_for_updates', $s)) {
    $w->set('check_for_updates', 'TRUE', $s);
}
if (!$w->get('update_ignore_date', $s)) {
    $w->set('update_ignore_date', time(), $s);
}
// Check for updates. Initially had coded for checking once a day but Alfred initiated duplicate calls which was screwing up the timing. This check isn't expensive so I'll just do it every time.
if ($w->get('check_for_updates', $s) == 'TRUE') {
    $now = time();
    $r = get_data('https://raw.github.com/nickwynja/darksky-alfred/master/version.json');
    $v = json_decode($r);
    $update_version = (double) $v->updated_version;
    $update_ignore_date = (int) $w->get('update_ignore_date', $s);
    $since_update_ignored = $now - $update_ignore_date;
    if ($update_version > $current_version && $since_update_ignored > 259200) {
        $w->result('download', $v->download_url, "Version {$v->updated_version} of Dark Sky is available. Update now?", "This will take you to the download page.", 'icon.png');
        $w->result('dont-update', 'dont-update', "No thanks. Tell me what the weather's like...", "Check the forcast and ignore updates for a few days.", 'icon.png');
Esempio n. 5
0
$query = $argv[1];
# thanks to http://www.alfredforum.com/topic/1788-prevent-flash-of-no-result
$query = iconv("UTF-8-MAC", "UTF-8", $query);
$w = new Workflows();
# increase memory_limit
if (file_exists($w->data() . "/library.json")) {
    ini_set('memory_limit', '256M');
}
//
// Get all_playlists from config
//
$ret = $w->get('all_playlists', 'settings.plist');
if ($ret == false) {
    // all_playlists not set
    // set it to default
    $w->set('all_playlists', 'false', 'settings.plist');
    $ret = 'false';
}
if ($ret == 'true') {
    $all_playlists = true;
} else {
    $all_playlists = false;
}
//
// Get is_spotifious_active from config
//
$ret = $w->get('is_spotifious_active', 'settings.plist');
if ($ret == false) {
    // is_spotifious_active not set
    // set it to default
    $w->set('is_spotifious_active', 'false', 'settings.plist');
Esempio n. 6
0
<?php

require 'workflows.php';
$w = new Workflows();
if (!isset($query)) {
    $query = <<<EOD
{query}
EOD;
}
$w->set('github.username', $query, 'settings.plist');
echo 'Set Alfred Github Username ' . $query;
Esempio n. 7
0
<?php

require 'workflows.php';
$w = new Workflows();
if (!isset($query)) {
    $query = <<<EOD
{query}
EOD;
}
$w->set('github.password', $query, 'settings.plist');
echo 'Set Alfred Github Password ********';
Esempio n. 8
0
<?php

/**
* Name: 		Wordreference.com (© WordReference.com) Workflow for Alfred 2 
* Author: 		Anthony Kevins
* Revised: 		14/06/2013
* Version:		0.3
* Note:   	       Icon Source: A68 - Freelance Graphics Design (http://a68.pl)
*/
$q = $argv[1];
require_once 'workflows.php';
$w = new Workflows();
$id = $argv[1];
$w->set('api', $id, 'settings.plist');
echo $id;
Esempio n. 9
0
<?php

require_once 'workflows.php';
$w = new Workflows();
// Make sure settings file exists.
exec('touch settings.plist');
/** Send request to Portal API to discover bridges on the local network. */
$bridges = $w->request('http://www.meethue.com/api/nupnp');
$bridges = json_decode($bridges, true);
if (empty($bridges)) {
    die('No bridges found on your network.');
}
$bridge_ip = $bridges[0]['internalipaddress'];
$w->set('api.bridge_ip', $bridge_ip, 'settings.plist');
/** Set API group */
if (!empty($argv[1]) && is_numeric($argv[1])) {
    $group = (int) $argv[1];
} else {
    $group = 0;
}
$w->set('api.group', $group, 'settings.plist');
/** Create API user for this workflow. */
$resp = $w->request("http://{$bridge_ip}/api", array(CURLOPT_POST => true, CURLOPT_POSTFIELDS => '{"devicetype": "Alfred"}'));
$resp = json_decode($resp, true);
if (isset($resp[0]['error'])) {
    die('Setup Error: ' . $resp[0]['error']['description']);
}
$username = $resp[0]['success']['username'];
$w->set('api.username', $username, 'settings.plist');
echo 'Success! You can now control your lights by using the "hue" keyword.';
exit;
<?php

require_once 'workflows.php';
$w = new Workflows();
$value = $argv[1];
if ($value == "true") {
    $w->set('all_playlists', 'true', 'settings.plist');
    echo "Search scope set to all playlists";
} else {
    $w->set('all_playlists', 'false', 'settings.plist');
    echo "Search scope set to starred playlist";
}
Esempio n. 11
0
<?php

require 'workflows.php';
$w = new Workflows();
if (!isset($query)) {
    $query = <<<EOD
{query}
EOD;
}
$w->set('github.proxy', $query, 'settings.plist');
echo 'Set Alfred Github Proxy ' . $query;