diff --git a/README.md b/README.md index 72a83dc..e312bbf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Tickeys-linux -Instant audio feedback when typing. For Linux.[最新版下载](https://github.com/BillBillBillBill/Tickeys-linux/releases/download/v0.2.1/tickeys-0.2.1.zip) +Instant audio feedback when typing. For Linux.[最新版下载](https://github.com/BillBillBillBill/Tickeys-linux/releases/download/v0.2.3/tickeys_0.2.3.deb) 如果有任何问题或者建议,请在issue中提出: [![Join the chat at https://gitter.im/BillBillBillBill/Tickeys-linux](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/BillBillBillBill/Tickeys-linux?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) @@ -14,7 +14,7 @@ Tickeys是一款很强大的键盘音效软件。Tickeys 自带了四种声音 # 项目网站 http://www.yingdev.com/projects/tickeys -PyPI: https://pypi.python.org/pypi/tickeys +PyPI: https://pypi.python.org/pypi/tickeys # Tickeys的Mac版本 https://github.com/yingDev/Tickeys @@ -22,14 +22,15 @@ https://github.com/yingDev/Tickeys # 安装说明 在不同发行版上可能会有因为文件的缺失或者环境不同导致无法使用,需要安装相关依赖。 -##下载编译好的程序运行(建议) +##下载打包好的安装包安装(建议) * 下载deb安装包:[tickeys_0.2.3.deb](https://github.com/BillBillBillBill/Tickeys-linux/releases/download/v0.2.3/tickeys_0.2.3.deb) * 安装,在启动器中找到Tickeys打开。 ##编译安装(需要安装依赖): -* 以下方法需要**先执行**`sudo apt-get install python-dev python-pip python-kivy xdotool`来安装依赖,一般这样就可以满足运行条件了。 +* 以下方法需要**先执行**`sudo apt-get install python-dev python-pip python-kivy xdotool gksu`来安装依赖,一般这样就可以满足运行条件了。 +* 安装库(注意版本): sudo pip install cython==0.20.2 notify2 pyinstaller==3.0 kivy==1.9.0 #### 快速编译安装:执行`sudo apt-get install python-dev python-pip python-kivy xdotool && sudo easy_install tickeys`。 @@ -43,13 +44,6 @@ https://github.com/yingDev/Tickeys * 下载 https://github.com/BillBillBillBill/Tickeys-linux/archive/master.zip ,解压后运行 `sudo python setup.py install` * 然后通过 `sudo tickeys` 来打开 (sudo tickeys -c 打开CLI版本) -###方法3.在本地打包成可执行程序 - -* 先下载 https://github.com/BillBillBillBill/Tickeys-linux/archive/master.zip -* 安装打包所需的pyinstaller -* 然后使用pyinstaller进行打包:`pyinstaller build.spec` -* ~~然后使用cx_freeze进行打包:`sudo python bulid.py bulid`~~ -* 然后下面跟方法2一样打开 #### 错误解决方案: @@ -61,11 +55,11 @@ https://github.com/yingDev/Tickeys 解决方法:使用`sudo apt-get install python-pip` 安装 -* Python.h:没有那个文件或目录 +* Python.h:没有那个文件或目录 解决方法:使用`sudo apt-get install python-dev`安装 -* ImportError: No module named Cython.Distutils +* ImportError: No module named Cython.Distutils 解决方法:使用`sudo easy_install cython`安装 @@ -80,7 +74,7 @@ https://github.com/yingDev/Tickeys Debian and Ubuntu 用户则可以尝试安装: - * sudo apt-get install xdotool + * sudo apt-get install xdotool * sudo apt-get install libsdl1.2-dev * sudo apt-get install libsdl-mixer1.2 * sudo apt-get install libsdl-ttf2.0 @@ -129,43 +123,63 @@ xdotool的使用: * 激活窗口: xdotool windowactivate --sync $WID + xdotool windowmap --sync $WID && xdotool windowactivate --sync $WID * 隐藏窗口实现: - xdotool getactivewindow windowminimize + xdotool getactivewindow windowunmap + ~~xdotool getactivewindow windowminimize~~ 或 - xdotool getactivewindow windowmove 999 0 + ~~xdotool getactivewindow windowmove 999 0~~ # 项目结构 Tickeys-linux ``` ├── AUTHOURS +├── build.sh +├── build.spec pyinstaller打包用 +├── Changelog 版本变动说明 +├── deb.sh +├── dist +│   ├── make_deb.sh 打包成deb包的脚本 +├── lib 运行所用的一些库 ├── LICENSE ├── MANIFEST.in ├── README.md -├── setup.py -└── tickeys - ├── build.py - ├── CLI.py - ├── GUI.py - ├── config.py - ├── __init__.py - ├── KeyboardHandler.py - ├── logger.py - ├── requirements.txt - ├── Resources - │ └── data - │ ├── bubble - │ ├── mechanical - │ ├── sword - │ ├── typewriter - │ └── schemes.json - ├── run.py - ├── SoundPlayer.py - ├── StartupHandler.py - ├── tickeys - ├── tickeys.png - └── tickeysui.kv +├── screenshot Tickeys截图文件 +├── setup.py 分发用 +├── tickeys +│   ├── build.py cx_freeze打包,已不用 +│   ├── CLI.py 启动CLI的模块 +│   ├── config.py 处理配置保存和读取的模块 +│   ├── GUI.py 启动GUI的模块 +│   ├── __init__.py +│   ├── keyboardHandler.py 处理键盘输入的函数 +│   ├── logger.py 日志记录函数,调试时使用 +│   ├── requirements.txt 开发模块依赖包 +│   ├── Resources 程序资源,包括音效,字体等 +│   │   ├── data +│   │   │   ├── bubble +│   │   │   ├── Cherry_G80_3000 +│   │   │   ├── Cherry_G80_3494 +│   │   │   ├── drum +│   │   │   ├── mechanical +│   │   │   ├── sword +│   │   │   └── typewriter +│   │   │   ├── schemes.json +│   │   └── fonts +│   │   └── DroidSansFallbackFull.ttf +│   ├── run.py 程序入口 +│   ├── run_with_CLI.py 程序入口,带CLI版(失败时运行CLI) +│   ├── soundPlayer.py 播放声效的模块 +│   ├── startupHandler.py 控制开机自启动的模块 +│   ├── tickeys 启动tickeys的脚本,打包时放进打包后的文件夹使用 +│   ├── tickeys.png +│   ├── tickeys_tray.py 托盘,由于打包大小问题尚未放入 +│   ├── tickeysui.kv kv的ui文件,现在已直接写入GUI.py中 +│   └── windowManager.py 提供窗口控制的方法 +├── tickeys_0.2.3.deb +└── tickeys.egg-info ``` # 文件说明 @@ -175,25 +189,25 @@ Tickeys-linux * readme.txt 放进打包后程序文件夹的readme -* requirements.txt 开发模块依赖包 +* requirements.txt -* tickeys 启动tickeys的脚本,打包时放进打包后的文件夹使用 +* tickeys -* CLI.py 启动CLI的模块 +* CLI.py -* GUI.py 启动GUI的模块 +* GUI.py -* config.py 处理配置保存和读取的模块 +* config.py -* tickeysui.kv kv的ui文件,当在GUI中不使用load_string来创建时把此文件更名为Tickeys.kv使用 +* tickeysui.kv -* KeyboardHandler.py 处理键盘输入的函数 +* KeyboardHandler.py -* logger.py 日志记录函数,调试时使用 +* logger.py -* SoundPlayer.py 播放声效的模块 +* SoundPlayer.py -* StartupHandler.py 控制开机自启动的模块 +* StartupHandler.py # 问题 diff --git a/build.spec b/build.spec index 57a8666..c6c4a41 100644 --- a/build.spec +++ b/build.spec @@ -5,11 +5,6 @@ block_cipher = None a = Analysis(['./tickeys/run.py'], pathex=['./tickeys'], binaries=[ - ('lib/libSDL2_ttf-2.0.so.0',"."), - ('lib/libSDL2_image-2.0.so.0',"."), - ('lib/libSDL2_mixer-2.0.so.0',"."), - ('lib/libSDL2-2.0.so.0',"."), - ('lib/libsndio.so.6.0',"."), ], # 动态库 datas=[("./tickeys/tickeys.png",".")], # 数据文件,可以是任意文件类型,例如ini配置文件、字体文件、图片等 hiddenimports=['six','packaging', 'packaging.version', 'packaging.specifiers'], diff --git a/dist/make_deb.sh b/dist/make_deb.sh new file mode 100644 index 0000000..89757b4 --- /dev/null +++ b/dist/make_deb.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +echo "Creating tickeys.deb" +#Creating a .deb.. +mkdir -p tickeys/usr/local/bin +mkdir -p tickeys/usr/share/applications +mkdir -p tickeys/usr/share/app-install/desktop +mkdir -p tickeys/usr/share/Tickeys/icons +mkdir -p tickeys/DEBIAN + +cp tickeys.png tickeys/usr/share/Tickeys/icons/tickeys.png + +deb_control="Source: Tickeys +Priority: extra +Maintainer: Bill +Author: Bill +Build-Depends: debhelper (>= 8.0.0) +Standards-Version: 3.9.2 +Package: tickeys +Version: 0.2.3 +Architecture: i386 +Installed-Size: 32253411 +Description: Instant audio feedback when typing, For Linux. (https://github.com/BillBillBillBill/Tickeys-linux) +" + +echo "$deb_control" > tickeys/DEBIAN/control +chown root tickeys/DEBIAN/control + +desktop="#!/usr/bin/env xdg-open +[Desktop Entry] +Version=1.0 +Type=Application +Categories=Application; +Exec=gksu /usr/local/bin/Tickeys +Icon=/usr/share/Tickeys/icons/tickeys.png +Terminal=false +Hidden=false +NoDisplay=false +StartupNotify=true +X-GNOME-Autostart-enabled=true +Name=Tickeys +Comment=Instant audio feedback when typing. For Linux. +" + +echo "$desktop" > tickeys/usr/share/applications/Tickeys.desktop +chmod a+x tickeys/usr/share/applications/Tickeys.desktop +chown root tickeys/usr/share/applications/Tickeys.desktop + +echo "$desktop" > tickeys/usr/share/app-install/desktop/Tickeys.desktop +chmod a+x tickeys/usr/share/app-install/desktop/Tickeys.desktop +chown root tickeys/usr/share/app-install/desktop/Tickeys.desktop + +cp Tickeys tickeys/usr/local/bin/Tickeys + +dpkg-deb -z9 -b tickeys + + +echo "ok." diff --git a/tickeys/keyboardHandler.py b/tickeys/keyboardHandler.py index 6066c88..98e3365 100644 --- a/tickeys/keyboardHandler.py +++ b/tickeys/keyboardHandler.py @@ -54,7 +54,7 @@ def find_keyboard(self): keyboardList = [] deviceInfo = open('/proc/bus/input/devices').read().lower().split('\n\n') - for i in filter(lambda i: not re.search('touch', i) and + for i in filter(lambda i: not re.search('touch|web|cam|hdmi|button|mic|phone', i) and ((not re.search('mouse', i) and re.search('bus=0003', i)) or re.search('keyboard', i)) , deviceInfo): m = re.search('event\d+', i) diff --git a/tickeys/windowManager.py b/tickeys/windowManager.py index 10658cf..3c50cd9 100644 --- a/tickeys/windowManager.py +++ b/tickeys/windowManager.py @@ -2,14 +2,16 @@ import commands from logger import logger - +from threading import Thread def save_terminal_window_id(): try: stat, terminalId = commands.getstatusoutput('xdotool getactivewindow') - assert stat == 0 with open("/tmp/tickeys_terminal_window_id", "w+") as f: - f.write(terminalId) + if stat == 0: + f.write(terminalId) + else: + f.write(0) except Exception, e: logger.error("Save terminal window id fail:" + str(e)) @@ -35,9 +37,11 @@ def hide_terminal(): def save_GUI_window_id(): try: stat, GUIID = commands.getstatusoutput('xdotool getactivewindow') - assert stat == 0 with open("/tmp/tickeys_GUI_window_id", "w+") as f: - f.write(GUIID) + if stat == 0: + f.write(GUIID) + else: + f.write(0) except Exception, e: logger.error("Save GUI window id fail:" + str(e)) @@ -57,14 +61,27 @@ def hide_GUI(): def show_GUI(): + def show_notify(): + try: + import notify2 + notify2.init('Tickeys') + title = 'Tickeys' + body = '程序“xdotool”尚未安装, 无法隐藏窗口。' + iconfile = os.getcwd() + '/tickeys.png' + notify = notify2.Notification(title, body, iconfile) + notify.show() + except Exception: + return try: GUIID = read_GUI_window_id() - if not GUIID: + if not GUIID or GUIID == "0": + Thread(target=show_notify).start() return - # read window ids - command = "xdotool windowmap --sync %s && xdotool windowactivate --sync %s" % (GUIID, GUIID) - stat, output = commands.getstatusoutput(command) - return str(stat) + else: + # read window ids + command = "xdotool windowmap --sync %s && xdotool windowactivate --sync %s" % (GUIID, GUIID) + stat, output = commands.getstatusoutput(command) + return str(stat) except Exception, e: logger.error(str(e)) return '256'