Skip to content

Commit 0bb9d50

Browse files
author
tiann
committed
添加丢失的clipoard文件;添加打包好的alfred插件
1 parent 95de112 commit 0bb9d50

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.DS_Store
22
*pyc
3+
config.ini

clipboard.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# -*- coding: utf-8 -*-
2+
import time, os
3+
from AppKit import NSPasteboard, NSPasteboardTypePNG, NSPasteboardTypeTIFF, NSPasteboardTypeString
4+
5+
def get_paste_img_file():
6+
pb = NSPasteboard.generalPasteboard()
7+
data_type = pb.types()
8+
# if img file
9+
print data_type
10+
now = int(time.time() * 1000) # used for filename
11+
if NSPasteboardTypePNG in data_type:
12+
# png
13+
data = pb.dataForType_(NSPasteboardTypePNG)
14+
filename = '%s.png' % now
15+
filepath = '/tmp/%s' % filename
16+
ret = data.writeToFile_atomically_(filepath, False)
17+
if ret:
18+
return filepath
19+
elif NSPasteboardTypeTIFF in data_type:
20+
# tiff
21+
data = pb.dataForType_(NSPasteboardTypeTIFF)
22+
filename = '%s.tiff' % now
23+
filepath = '/tmp/%s' % filename
24+
ret = data.writeToFile_atomically_(filepath, False)
25+
if ret:
26+
os.system('sips -s format tiff /tmp/%s.tiff --out /tmp/%s.png' % (now, now))
27+
return '/tmp/%s.png' % now
28+
elif NSPasteboardTypeString in data_type:
29+
# string todo, recognise url of png & jpg
30+
pass
31+
32+
33+
34+
35+

markdown img.alfredworkflow

42.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)