Skip to content

Commit

Permalink
2016-01-25 version 0.2.2
Browse files Browse the repository at this point in the history
1.添加新音效(爆裂鼓手)
2.修改界面,现在显示中文
3.修改音效显示名称
4.修复一个键盘监测bug
5.再次运行程序自动打开设置界面
  • Loading branch information
BillBillBillBill committed Jan 25, 2016
1 parent 80d828f commit 4212644
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 64 deletions.
3 changes: 2 additions & 1 deletion Changelog
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
2016-01-23 version 0.2.2
2016-01-25 version 0.2.2
1.添加新音效(爆裂鼓手)
2.修改界面,现在显示中文
3.修改音效显示名称
4.修复一个键盘监测bug
5.再次运行程序自动打开设置界面

2015-10-31 version 0.2.1
1.修复错误弹出更新提示的bug
Expand Down
Binary file added screenshot/tickeys_v0.2.2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tickeys/CLI.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# coding: utf-8
import cmd
from KeyboardHandler import KeyboardHandler
from keyboardHandler import KeyboardHandler
from logger import logger
from __init__ import __version__
import sys
Expand Down
48 changes: 10 additions & 38 deletions tickeys/GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from kivy.uix.spinner import Spinner
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
from KeyboardHandler import KeyboardHandler
from keyboardHandler import KeyboardHandler
from kivy.lang import Builder
from StartupHandler import add_startup_linux, check_startup_file, delete_startup_linux
from startupHandler import add_startup_linux, check_startup_file, delete_startup_linux
from logger import logger
from config import Configer
from __init__ import __version__, debug_mode
Expand All @@ -15,6 +15,9 @@
import os
import commands
import webbrowser

from windowManager import hide_terminal, hide_GUI, save_GUI_window_id

reload(sys)
sys.setdefaultencoding("utf-8")

Expand Down Expand Up @@ -259,44 +262,14 @@ class Main(GridLayout):
def __init__(self, *args, **kwargs):
self.Configer = Configer()
super(Main, self).__init__(**kwargs)
self.terminalId = args[0] if args else None
self.GUIID = None
# tool works preget
if self.terminalId:
stat, GUIID = commands.getstatusoutput('xdotool getactivewindow')
if stat == 0:
self.GUIID = GUIID
# hide itself
# commands.getstatusoutput(
# 'xdotool getactivewindow windowminimize')
self.hide_GUI()
save_GUI_window_id()
self.Hide()
self.detecter = KeyboardHandler()
self.detecter.start_detecting()
self.detecter.GUIID = self.GUIID
if not debug_mode:
self.hide_terminal()
hide_terminal()
show_notify()

# @property
# def detecter(self):
# return self.detecter

def hide_terminal(self):
if not self.terminalId:
return
commands.getstatusoutput(
"xdotool windowactivate --sync %s" % self.terminalId)
commands.getstatusoutput(
"xdotool getactivewindow windowunmap")
# if want to show terminal use windowminimize

def hide_GUI(self):
try:
commands.getstatusoutput(
'xdotool windowunmap --sync %s' % self.GUIID)
except Exception,e:
logger.error(str(e))

def Exit(self):
self.detecter.stop_detecting()
# Show the terminal
Expand All @@ -309,17 +282,16 @@ def Exit(self):

def Hide(self):
if not debug_mode:
self.hide_GUI()
hide_GUI()


class TickeysApp(App):
def __init__(self, *args, **kwargs):
super(TickeysApp, self).__init__(**kwargs)
self.terminalId = args[0] if args else None

def build(self):
self.icon = 'tickeys.png'
root = Main(self.terminalId)
root = Main()
return root

def on_stop(self):
Expand Down
2 changes: 1 addition & 1 deletion tickeys/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__author__ = 'Huang Xiongbiao'
__email__ = '[email protected]'
__version__ = '0.2.2'
debug_mode = True
debug_mode = False

from run import main

Expand Down
18 changes: 4 additions & 14 deletions tickeys/KeyboardHandler.py → tickeys/keyboardHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import threading
from evdev import InputDevice
from select import select
from SoundPlayer import SoundPlayer
from soundPlayer import SoundPlayer
from logger import logger
import commands

from windowManager import show_GUI

__author__ = 'Huang xiongbiao([email protected])'

# input device file path
Expand All @@ -24,7 +26,6 @@ def __init__(self):
self.inputRecord = []
self.hotKey = [16, 30, 44, 2, 3, 4] # QAZ123
self.sp = SoundPlayer()
self.GUIID = None
self.show_device()

# list all event's name and its device
Expand All @@ -48,17 +49,6 @@ def set_pitch(self, pitch):
def get_player_infor(self):
return self.sp.get_infor()

@property
def GUIID(self):
return self.GUIID

def show_GUI(self):
if not self.GUIID:
return
# command = "xdotool windowactivate --sync %s" % self.GUIID
command = "xdotool windowmap --sync %s && xdotool windowactivate --sync %s" % (self.GUIID, self.GUIID)
commands.getstatusoutput(command)

# new way to find keyboard
# return with a list of keyboard's event
def find_keyboard(self):
Expand Down Expand Up @@ -127,7 +117,7 @@ def check_show_window(self, keycode):
self.inputRecord.append(keycode)
logger.debug(self.inputRecord)
if len(self.inputRecord) == 6:
self.show_GUI()
show_GUI()
self.inputRecord = []
else:
self.inputRecord = []
Expand Down
17 changes: 8 additions & 9 deletions tickeys/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from logger import logger
import sys
import os
import commands
import json
import requests
from threading import Thread

__version__ = '0.2.1'
from windowManager import save_terminal_window_id, check_tickeys_running_status

__version__ = '0.2.2'
__author__ = 'Huang xiongbiao([email protected])'


Expand All @@ -17,13 +17,8 @@ def run_GUI():
Thread(target=check_update, args=()).start()
check_system()
try:
stat, terminalId = commands.getstatusoutput('xdotool getactivewindow')
from GUI import TickeysApp
if stat == 0:
TickeysApp(terminalId).run()
else:
TickeysApp().run()

TickeysApp().run()
except Exception, e:
logger.info("Run GUI Fail, use CLI instead..Fail msg:%s" % str(e))
run_CLI()
Expand All @@ -48,6 +43,7 @@ def check_root():

def check_update():
try:
import requests
logger.info("Version checking...")
r = requests.get("http://billbill.sinaapp.com/tickeys")
returnInfor = json.loads(r.text)
Expand Down Expand Up @@ -92,6 +88,9 @@ def print_help_msg():

def main():
logger.debug("Tickeys start........")
is_running = check_tickeys_running_status()
if is_running:
return
if len(sys.argv) == 1:
run_GUI()
elif len(sys.argv) == 2:
Expand Down
File renamed without changes.
File renamed without changes.
80 changes: 80 additions & 0 deletions tickeys/windowManager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# coding: utf-8
import commands

from logger import logger


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)
except Exception, e:
logger.error("Save terminal window id fail:" + str(e))


def read_terminal_window_id():
with open("/tmp/tickeys_terminal_window_id", "r") as f:
return f.read()


def hide_terminal():
try:
terminalId = read_terminal_window_id()
if not terminalId:
return
commands.getstatusoutput(
"xdotool windowactivate --sync %s" % terminalId)
commands.getstatusoutput(
"xdotool getactivewindow windowunmap")
except Exception,e:
logger.error(str(e))


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)
except Exception, e:
logger.error("Save GUI window id fail:" + str(e))


def read_GUI_window_id():
with open("/tmp/tickeys_GUI_window_id", "r") as f:
return f.read()


def hide_GUI():
try:
GUIID = read_GUI_window_id()
commands.getstatusoutput(
'xdotool windowunmap --sync %s' % GUIID)
except Exception,e:
logger.error(str(e))


def show_GUI():
try:
GUIID = read_GUI_window_id()
if not GUIID:
return
# 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'

def check_tickeys_running_status():
save_terminal_window_id()
stat = show_GUI()
if stat != "0":
return False
else:
print "Tickeys is already running, show it"
hide_terminal()
return True

0 comments on commit 4212644

Please sign in to comment.