Skip to content

Commit c62467d

Browse files
committed
Merge pull request hzlzh#47 from xbot/master
submit alfred-pushbullet
2 parents b526e39 + 95388c4 commit c62467d

File tree

156 files changed

+36189
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+36189
-0
lines changed
1.2 MB
Binary file not shown.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
*.egg-info/
23+
.installed.cfg
24+
*.egg
25+
26+
# PyInstaller
27+
# Usually these files are written by a python script from a template
28+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
29+
*.manifest
30+
*.spec
31+
32+
# Installer logs
33+
pip-log.txt
34+
pip-delete-this-directory.txt
35+
36+
# Unit test / coverage reports
37+
htmlcov/
38+
.tox/
39+
.coverage
40+
.coverage.*
41+
.cache
42+
nosetests.xml
43+
coverage.xml
44+
*,cover
45+
.hypothesis/
46+
47+
# Translations
48+
*.mo
49+
*.pot
50+
51+
# Django stuff:
52+
*.log
53+
54+
# Sphinx documentation
55+
docs/_build/
56+
57+
# PyBuilder
58+
target/
59+
60+
#Ipython Notebook
61+
.ipynb_checkpoints
24.8 KB
Loading
24.8 KB
Loading
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Donie Leigh
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# alfred-pushbullet
2+
3+
Pushbullet workflow for Alfred.
4+
5+
## Features
6+
7+
- Push a text to another device.
8+
9+
## Installation
10+
11+
1. Download the latest release and rename it to pushbullet.alfredworkflow.
12+
- Double click it to import it into Alfred.
13+
- Double click the "Run Script" button and replace "ACCESS_TOKEN" and "DEVICE_NAME" according to your pushbullet settings.
14+
- Activate alfred and input "push blablabla", then press enter.
15+
16+
## Author
17+
18+
`base64decode IkRvbmllIExlaWdoIiA8ZG9uaWUubGVpZ2hAZ21haWwuY29tPgo=`
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# -*- coding: utf-8 -*-
2+
import itertools
3+
import os
4+
import plistlib
5+
import unicodedata
6+
import sys
7+
8+
from xml.etree.ElementTree import Element, SubElement, tostring
9+
10+
"""
11+
You should run your script via /bin/bash with all escape options ticked.
12+
The command line should be
13+
14+
python yourscript.py "{query}" arg2 arg3 ...
15+
"""
16+
UNESCAPE_CHARACTERS = u""" ;()"""
17+
18+
_MAX_RESULTS_DEFAULT = 9
19+
20+
preferences = plistlib.readPlist('info.plist')
21+
bundleid = preferences['bundleid']
22+
23+
class Item(object):
24+
@classmethod
25+
def unicode(cls, value):
26+
try:
27+
items = iter(value.items())
28+
except AttributeError:
29+
return unicode(value)
30+
else:
31+
return dict(map(unicode, item) for item in items)
32+
33+
def __init__(self, attributes, title, subtitle, icon=None):
34+
self.attributes = attributes
35+
self.title = title
36+
self.subtitle = subtitle
37+
self.icon = icon
38+
39+
def __str__(self):
40+
return tostring(self.xml()).decode('utf-8')
41+
42+
def xml(self):
43+
item = Element(u'item', self.unicode(self.attributes))
44+
for attribute in (u'title', u'subtitle', u'icon'):
45+
value = getattr(self, attribute)
46+
if value is None:
47+
continue
48+
if len(value) == 2 and isinstance(value[1], dict):
49+
(value, attributes) = value
50+
else:
51+
attributes = {}
52+
SubElement(item, attribute, self.unicode(attributes)).text = self.unicode(value)
53+
return item
54+
55+
def args(characters=None):
56+
return tuple(unescape(decode(arg), characters) for arg in sys.argv[1:])
57+
58+
def config():
59+
return _create('config')
60+
61+
def decode(s):
62+
return unicodedata.normalize('NFD', s.decode('utf-8'))
63+
64+
def uid(uid):
65+
return u'-'.join(map(str, (bundleid, uid)))
66+
67+
def unescape(query, characters=None):
68+
for character in (UNESCAPE_CHARACTERS if (characters is None) else characters):
69+
query = query.replace('\\%s' % character, character)
70+
return query
71+
72+
def work(volatile):
73+
path = {
74+
True: '~/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data',
75+
False: '~/Library/Application Support/Alfred 2/Workflow Data'
76+
}[bool(volatile)]
77+
return _create(os.path.join(os.path.expanduser(path), bundleid))
78+
79+
def write(text):
80+
sys.stdout.write(text)
81+
82+
def xml(items, maxresults=_MAX_RESULTS_DEFAULT):
83+
root = Element('items')
84+
for item in itertools.islice(items, maxresults):
85+
root.append(item.xml())
86+
return tostring(root, encoding='utf-8')
87+
88+
def _create(path):
89+
if not os.path.isdir(path):
90+
os.mkdir(path)
91+
if not os.access(path, os.W_OK):
92+
raise IOError('No write access: %s' % path)
93+
return path
24.8 KB
Loading
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>bundleid</key>
6+
<string>org.0x3f.pushbullet</string>
7+
<key>connections</key>
8+
<dict>
9+
<key>0454B024-4458-426D-8821-657AC693F4AF</key>
10+
<array>
11+
<dict>
12+
<key>destinationuid</key>
13+
<string>6D974F7E-8D4C-476A-9B01-9942ED343843</string>
14+
<key>modifiers</key>
15+
<integer>0</integer>
16+
<key>modifiersubtext</key>
17+
<string></string>
18+
</dict>
19+
</array>
20+
<key>AA8B47EF-14F7-490B-ABF2-F2FD0B99D1D1</key>
21+
<array>
22+
<dict>
23+
<key>destinationuid</key>
24+
<string>0454B024-4458-426D-8821-657AC693F4AF</string>
25+
<key>modifiers</key>
26+
<integer>0</integer>
27+
<key>modifiersubtext</key>
28+
<string></string>
29+
</dict>
30+
</array>
31+
</dict>
32+
<key>createdby</key>
33+
<string>Donie Leigh</string>
34+
<key>description</key>
35+
<string>Push texts to phone by pushbullet.</string>
36+
<key>disabled</key>
37+
<false/>
38+
<key>name</key>
39+
<string>Pushbullet</string>
40+
<key>objects</key>
41+
<array>
42+
<dict>
43+
<key>config</key>
44+
<dict>
45+
<key>concurrently</key>
46+
<false/>
47+
<key>escaping</key>
48+
<integer>127</integer>
49+
<key>script</key>
50+
<string>python main.py ACCESS_TOKEN DEVICE_NAME "{query}"</string>
51+
<key>type</key>
52+
<integer>0</integer>
53+
</dict>
54+
<key>type</key>
55+
<string>alfred.workflow.action.script</string>
56+
<key>uid</key>
57+
<string>0454B024-4458-426D-8821-657AC693F4AF</string>
58+
<key>version</key>
59+
<integer>0</integer>
60+
</dict>
61+
<dict>
62+
<key>config</key>
63+
<dict>
64+
<key>argumenttype</key>
65+
<integer>0</integer>
66+
<key>keyword</key>
67+
<string>push</string>
68+
<key>subtext</key>
69+
<string>Push texts to another device.</string>
70+
<key>text</key>
71+
<string>Pushbullet</string>
72+
<key>withspace</key>
73+
<true/>
74+
</dict>
75+
<key>type</key>
76+
<string>alfred.workflow.input.keyword</string>
77+
<key>uid</key>
78+
<string>AA8B47EF-14F7-490B-ABF2-F2FD0B99D1D1</string>
79+
<key>version</key>
80+
<integer>0</integer>
81+
</dict>
82+
<dict>
83+
<key>config</key>
84+
<dict>
85+
<key>lastpathcomponent</key>
86+
<false/>
87+
<key>onlyshowifquerypopulated</key>
88+
<false/>
89+
<key>output</key>
90+
<integer>0</integer>
91+
<key>removeextension</key>
92+
<false/>
93+
<key>sticky</key>
94+
<false/>
95+
<key>text</key>
96+
<string>{query}</string>
97+
<key>title</key>
98+
<string>Pushbullet</string>
99+
</dict>
100+
<key>type</key>
101+
<string>alfred.workflow.output.notification</string>
102+
<key>uid</key>
103+
<string>6D974F7E-8D4C-476A-9B01-9942ED343843</string>
104+
<key>version</key>
105+
<integer>0</integer>
106+
</dict>
107+
</array>
108+
<key>readme</key>
109+
<string></string>
110+
<key>uidata</key>
111+
<dict>
112+
<key>0454B024-4458-426D-8821-657AC693F4AF</key>
113+
<dict>
114+
<key>ypos</key>
115+
<real>10</real>
116+
</dict>
117+
<key>6D974F7E-8D4C-476A-9B01-9942ED343843</key>
118+
<dict>
119+
<key>ypos</key>
120+
<real>10</real>
121+
</dict>
122+
<key>AA8B47EF-14F7-490B-ABF2-F2FD0B99D1D1</key>
123+
<dict>
124+
<key>ypos</key>
125+
<real>10</real>
126+
</dict>
127+
</dict>
128+
<key>webaddress</key>
129+
<string>http://0x3f.org</string>
130+
</dict>
131+
</plist>

Sources/Workflows/alfred-pushbullet/lib/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)