-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD]: publish version 1.0.0 for CountKey.
- Loading branch information
Showing
5 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,7 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
__MACOSX/ | ||
.DS_Store | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,43 @@ | ||
# CountKey | ||
|
||
A mac app that records the number of keystrokes on the keyboard. | ||
|
||
|
||
## Usages | ||
|
||
1、直接运行 | ||
|
||
2、将 `CountKey.app` 拷贝到访达里的 `应用程序` 中,这样使用更方便 | ||
|
||
Tips: 按住 `Command` 键不松,鼠标点击菜单栏图标向右拖动到可以看到的位置,可以避免图标被遮挡导致看不到 | ||
|
||
软件不联网,也不储存什么文件,只需要获取读键盘的权限就行,软件重启会从零开始重新计数。 | ||
|
||
## Build | ||
|
||
|
||
```bash | ||
python setup.py py2app | ||
``` | ||
|
||
生成的 app 中会缺少 `libffi.7.dylib` ,需要手动拷贝到 `/Contents/Frameworks/` 里边。 | ||
|
||
## TODO | ||
|
||
- [ ] 去除 Dock 上的图标显示 | ||
- [ ] 在本地保存日志,记录每天的次数以及高频按键 | ||
- [ ] 自动化打包问题,即不需要手动拷贝依赖 | ||
|
||
## About | ||
|
||
CountKey v1.0.0 was made in 2021 by YangShu. | ||
|
||
Don't be sedentary! | ||
Protect your waist, shoulders, neck and wrists! | ||
Here's to your health, longevity! | ||
|
||
Welcome to email me! | ||
Let me know you are using this app. | ||
Since this app is not networked, it is convenient for me to tell you by email after this app is upgraded. | ||
|
||
Contact Me: [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from _thread import start_new_thread | ||
|
||
import rumps | ||
from pynput import keyboard | ||
|
||
key_count = 0 | ||
|
||
|
||
class KeyAction: | ||
def __init__(self): | ||
self.key_dict = {} | ||
|
||
@property | ||
def key_count(self): | ||
global key_count | ||
key_count = 0 | ||
for _, value in self.key_dict.items(): | ||
key_count += value | ||
return key_count | ||
|
||
def on_press(self, key): | ||
pass | ||
|
||
def on_release(self, key): | ||
global key_count | ||
key_count += 1 | ||
if key in self.key_dict: | ||
self.key_dict[key] += 1 | ||
else: | ||
self.key_dict[key] = 0 | ||
|
||
|
||
class CountKeyApp(rumps.App): | ||
def __init__(self): | ||
self.config = { | ||
'app_name': 'CountKey', | ||
'about': 'About', | ||
'about_title': 'About CountKey' | ||
} | ||
super(CountKeyApp, self).__init__(self.config['app_name']) | ||
start_new_thread(self.thread_count, ()) | ||
self.about_button = rumps.MenuItem(title=self.config['about'], callback=self.on_about) | ||
self.menu = [self.about_button] | ||
|
||
@rumps.timer(1) | ||
def on_tick(self, sender): | ||
global key_count | ||
self.title = 'CountKey: ' + str(key_count) | ||
|
||
def on_about(self, sender): | ||
rumps.alert(self.config['about_title'], | ||
'CountKey was made in 2021 by YangShu.\n\n' + | ||
'Don\'t be sedentary!\n' + | ||
'Protect your waist, shoulders, neck and wrists!\n' + | ||
'Here\'s to your health, longevity!\n\n' + | ||
'Welcome to email me!\nLet me know you are using this app.\n' + | ||
'Since this app is not networked, it is convenient for me to tell you by email ' + | ||
'after this app is upgraded.\n\n' + | ||
'Contact Me: [email protected]\n', | ||
ok='Thanks!') | ||
|
||
@staticmethod | ||
def thread_count(): | ||
ka = KeyAction() | ||
with keyboard.Listener(on_press=ka.on_press, on_release=ka.on_release) as listener: | ||
listener.join() | ||
|
||
|
||
if __name__ == '__main__': | ||
CountKeyApp().run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
""" | ||
This is a setup.py script generated by py2applet | ||
Usage: | ||
python setup.py py2app | ||
""" | ||
|
||
from setuptools import setup | ||
|
||
APP = ['main.py'] | ||
VERSION = '1.0.0' | ||
DATA_FILES = [] | ||
OPTIONS = { | ||
'iconfile': 'icon.png', | ||
'packages': ['rumps', 'pynput'], | ||
} | ||
|
||
setup( | ||
app=APP, | ||
name='CountKey', | ||
author="YangShu", | ||
author_email="[email protected]", | ||
version=VERSION, | ||
data_files=DATA_FILES, | ||
options={'py2app': OPTIONS}, | ||
setup_requires=['py2app'], | ||
install_requires=['rumps', 'pynput'] | ||
) |