diff --git a/0FA3CA6F-AB00-446F-95B9-EAB309AA7AD4.png b/0FA3CA6F-AB00-446F-95B9-EAB309AA7AD4.png new file mode 100644 index 0000000..bdeed4d Binary files /dev/null and b/0FA3CA6F-AB00-446F-95B9-EAB309AA7AD4.png differ diff --git a/29615B9D-6FED-426D-AC5D-34E5D09C8770.png b/29615B9D-6FED-426D-AC5D-34E5D09C8770.png new file mode 100644 index 0000000..b949251 Binary files /dev/null and b/29615B9D-6FED-426D-AC5D-34E5D09C8770.png differ diff --git a/679ACFD3-4EFD-4253-8DE7-43596D7AE00B.png b/679ACFD3-4EFD-4253-8DE7-43596D7AE00B.png new file mode 100644 index 0000000..833f9e5 Binary files /dev/null and b/679ACFD3-4EFD-4253-8DE7-43596D7AE00B.png differ diff --git a/92606F4B-F131-40B2-AB3B-BE0A56339FA8.png b/92606F4B-F131-40B2-AB3B-BE0A56339FA8.png new file mode 100644 index 0000000..e75ab13 Binary files /dev/null and b/92606F4B-F131-40B2-AB3B-BE0A56339FA8.png differ diff --git a/README.md b/README.md index 4864b66..2baf770 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ 提供查看帮助文档、复制常用命令等功能 -[Download](https://github.com/wxnacy/alfred-commands-workflow/releases/download/v2020.05.23/Commands.Help.Tools.alfredworkflow) +[Download](https://github.com/wxnacy/alfred-commands-workflow/releases/download/v2020.06.01/Commands.Help.Tools.alfredworkflow) ## 复制常用命令 @@ -18,3 +18,14 @@ ![dl](https://github.com/wxnacy/image/blob/master/blog/alfred-dl.gif) +## 查询 ip + +![t3W2RS.gif](https://s1.ax1x.com/2020/06/01/t3W2RS.gif) + +## 运行命令 + +![t3R2u9.gif](https://s1.ax1x.com/2020/06/01/t3R2u9.gif) + +# 查看磁盘使用情况 + +![t3WzZR.gif](https://s1.ax1x.com/2020/06/01/t3WzZR.gif) diff --git a/convert_time.py b/convert_time.py new file mode 100644 index 0000000..f6cd587 --- /dev/null +++ b/convert_time.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python +# -*- coding:utf-8 -*- +# Author: wxnacy(wxnacy@gmail.com) +# Description: + +import sys +import json +import os +import logging +import subprocess + +from workflow import Workflow3 +from workflow import web +import time +from datetime import datetime +from datetime import timedelta +from pytz import timezone +from pytz import utc + + +def input_type(text): + '''判断输入类型''' + try: + int(text) + return int + except ValueError: + pass + + return str + +def now(): + '''获取当前时间''' + ts = int(time.time()) + return format_timestamp(ts) + +def fmt_dt(dt): + return dt.strftime("%Y-%m-%d %H:%M:%S") + +def format_timestamp(ts): + '''格式化时间戳''' + res = dict(timestamp = ts) + # t = datetime.fromtimestamp(ts) + t = datetime.utcfromtimestamp(ts) + res['local'] = fmt_dt(datetime.now()) + # t = t.replace(tzinfo=timezone("UTC")) + + for i in list(range(-12, 13)): + dt = t + timedelta(hours=i) + res[i] = fmt_dt(dt) + + return res + +def output_result(wf, res): + '''格式化输出''' + item = dict(valid = True) + item['title'] = res['timestamp'] + item['subtitle'] = '时间戳' + item['arg'] = item['title'] + wf.add_item(**item) + + for k, v in res.items(): + item['title'] = v + if k == 'local': + item['subtitle'] = '本地时间' + item['arg'] = item['title'] + wf.add_item(**item) + elif k == 0: + item['subtitle'] = 'UTC 时间' + item['arg'] = item['title'] + wf.add_item(**item) + elif k == -4: + item['subtitle'] = '纽约时间' + item['arg'] = item['title'] + wf.add_item(**item) + +def main(wf): + args = wf.args + logging.info(args) + t = args[0] + + whole_input = ' '.join(args) + + type = input_type(t) + if type == int: + res = format_timestamp(int(t)) + output_result(wf, res) + + + item = dict(valid = True) + if t == 'now': + res = now() + output_result(wf, res) + + logging.info(list(filter(lambda o: 'item' in o, dir(wf)))) + logging.info(wf._items) + if not wf._items: + wf.add_item(title="输入需要转换的时间", subtitle = ' '.join(args)) + + wf.send_feedback() + + +if __name__ == '__main__': + wf = Workflow3() + sys.exit(wf.run(main)) + diff --git a/df.sh b/df.sh new file mode 100755 index 0000000..7cef37f --- /dev/null +++ b/df.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Author: wxnacy(wxnacy@gmail.com) +# Description: + +disk=`df -h | grep 'disk.*System'` +disks=(${disk}) +VOLUME=$(system_profiler SPSoftwareDataType | grep 'Boot Volume' | awk '{print substr($0, index($0,$3))}') + +subtitle="Size: ${disks[1]} Used: ${disks[2]} Avail: ${disks[3]}" + +cat << EOB + + + + ${VOLUME} + ${subtitle} + + +EOB diff --git a/info.plist b/info.plist index 227834a..68074fd 100644 --- a/info.plist +++ b/info.plist @@ -19,6 +19,19 @@ + 29615B9D-6FED-426D-AC5D-34E5D09C8770 + + + destinationuid + 2CE54DD1-24E6-4356-BFCA-AB8E6F825958 + modifiers + 0 + modifiersubtext + + vitoclose + + + 2CE54DD1-24E6-4356-BFCA-AB8E6F825958 @@ -34,6 +47,19 @@ 3E407FFE-9A3F-49F5-B15F-CE97FAFAED07 + 679ACFD3-4EFD-4253-8DE7-43596D7AE00B + + + destinationuid + 2CE54DD1-24E6-4356-BFCA-AB8E6F825958 + modifiers + 0 + modifiersubtext + + vitoclose + + + 71463E91-2E01-41CC-B10F-3A01857AB2DE @@ -333,6 +359,104 @@ version 3 + + config + + alfredfiltersresults + + alfredfiltersresultsmatchmode + 0 + argumenttreatemptyqueryasnil + + argumenttrimmode + 0 + argumenttype + 0 + escaping + 0 + keyword + time + queuedelaycustom + 3 + queuedelayimmediatelyinitially + + queuedelaymode + 0 + queuemode + 1 + runningsubtext + 正在处理,请稍后 + script + python convert_time.py $1 + scriptargtype + 1 + scriptfile + + subtext + 请输入要转换的时间 + title + 对时间进行转换 + type + 0 + withspace + + + type + alfred.workflow.input.scriptfilter + uid + 679ACFD3-4EFD-4253-8DE7-43596D7AE00B + version + 3 + + + config + + alfredfiltersresults + + alfredfiltersresultsmatchmode + 0 + argumenttreatemptyqueryasnil + + argumenttrimmode + 0 + argumenttype + 2 + escaping + 102 + keyword + disk + queuedelaycustom + 3 + queuedelayimmediatelyinitially + + queuedelaymode + 0 + queuemode + 1 + runningsubtext + 正在查询,请稍后 + script + ./df.sh + scriptargtype + 1 + scriptfile + + subtext + + title + 查看硬盘空间 + type + 0 + withspace + + + type + alfred.workflow.input.scriptfilter + uid + 29615B9D-6FED-426D-AC5D-34E5D09C8770 + version + 3 + config @@ -341,7 +465,10 @@ escaping 102 script - echo -n `$1` + $@ | while read line +do + echo $line +done scriptargtype 1 scriptfile @@ -544,7 +671,14 @@ echo -n $(nohup curl $1 -O &) xpos 180 ypos - 425 + 685 + + 29615B9D-6FED-426D-AC5D-34E5D09C8770 + + xpos + 180 + ypos + 555 2CE54DD1-24E6-4356-BFCA-AB8E6F825958 @@ -558,7 +692,7 @@ echo -n $(nohup curl $1 -O &) xpos 510 ypos - 705 + 965 5348461E-968E-4C7D-A961-2C53A47EEB39 @@ -567,12 +701,19 @@ echo -n $(nohup curl $1 -O &) ypos 170 + 679ACFD3-4EFD-4253-8DE7-43596D7AE00B + + xpos + 180 + ypos + 430 + 71463E91-2E01-41CC-B10F-3A01857AB2DE xpos 180 ypos - 705 + 965 7550C092-A6C8-4BB2-A593-865B5A9F831B @@ -600,35 +741,35 @@ echo -n $(nohup curl $1 -O &) xpos 180 ypos - 570 + 830 ABFDAC0A-59AC-46FF-8317-30A5EE1E72B4 xpos 350 ypos - 570 + 830 AEEE997C-352F-4019-BFEF-40480C5770E9 xpos 350 ypos - 425 + 685 C2C22059-F577-4982-B0BF-665E0E358013 xpos 565 ypos - 425 + 685 F800D030-BFC4-490B-813D-74D375AA6EF0 xpos 350 ypos - 705 + 965 variablesdontexport diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..c05e7b3 --- /dev/null +++ b/run.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# Author: wxnacy(wxnacy@gmail.com) +# Description: + +# result=`$@` + +$@ | while read line +do + echo $line +done