首页   注册   登录
 fengjianxinghun 最近的时间轴更新

fengjianxinghun

V2EX 第 115063 号会员,加入于 2015-05-04 14:11:23 +08:00
今日活跃度排名 7118
fengjianxinghun 最近回复了
4 天前
回复了 crazyjin 创建的主题 Python Python 社区是啥子隐秘的高端会所吗?
@crazyjin 那就找梯子
4 天前
回复了 pjhubs 创建的主题 程序员 解析 crash log(一)
lldb 没试过?
能得个笔记本嘛
13 天前
回复了 rochek 创建的主题 职场话题 有深信服的大佬吗,公司是怎样的氛围呢
华为系,你懂的
@luoway mac 上能用的
```
#!/usr/bin/env bash

cd /tmp

# Create the source file
cat > main.m << EOF

#import <objc/runtime.h>
#import <Foundation/Foundation.h>

int main () {
NSBundle *bundle = [NSBundle bundleWithPath:@"/Applications/Utilities/Keychain Access.app/Contents/Resources/Keychain.menu"];

Class principalClass = [bundle principalClass];

id instance = [[principalClass alloc] init];

[instance performSelector:@selector(_lockScreenMenuHit:) withObject:nil];

return 0;
}

EOF

# Compile the source file
clang -framework Foundation main.m -o lockscreen
```


```
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import Foundation
import objc
import AppKit
import sys
import os
import threading
import functools
import time

NSUserNotification = objc.lookUpClass('NSUserNotification')
NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter')



def notify(title, subtitle, info_text, delay=0, sound=False, userInfo={}):
notification = NSUserNotification.alloc().init()
notification.setTitle_(title)
notification.setSubtitle_(subtitle)
notification.setInformativeText_(info_text)
notification.setUserInfo_(userInfo)
if sound:
notification.setSoundName_("NSUserNotificationDefaultSoundName")
notification.setDeliveryDate_(Foundation.NSDate.dateWithTimeInterval_sinceDate_(delay, Foundation.NSDate.date()))
NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification)
time.sleep(5)
curr_path = os.path.dirname(os.path.abspath(__file__))
os.system("{}/lockscreen".format(curr_path))

def work_fn():
notify(title="STOP!!!!!!!!!!", subtitle="take a rest", info_text="AAAAAAAAAAAAAAAAAAAAAAAAA", sound=True)


def main():
work_fn()


if __name__ == '__main__':
main()
```

然后丢到 launchctl 一小时跑一次这个 python 脚本
关于   ·   FAQ   ·   API   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   797 人在线   最高记录 4385   ·  
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.3 · 16ms · UTC 21:03 · PVG 05:03 · LAX 14:03 · JFK 17:03
♥ Do have faith in what you're doing.
沪ICP备16043287号-1