1.4.1
This commit is contained in:
parent
a2038ac40e
commit
89aa00ebf5
|
@ -2,12 +2,17 @@
|
|||
|
||||
### 介绍
|
||||
新版本Deepin/UOS发布后,可以在应用商店安装部分官方已适配的安卓应用,对爱好者来说,不能自己安装APK软件包始终差点意思,本程序可以为Deepin/UOS上的Uengine安卓运行环境安装自定义APK软件包,并能发送安装的APK包启动菜单到桌面或系统菜单。
|
||||
![1.4.0](https://storage.deepin.org/thread/202108191410327464_截图_选择区域_20210819140938.png)
|
||||
![1.4.1](https://storage.deepin.org/thread/20210826151947783_截图_选择区域_20210826151312.png)
|
||||
(测试平台:UOS 家庭版,deepin 20.2.2,UOS 专业版 1040)
|
||||
(自己美术功底太差,图标直接用 anbox 的了)
|
||||
|
||||
### 更新内容
|
||||
#### V1.4.0:
|
||||
#### V1.4.1(2021-08-26):
|
||||
**※1、初步支持键盘映射**
|
||||
2、修复新版包在发送uengine列表快捷方式时会提示找不到文件
|
||||
![](https://storage.deepin.org/thread/20210826151947783_截图_选择区域_20210826151312.png)
|
||||
|
||||
#### V1.4.0(2021-08-19):
|
||||
**※1、添加新版打包方式(deepin打包方式);**
|
||||
**※2、支持测试运行/创建/删除uengine图标;**
|
||||
**※3、支持提取安装的apk;**
|
||||
|
@ -18,7 +23,7 @@
|
|||
8、更多命令操作;
|
||||
![1.4.0](https://storage.deepin.org/thread/202108191410327464_截图_选择区域_20210819140938.png)
|
||||
|
||||
#### V1.3.2:
|
||||
#### V1.3.2(2021-08-16):
|
||||
**※1、支持uengine数据重置;**
|
||||
**※2、支持修改uengine网络桥接的启动状态;**
|
||||
**※3、支持右键安装/卸载;**
|
||||
|
@ -26,44 +31,44 @@
|
|||
**※5、修复打包问题,不会出现“dpkg:警告:卸载spark-uengine-runner时,目录/opt/apps/uengine-runner非空,因而不会删除该目录”的错误;**
|
||||
![1.3.2](https://storage.deepin.org/thread/202108152141139401_截图_选择区域_20210815213948.png)
|
||||
|
||||
#### V1.3.1:
|
||||
#### V1.3.1(2021-08-12):
|
||||
**※1、修复打包问题,防止部分用户安装出错的问题;**
|
||||
**※2、修复了程序无法提取图标时可以提取默认图标使用;**
|
||||
![1.3.1](https://storage.deepin.org/thread/202108121509217807_截图_选择区域_20210812150849.png)
|
||||
|
||||
#### V1.3.0:
|
||||
#### V1.3.0(2021-08-08):
|
||||
**※1、修改了界面布局;**
|
||||
**※2、修复大多数新安装普通用户的路图标及启动菜单文件路径不存在导致安装APK报错的bugs;**
|
||||
3、删除少量冗余代码,调整代码顺序;
|
||||
4、支持提取 apk 图标。
|
||||
![1.3.0](https://storage.deepin.org/thread/202108082100582804_截图_tk_20210808210047.png)
|
||||
|
||||
#### V1.2.3:
|
||||
#### V1.2.3(2021-08-02):
|
||||
1、调整部分控件名称;
|
||||
2、调整界面布局及界面风格;
|
||||
![1.2.3](https://images.gitee.com/uploads/images/2021/0802/080620_1dd289ca_7896131.png)
|
||||
|
||||
#### V1.2.2:
|
||||
#### V1.2.2(2021-07-11):
|
||||
1、对程序错误的显示更加人性化;
|
||||
2、对 icon 的获取方式进行了升级;
|
||||
3、增加了注释、删除部分冗余代码。
|
||||
![1.2.2](https://images.gitee.com/uploads/images/2021/0711/145140_b04e51b7_7896131.png)
|
||||
|
||||
#### V1.2.1:
|
||||
#### V1.2.1(2021-07-02):
|
||||
**※1、进行了安装方式的修改(不使用 adb),修复原无法安装和卸载的问题;**
|
||||
2、进行了部分优化;
|
||||
3、进行了功能缩水;
|
||||
4、修复 deb 打包错误。
|
||||
![1.2.1](https://images.gitee.com/uploads/images/2021/0702/204040_6abb6f3f_7896131.png)
|
||||
|
||||
#### V1.2.0:
|
||||
#### V1.2.0(2021-06-06):
|
||||
1、支持安装自动添加快捷方式、卸载删除快捷方式;
|
||||
2、支持使用包名或 APK 文件卸载程序;
|
||||
3、支持查看安装的所有包名;
|
||||
4、进行了部分优化
|
||||
![1.2.0](https://images.gitee.com/uploads/images/2021/0606/115536_0c0ddf38_7896131.png)
|
||||
|
||||
#### V1.1.0:
|
||||
#### V1.1.0(2021-05-30):
|
||||
1、修改了因编写时出现的中、英文混用的情况
|
||||
2、支持一键连接默认 IP
|
||||
3、修复在不连接设备直接选择 apk 安装时会卡住的问题
|
||||
|
@ -71,7 +76,7 @@
|
|||
5、修改了程序界面为白色调,不和标题栏冲突矛盾
|
||||
![1.1.0](https://images.gitee.com/uploads/images/2021/0530/133429_7e6bf629_7896131.png)
|
||||
|
||||
#### V1.0.0
|
||||
#### V1.0.0(2021-05-29):
|
||||
![1.0.0](https://images.gitee.com/uploads/images/2021/0529/173756_2e333c86_7896131.png)
|
||||
|
||||
### 源码安装教程
|
||||
|
|
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
Package: spark-uengine-runner
|
||||
Version: 1.4.0
|
||||
Version: 1.4.1
|
||||
Maintainer: gfdgd xi <3025613752@qq.com>, actionchen<917981399@qq.com>
|
||||
Homepage: [https://gitee.com/gfdgd-xi/uengine-runner, https://github.com/gfdgd-xi/uengine-runner]
|
||||
Architecture: all
|
||||
|
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
@ -1,8 +1,9 @@
|
|||
{
|
||||
"Url": [
|
||||
"https://gitee.com/gfdgd-xi/uengine-runner"
|
||||
"https://gitee.com/gfdgd-xi/uengine-runner",
|
||||
"https://github.com/gfdgd-xi/uengine-runner"
|
||||
],
|
||||
"Version": "1.4.0",
|
||||
"Version": "1.4.1",
|
||||
"System": "Linux(deepin/UOS)",
|
||||
"Tips": [
|
||||
" 新版本Deepin/UOS发布后,可以在应用商店安装部分官方已适配的安卓应用,对爱好者来说,不能自己安装APK软件包始终差点意思,本程序可以为Deepin/UOS上的Uengine安卓运行环境安装自定义APK软件包,并能发送安装的APK包启动菜单到桌面或系统菜单。",
|
||||
|
@ -13,6 +14,8 @@
|
|||
"",
|
||||
"保存APK图标:在安装APK下面的输入框浏览或输入APK的路径,然后点击“保存图标”按钮,选择保存位置即可",
|
||||
"",
|
||||
"键盘映射:详细请查看uengine键盘映射主界面",
|
||||
"",
|
||||
"重置(删除)uengine数据:点击菜单栏的“uengine”的“清空uengine数据”,输入密码重启即可",
|
||||
" 注意:如果任何安卓一遍打不开,多打开几遍应该就可以重新加载uengine配置了",
|
||||
"",
|
||||
|
@ -25,6 +28,10 @@
|
|||
"4、如果想要连接其他手机,请使用 1.2.0 以前的版本,可以使用 adb 连接。"
|
||||
],
|
||||
"Update": [
|
||||
"V1.4.1:",
|
||||
"※1、初步支持键盘映射",
|
||||
"2、修复新版包在发送uengine列表快捷方式时会提示找不到文件",
|
||||
"",
|
||||
"V1.4.0:",
|
||||
"※1、添加新版打包方式(deepin打包方式);",
|
||||
"※2、支持测试运行/创建/删除uengine图标;",
|
||||
|
@ -91,7 +98,7 @@
|
|||
"9、chmod",
|
||||
"……"
|
||||
],
|
||||
"Time": "2021年08月19日",
|
||||
"Time": "2021年08月26日",
|
||||
"Contribute": ["gfdgd xi<3025613752@qq.com>",
|
||||
"actionchen<917981399@qq.com>"]
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"Package": "spark-uengine-runner",
|
||||
"Update": true,
|
||||
"Version": "1.4.1",
|
||||
"Url": "https://gfdgd-xi.github.io/update-program/data/UpdateInformation.json"
|
||||
|
||||
}
|
|
@ -0,0 +1,209 @@
|
|||
#!/usr/bin/env python3
|
||||
#########################################
|
||||
# 版本:1.4.0
|
||||
# 更新时间:2021年08月26日
|
||||
#########################################
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import shutil
|
||||
import keyboard
|
||||
import traceback
|
||||
import ttkthemes
|
||||
import pyautogui
|
||||
import threading
|
||||
import tkinter as tk
|
||||
import tkinter.ttk as ttk
|
||||
import tkinter.messagebox as messagebox
|
||||
import tkinter.filedialog as filedialog
|
||||
|
||||
########################
|
||||
#
|
||||
########################
|
||||
def Inputt(key):
|
||||
if key.event_type == "down":
|
||||
global setting
|
||||
if setting:
|
||||
Setting(key)
|
||||
else:
|
||||
Mouse(key)
|
||||
|
||||
def Open():
|
||||
path = filedialog.askopenfilename(title="打开", filetypes=[["json 文件", "*.json"], ["全部文件", ["*.*"]]])
|
||||
if not path == "" or path == ():
|
||||
shutil.copy(path, get_home() + "/.config/uengine-keyboard/key.json")
|
||||
if messagebox.askyesno(title="提示", message="导入成功!是否现在重启程序以便生效?"):
|
||||
ReStartProgram()
|
||||
|
||||
def Save():
|
||||
path = filedialog.asksaveasfilename(title="打开", filetypes=[["json 文件", "*.json"], ["全部文件", ["*.*"]]])
|
||||
if not path == "" or path == ():
|
||||
shutil.copy(get_home() + "/.config/uengine-keyboard/key.json", path)
|
||||
messagebox.showinfo(title="提示", message="导出成功!")
|
||||
|
||||
# 重启本应用程序
|
||||
def ReStartProgram()->"重启本应用程序":
|
||||
python = sys.executable
|
||||
os.execl(python, python, * sys.argv)
|
||||
|
||||
|
||||
def Mouse(key):
|
||||
if keybo.__contains__(key.name):
|
||||
print(keybo[key.name]["MousePlace"])
|
||||
pyautogui.click(keybo[key.name]["MousePlace"][0], keybo[key.name]["MousePlace"][1])
|
||||
|
||||
def Setting(key):
|
||||
if key.event_type == 'up':
|
||||
keybo[key.name] = {"Mouse": "Left", "MousePlace": pyautogui.position()}
|
||||
write_txt("{}/.config/uengine-keyboard/key.json".format(get_home()), json.dumps(keybo))
|
||||
global inputs
|
||||
inputs = True
|
||||
global setting
|
||||
setting = False
|
||||
return False
|
||||
|
||||
def ShowTips():
|
||||
try:
|
||||
if setting:
|
||||
settingLabelText.set('''设置方法:把鼠标移动带所需位置然后按下需要设置的按键即可({}x{})
|
||||
提示:
|
||||
1、目前不支持同时按两个及以上按键,只支持在单一时间内按一个按键;
|
||||
2、使用映射不能关闭本窗口,但可以最小化;
|
||||
3、本程序需要 root 权限才能使用;
|
||||
4、映射时会占用鼠标,所以在使用时最好不要使用鼠标;'''.format(pyautogui.position()[0], pyautogui.position()[1]))
|
||||
settingButton.configure(state=tk.DISABLED)
|
||||
else:
|
||||
settingLabelText.set('''点击“设置”按钮设置映射({}x{})
|
||||
提示:
|
||||
1、目前不支持同时按两个及以上按键,只支持在单一时间内按一个按键;
|
||||
2、使用映射不能关闭本窗口,但可以最小化;
|
||||
3、本程序需要 root 权限才能使用;
|
||||
4、映射时会占用鼠标,所以在使用时最好不要使用鼠标;'''.format(pyautogui.position()[0], pyautogui.position()[1]))
|
||||
settingButton.configure(state=tk.NORMAL)
|
||||
time.sleep(0.1)
|
||||
ShowTips()
|
||||
except:
|
||||
pass
|
||||
|
||||
def Key():
|
||||
global inputs
|
||||
keyboard.hook(Inputt)
|
||||
|
||||
# 获取用户主目录
|
||||
def get_home()->"获取用户主目录":
|
||||
return os.path.expanduser('~')
|
||||
|
||||
# 写入文本文档
|
||||
def write_txt(path: "路径", things: "内容")->"写入文本文档":
|
||||
TxtDir = os.path.dirname(path)
|
||||
print(TxtDir)
|
||||
if not os.path.exists(TxtDir):
|
||||
os.makedirs(TxtDir,exist_ok=True)
|
||||
file = open(path, 'w', encoding='UTF-8') # 设置文件对象
|
||||
file.write(things) # 写入文本
|
||||
file.close() # 关闭文本对象
|
||||
|
||||
# 读取文本文档
|
||||
def readtxt(path: "路径")->"读取文本文档":
|
||||
f = open(path, "r") # 设置文件对象
|
||||
str = f.read() # 获取内容
|
||||
f.close() # 关闭文本对象
|
||||
return str # 返回结果
|
||||
|
||||
def Settings():
|
||||
global setting
|
||||
setting = True
|
||||
|
||||
def Clean():
|
||||
if messagebox.askokcancel(title="提示", message="你确定要删除吗?"):
|
||||
shutil.rmtree("{}/.config/uengine-keyboard".format(get_home()))
|
||||
if messagebox.askyesno(title="提示", message="删除成功!是否现在重启程序以便生效?"):
|
||||
ReStartProgram()
|
||||
|
||||
def About():
|
||||
threading.Thread(target=os.system, args=["{}/uengine-runner-about".format(programPath)]).start()
|
||||
|
||||
###################
|
||||
#
|
||||
###################
|
||||
if not os.path.exists("{}/.config/uengine-keyboard".format(get_home())):
|
||||
os.mkdir("{}/.config/uengine-keyboard".format(get_home()))
|
||||
if not os.path.exists("{}/.config/uengine-keyboard/key.json".format(get_home())):
|
||||
write_txt("{}/.config/uengine-keyboard/key.json".format(get_home()), "{}")
|
||||
|
||||
###################
|
||||
#
|
||||
###################
|
||||
setting = False
|
||||
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
|
||||
iconPath = "{}/icon.png".format(os.path.split(os.path.realpath(__file__))[0])
|
||||
keybo = json.loads(readtxt("{}/.config/uengine-keyboard/key.json".format(get_home())))
|
||||
version = json.loads(readtxt("{}/information.json".format(programPath)))["Version"]
|
||||
|
||||
###################
|
||||
# 判断是不是 root
|
||||
###################
|
||||
if os.geteuid() != 0:
|
||||
print("不是以 root 权限运行本程序!")
|
||||
root = tk.Tk()
|
||||
root.overrideredirect(1)
|
||||
root.withdraw()
|
||||
messagebox.showerror(title="错误", message="不是以 root 权限运行本程序!")
|
||||
sys.exit(1)
|
||||
|
||||
###################
|
||||
#
|
||||
###################
|
||||
window = tk.Tk()
|
||||
win = ttk.Frame(window)
|
||||
show = ttk.Frame(win)
|
||||
|
||||
settingLabelText = tk.StringVar()
|
||||
|
||||
# 设置菜单栏
|
||||
menu = tk.Menu(window, tearoff=0, background="white")
|
||||
programMenu = tk.Menu(menu, tearoff=0, background="white")
|
||||
aboutMenu = tk.Menu(menu, tearoff=0, background="white")
|
||||
|
||||
settingLabel = ttk.Label(win, textvariable=settingLabelText)
|
||||
|
||||
settingMouseToKeyboard = ttk.Button(show, text="启动键盘映射(已启用)")
|
||||
settingButton = ttk.Button(show, text="添加或覆盖键盘映射设置", command=Settings)
|
||||
|
||||
settingMouseToKeyboard.configure(state=tk.DISABLED)
|
||||
|
||||
style = ttkthemes.ThemedStyle(window)
|
||||
style.set_theme("breeze")
|
||||
window.resizable(0, 0)
|
||||
window.iconphoto(False, tk.PhotoImage(file=iconPath))
|
||||
window.title("uengine 键盘映射 {}".format(version))
|
||||
|
||||
menu.add_cascade(label="程序", menu=programMenu)
|
||||
menu.add_cascade(label="帮助", menu=aboutMenu)
|
||||
menu.configure(activebackground="dodgerblue")
|
||||
|
||||
programMenu.add_command(label="导入映射设置", command=Open)
|
||||
programMenu.add_command(label="导出映射设置", command=Save)
|
||||
programMenu.add_command(label="删除所有映射设置", command=Clean)
|
||||
programMenu.add_separator()
|
||||
programMenu.add_command(label="退出程序", command=sys.exit)
|
||||
programMenu.configure(activebackground="dodgerblue")
|
||||
|
||||
aboutMenu.add_command(label="关于", command=About)
|
||||
|
||||
window.config(menu=menu) # 显示菜单栏
|
||||
|
||||
show.grid(row=1, column=0)
|
||||
|
||||
settingLabel.grid(row=0, column=0)
|
||||
|
||||
settingMouseToKeyboard.grid(row=0, column=0)
|
||||
settingButton.grid(row=0, column=1)
|
||||
|
||||
win.pack(fill="both", expand="yes")
|
||||
|
||||
threading.Thread(target=Key).start()
|
||||
threading.Thread(target=ShowTips).start()
|
||||
|
||||
window.mainloop()
|
|
@ -2,8 +2,8 @@
|
|||
# 使用系统默认的 python3 运行
|
||||
###########################################################################################
|
||||
# 作者:gfdgd xi<3025613752@qq.com>
|
||||
# 版本:1.3.2
|
||||
# 更新时间:2021年8月15日
|
||||
# 版本:1.4.0
|
||||
# 更新时间:2021年8月26日
|
||||
# 感谢:anbox、deepin 和 UOS
|
||||
# 基于 Python3 的 tkinter 构建
|
||||
# 更新:actionchen<917981399@qq.com>
|
||||
|
@ -369,6 +369,9 @@ def saveicon():
|
|||
print(iconSavePath+"iconpaths")
|
||||
SaveApkIcon(temppath, iconSavePath)
|
||||
|
||||
def KeyboardToMouse():
|
||||
threading.Thread(target=os.system, args=["pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY {}/uengine-keyboard".format(programPath)]).start()
|
||||
|
||||
# 用户自行保存APK
|
||||
def SaveIconToOtherPath():
|
||||
apkPath = ComboInstallPath.get()
|
||||
|
@ -696,7 +699,7 @@ title = "uengine 运行器 {}".format(version)
|
|||
updateTime = information["Time"]
|
||||
updateThings = "{} 更新内容:\n{}\n更新时间:{}".format(version, updateThingsString, updateTime, time.strftime("%Y"))
|
||||
iconPath = "{}/icon.png".format(os.path.split(os.path.realpath(__file__))[0])
|
||||
desktop = "/opt/apps/uengine-runner/UengineAndroidProgramList.desktop"
|
||||
desktop = programPath + "/UengineAndroidProgramList.desktop"
|
||||
desktopName = "UengineAndroidProgramList.desktop"
|
||||
contribute = "\n".join(information["Contribute"])
|
||||
useProgram = "\n".join(information["Use"])
|
||||
|
@ -884,6 +887,7 @@ programmenu.add_separator() # 设置分界线
|
|||
programmenu.add_command(label="退出程序", command=window.quit) # 设置“退出程序”
|
||||
|
||||
uengine.add_command(label="uengine 应用打包", command=OpenUengineDebBuilder)
|
||||
uengine.add_command(label="uengine 键盘映射", command=KeyboardToMouse)
|
||||
uengine.add_cascade(label="uengine 服务", menu=uengineService)
|
||||
uengine.add_cascade(label="uengine 网络桥接", menu=uengineInternet)
|
||||
uengine.add_cascade(label="uengine 快捷方式", menu=uengineIcon)
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import shutil
|
||||
import requests
|
||||
import traceback
|
||||
|
||||
# 读取文本文档
|
||||
def read_txt(path):
|
||||
f = open(path,"r") # 设置文件对象
|
||||
str = f.read() # 获取内容
|
||||
f.close() # 关闭文本对象
|
||||
return str # 返回结果
|
||||
|
||||
def GetPackageUpdateInformation():
|
||||
global setting
|
||||
global package
|
||||
for i in allJson['Program']:
|
||||
if i['Package'] == package:
|
||||
return i
|
||||
|
||||
try:
|
||||
setting = json.loads(read_txt("{}/setting.json".format(os.path.split(os.path.realpath(__file__))[0])))
|
||||
except:
|
||||
traceback.print_exc()
|
||||
print("配置文件无法访问!")
|
||||
package = setting['Package']
|
||||
nowVersion = setting['Version']
|
||||
try:
|
||||
jsons = requests.get(setting["Url"])
|
||||
except:
|
||||
traceback.print_exc()
|
||||
print("服务器出现错误!")
|
||||
sys.exit(1)
|
||||
allJson = json.loads(jsons.text)
|
||||
updateInformation = GetPackageUpdateInformation()
|
||||
name = updateInformation['Name']
|
||||
newVersion = updateInformation['Version']
|
||||
print("更新程序:{}".format(name))
|
||||
print("最新版本:{}".format(newVersion))
|
||||
print("目前版本:{}".format(nowVersion))
|
||||
if nowVersion == newVersion:
|
||||
print("目前是最新版本,无需更新!")
|
||||
quit()
|
||||
print("更新内容:")
|
||||
print(updateInformation['New Things'])
|
||||
choose = input("更新?[Y/N]")
|
||||
if choose.upper() == "N":
|
||||
quit()
|
||||
if os.path.exists("/tmp/update-console-{}".format(package)):
|
||||
shutil.rmtree("/tmp/update-console-{}".format(package))
|
||||
os.mkdir("/tmp/update-console-{}".format(package))
|
||||
if updateInformation["Linux App Url"][0] == None:
|
||||
print("没有可用包源")
|
||||
quit()
|
||||
os.system("wget '{}' -P '/tmp/update-console-{}'".format(updateInformation["Linux App Url"][0], package))
|
||||
os.system("sudo dpkg -i /tmp/update-console-{}/*".format(package))
|
||||
os.system("sudo apt install -f -y")
|
|
@ -0,0 +1 @@
|
|||
/opt/apps/uengine-runner/uengine-keyboard
|
Binary file not shown.
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
@ -1,8 +1,9 @@
|
|||
{
|
||||
"Url": [
|
||||
"https://gitee.com/gfdgd-xi/uengine-runner"
|
||||
"https://gitee.com/gfdgd-xi/uengine-runner",
|
||||
"https://github.com/gfdgd-xi/uengine-runner"
|
||||
],
|
||||
"Version": "1.4.0",
|
||||
"Version": "1.4.1",
|
||||
"System": "Linux(deepin/UOS)",
|
||||
"Tips": [
|
||||
" 新版本Deepin/UOS发布后,可以在应用商店安装部分官方已适配的安卓应用,对爱好者来说,不能自己安装APK软件包始终差点意思,本程序可以为Deepin/UOS上的Uengine安卓运行环境安装自定义APK软件包,并能发送安装的APK包启动菜单到桌面或系统菜单。",
|
||||
|
@ -13,6 +14,8 @@
|
|||
"",
|
||||
"保存APK图标:在安装APK下面的输入框浏览或输入APK的路径,然后点击“保存图标”按钮,选择保存位置即可",
|
||||
"",
|
||||
"键盘映射:详细请查看uengine键盘映射主界面",
|
||||
"",
|
||||
"重置(删除)uengine数据:点击菜单栏的“uengine”的“清空uengine数据”,输入密码重启即可",
|
||||
" 注意:如果任何安卓一遍打不开,多打开几遍应该就可以重新加载uengine配置了",
|
||||
"",
|
||||
|
@ -25,6 +28,10 @@
|
|||
"4、如果想要连接其他手机,请使用 1.2.0 以前的版本,可以使用 adb 连接。"
|
||||
],
|
||||
"Update": [
|
||||
"V1.4.1:",
|
||||
"※1、初步支持键盘映射",
|
||||
"2、修复新版包在发送uengine列表快捷方式时会提示找不到文件",
|
||||
"",
|
||||
"V1.4.0:",
|
||||
"※1、添加新版打包方式(deepin打包方式);",
|
||||
"※2、支持测试运行/创建/删除uengine图标;",
|
||||
|
@ -91,7 +98,7 @@
|
|||
"9、chmod",
|
||||
"……"
|
||||
],
|
||||
"Time": "2021年08月19日",
|
||||
"Time": "2021年08月26日",
|
||||
"Contribute": ["gfdgd xi<3025613752@qq.com>",
|
||||
"actionchen<917981399@qq.com>"]
|
||||
}
|
10
main.py
10
main.py
|
@ -2,8 +2,8 @@
|
|||
# 使用系统默认的 python3 运行
|
||||
###########################################################################################
|
||||
# 作者:gfdgd xi<3025613752@qq.com>
|
||||
# 版本:1.3.2
|
||||
# 更新时间:2021年8月15日
|
||||
# 版本:1.4.0
|
||||
# 更新时间:2021年8月26日
|
||||
# 感谢:anbox、deepin 和 UOS
|
||||
# 基于 Python3 的 tkinter 构建
|
||||
# 更新:actionchen<917981399@qq.com>
|
||||
|
@ -369,6 +369,9 @@ def saveicon():
|
|||
print(iconSavePath+"iconpaths")
|
||||
SaveApkIcon(temppath, iconSavePath)
|
||||
|
||||
def KeyboardToMouse():
|
||||
threading.Thread(target=os.system, args=["pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY {}/uengine-keyboard".format(programPath)]).start()
|
||||
|
||||
# 用户自行保存APK
|
||||
def SaveIconToOtherPath():
|
||||
apkPath = ComboInstallPath.get()
|
||||
|
@ -696,7 +699,7 @@ title = "uengine 运行器 {}".format(version)
|
|||
updateTime = information["Time"]
|
||||
updateThings = "{} 更新内容:\n{}\n更新时间:{}".format(version, updateThingsString, updateTime, time.strftime("%Y"))
|
||||
iconPath = "{}/icon.png".format(os.path.split(os.path.realpath(__file__))[0])
|
||||
desktop = "/opt/apps/uengine-runner/UengineAndroidProgramList.desktop"
|
||||
desktop = programPath + "/UengineAndroidProgramList.desktop"
|
||||
desktopName = "UengineAndroidProgramList.desktop"
|
||||
contribute = "\n".join(information["Contribute"])
|
||||
useProgram = "\n".join(information["Use"])
|
||||
|
@ -884,6 +887,7 @@ programmenu.add_separator() # 设置分界线
|
|||
programmenu.add_command(label="退出程序", command=window.quit) # 设置“退出程序”
|
||||
|
||||
uengine.add_command(label="uengine 应用打包", command=OpenUengineDebBuilder)
|
||||
uengine.add_command(label="uengine 键盘映射", command=KeyboardToMouse)
|
||||
uengine.add_cascade(label="uengine 服务", menu=uengineService)
|
||||
uengine.add_cascade(label="uengine 网络桥接", menu=uengineInternet)
|
||||
uengine.add_cascade(label="uengine 快捷方式", menu=uengineIcon)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Package: com.gitee.uengine.runner.spark
|
||||
Source: spark-uengine-runner
|
||||
Version: 1.4.0
|
||||
Version: 1.4.1
|
||||
Architecture: all
|
||||
Maintainer: gfdgd xi <3025613752@qq.com>, actionchen<917981399@qq.com>
|
||||
Depends: deepin-elf-verify (>= 0.0.16.7-1), python3, python3-tk, python3-pip, aapt, adb, python3-pil, python3-setuptools, uengine
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
# 使用 pip 安装所需库
|
||||
python3 -m pip install --upgrade ttkthemes
|
||||
# 建立软链接
|
||||
ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-runner /usr/bin/uengine-runner
|
||||
ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-apk-builder /usr/bin/uengine-apk-builder
|
||||
ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-runner /usr/bin/uengine-runner
|
||||
ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-apk-builder /usr/bin/uengine-apk-builder
|
||||
ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-app-uninstall /usr/bin/uengine-app-uninstall
|
||||
ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-app-install /usr/bin/uengine-app-install
|
||||
ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-clean /usr/bin/uengine-clean
|
||||
ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-runner-about /usr/bin/uengine-runner-about
|
||||
ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-app-install /usr/bin/uengine-app-install
|
||||
ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-clean /usr/bin/uengine-clean
|
||||
ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-runner-about /usr/bin/uengine-runner-about
|
||||
ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-keyboard /usr/bin/uengine-keyboard
|
|
@ -5,4 +5,5 @@ rm -fv /usr/bin/uengine-apk-builder
|
|||
rm -fv /usr/bin/uengine-app-uninstall
|
||||
rm -fv /usr/bin/uengine-app-install
|
||||
rm -fv /usr/bin/uengine-clean
|
||||
rm -fv /usr/bin/uengine-runner-about
|
||||
rm -fv /usr/bin/uengine-runner-about
|
||||
rm -fv /usr/bin/uengine-keyboard
|
|
@ -3,7 +3,7 @@ Categories=System;
|
|||
Comment=uengine(anbox) 程序菜单
|
||||
Encoding=UTF-8
|
||||
Exec=/usr/bin/uengine-launch.sh --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity
|
||||
Icon=/opt/apps/uengine-runner/icon.png
|
||||
Icon=/opt/apps/com.gitee.uengine.runner.spark/files/icon.png
|
||||
MimeType=
|
||||
Name=uengine 程序菜单
|
||||
StartupWMClass=uengine 程序菜单
|
||||
|
|
0
new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/getxmlimg.py
Normal file → Executable file
0
new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/getxmlimg.py
Normal file → Executable file
0
new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/icon.png
Normal file → Executable file
0
new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/icon.png
Normal file → Executable file
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
13
new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/information.json
Normal file → Executable file
13
new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/information.json
Normal file → Executable file
|
@ -1,8 +1,9 @@
|
|||
{
|
||||
"Url": [
|
||||
"https://gitee.com/gfdgd-xi/uengine-runner"
|
||||
"https://gitee.com/gfdgd-xi/uengine-runner",
|
||||
"https://github.com/gfdgd-xi/uengine-runner"
|
||||
],
|
||||
"Version": "1.4.0",
|
||||
"Version": "1.4.1",
|
||||
"System": "Linux(deepin/UOS)",
|
||||
"Tips": [
|
||||
" 新版本Deepin/UOS发布后,可以在应用商店安装部分官方已适配的安卓应用,对爱好者来说,不能自己安装APK软件包始终差点意思,本程序可以为Deepin/UOS上的Uengine安卓运行环境安装自定义APK软件包,并能发送安装的APK包启动菜单到桌面或系统菜单。",
|
||||
|
@ -13,6 +14,8 @@
|
|||
"",
|
||||
"保存APK图标:在安装APK下面的输入框浏览或输入APK的路径,然后点击“保存图标”按钮,选择保存位置即可",
|
||||
"",
|
||||
"键盘映射:详细请查看uengine键盘映射主界面",
|
||||
"",
|
||||
"重置(删除)uengine数据:点击菜单栏的“uengine”的“清空uengine数据”,输入密码重启即可",
|
||||
" 注意:如果任何安卓一遍打不开,多打开几遍应该就可以重新加载uengine配置了",
|
||||
"",
|
||||
|
@ -25,6 +28,10 @@
|
|||
"4、如果想要连接其他手机,请使用 1.2.0 以前的版本,可以使用 adb 连接。"
|
||||
],
|
||||
"Update": [
|
||||
"V1.4.1:",
|
||||
"※1、初步支持键盘映射",
|
||||
"2、修复新版包在发送uengine列表快捷方式时会提示找不到文件",
|
||||
"",
|
||||
"V1.4.0:",
|
||||
"※1、添加新版打包方式(deepin打包方式);",
|
||||
"※2、支持测试运行/创建/删除uengine图标;",
|
||||
|
@ -91,7 +98,7 @@
|
|||
"9、chmod",
|
||||
"……"
|
||||
],
|
||||
"Time": "2021年08月19日",
|
||||
"Time": "2021年08月26日",
|
||||
"Contribute": ["gfdgd xi<3025613752@qq.com>",
|
||||
"actionchen<917981399@qq.com>"]
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Package": "com.gitee.uengine.runner.spark",
|
||||
"Update": true,
|
||||
"Version": "1.4.1",
|
||||
"Url": "https://gfdgd-xi.github.io/update-program/data/UpdateInformation.json"
|
||||
}
|
0
new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/uengine-clean
Normal file → Executable file
0
new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/uengine-clean
Normal file → Executable file
|
@ -0,0 +1,209 @@
|
|||
#!/usr/bin/env python3
|
||||
#########################################
|
||||
# 版本:1.4.0
|
||||
# 更新时间:2021年08月26日
|
||||
#########################################
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import shutil
|
||||
import keyboard
|
||||
import traceback
|
||||
import ttkthemes
|
||||
import pyautogui
|
||||
import threading
|
||||
import tkinter as tk
|
||||
import tkinter.ttk as ttk
|
||||
import tkinter.messagebox as messagebox
|
||||
import tkinter.filedialog as filedialog
|
||||
|
||||
########################
|
||||
#
|
||||
########################
|
||||
def Inputt(key):
|
||||
if key.event_type == "down":
|
||||
global setting
|
||||
if setting:
|
||||
Setting(key)
|
||||
else:
|
||||
Mouse(key)
|
||||
|
||||
def Open():
|
||||
path = filedialog.askopenfilename(title="打开", filetypes=[["json 文件", "*.json"], ["全部文件", ["*.*"]]])
|
||||
if not path == "" or path == ():
|
||||
shutil.copy(path, get_home() + "/.config/uengine-keyboard/key.json")
|
||||
if messagebox.askyesno(title="提示", message="导入成功!是否现在重启程序以便生效?"):
|
||||
ReStartProgram()
|
||||
|
||||
def Save():
|
||||
path = filedialog.asksaveasfilename(title="打开", filetypes=[["json 文件", "*.json"], ["全部文件", ["*.*"]]])
|
||||
if not path == "" or path == ():
|
||||
shutil.copy(get_home() + "/.config/uengine-keyboard/key.json", path)
|
||||
messagebox.showinfo(title="提示", message="导出成功!")
|
||||
|
||||
# 重启本应用程序
|
||||
def ReStartProgram()->"重启本应用程序":
|
||||
python = sys.executable
|
||||
os.execl(python, python, * sys.argv)
|
||||
|
||||
|
||||
def Mouse(key):
|
||||
if keybo.__contains__(key.name):
|
||||
print(keybo[key.name]["MousePlace"])
|
||||
pyautogui.click(keybo[key.name]["MousePlace"][0], keybo[key.name]["MousePlace"][1])
|
||||
|
||||
def Setting(key):
|
||||
if key.event_type == 'up':
|
||||
keybo[key.name] = {"Mouse": "Left", "MousePlace": pyautogui.position()}
|
||||
write_txt("{}/.config/uengine-keyboard/key.json".format(get_home()), json.dumps(keybo))
|
||||
global inputs
|
||||
inputs = True
|
||||
global setting
|
||||
setting = False
|
||||
return False
|
||||
|
||||
def ShowTips():
|
||||
try:
|
||||
if setting:
|
||||
settingLabelText.set('''设置方法:把鼠标移动带所需位置然后按下需要设置的按键即可({}x{})
|
||||
提示:
|
||||
1、目前不支持同时按两个及以上按键,只支持在单一时间内按一个按键;
|
||||
2、使用映射不能关闭本窗口,但可以最小化;
|
||||
3、本程序需要 root 权限才能使用;
|
||||
4、映射时会占用鼠标,所以在使用时最好不要使用鼠标;'''.format(pyautogui.position()[0], pyautogui.position()[1]))
|
||||
settingButton.configure(state=tk.DISABLED)
|
||||
else:
|
||||
settingLabelText.set('''点击“设置”按钮设置映射({}x{})
|
||||
提示:
|
||||
1、目前不支持同时按两个及以上按键,只支持在单一时间内按一个按键;
|
||||
2、使用映射不能关闭本窗口,但可以最小化;
|
||||
3、本程序需要 root 权限才能使用;
|
||||
4、映射时会占用鼠标,所以在使用时最好不要使用鼠标;'''.format(pyautogui.position()[0], pyautogui.position()[1]))
|
||||
settingButton.configure(state=tk.NORMAL)
|
||||
time.sleep(0.1)
|
||||
ShowTips()
|
||||
except:
|
||||
pass
|
||||
|
||||
def Key():
|
||||
global inputs
|
||||
keyboard.hook(Inputt)
|
||||
|
||||
# 获取用户主目录
|
||||
def get_home()->"获取用户主目录":
|
||||
return os.path.expanduser('~')
|
||||
|
||||
# 写入文本文档
|
||||
def write_txt(path: "路径", things: "内容")->"写入文本文档":
|
||||
TxtDir = os.path.dirname(path)
|
||||
print(TxtDir)
|
||||
if not os.path.exists(TxtDir):
|
||||
os.makedirs(TxtDir,exist_ok=True)
|
||||
file = open(path, 'w', encoding='UTF-8') # 设置文件对象
|
||||
file.write(things) # 写入文本
|
||||
file.close() # 关闭文本对象
|
||||
|
||||
# 读取文本文档
|
||||
def readtxt(path: "路径")->"读取文本文档":
|
||||
f = open(path, "r") # 设置文件对象
|
||||
str = f.read() # 获取内容
|
||||
f.close() # 关闭文本对象
|
||||
return str # 返回结果
|
||||
|
||||
def Settings():
|
||||
global setting
|
||||
setting = True
|
||||
|
||||
def Clean():
|
||||
if messagebox.askokcancel(title="提示", message="你确定要删除吗?"):
|
||||
shutil.rmtree("{}/.config/uengine-keyboard".format(get_home()))
|
||||
if messagebox.askyesno(title="提示", message="删除成功!是否现在重启程序以便生效?"):
|
||||
ReStartProgram()
|
||||
|
||||
def About():
|
||||
threading.Thread(target=os.system, args=["{}/uengine-runner-about".format(programPath)]).start()
|
||||
|
||||
###################
|
||||
#
|
||||
###################
|
||||
if not os.path.exists("{}/.config/uengine-keyboard".format(get_home())):
|
||||
os.mkdir("{}/.config/uengine-keyboard".format(get_home()))
|
||||
if not os.path.exists("{}/.config/uengine-keyboard/key.json".format(get_home())):
|
||||
write_txt("{}/.config/uengine-keyboard/key.json".format(get_home()), "{}")
|
||||
|
||||
###################
|
||||
#
|
||||
###################
|
||||
setting = False
|
||||
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
|
||||
iconPath = "{}/icon.png".format(os.path.split(os.path.realpath(__file__))[0])
|
||||
keybo = json.loads(readtxt("{}/.config/uengine-keyboard/key.json".format(get_home())))
|
||||
version = json.loads(readtxt("{}/information.json".format(programPath)))["Version"]
|
||||
|
||||
###################
|
||||
# 判断是不是 root
|
||||
###################
|
||||
if os.geteuid() != 0:
|
||||
print("不是以 root 权限运行本程序!")
|
||||
root = tk.Tk()
|
||||
root.overrideredirect(1)
|
||||
root.withdraw()
|
||||
messagebox.showerror(title="错误", message="不是以 root 权限运行本程序!")
|
||||
sys.exit(1)
|
||||
|
||||
###################
|
||||
#
|
||||
###################
|
||||
window = tk.Tk()
|
||||
win = ttk.Frame(window)
|
||||
show = ttk.Frame(win)
|
||||
|
||||
settingLabelText = tk.StringVar()
|
||||
|
||||
# 设置菜单栏
|
||||
menu = tk.Menu(window, tearoff=0, background="white")
|
||||
programMenu = tk.Menu(menu, tearoff=0, background="white")
|
||||
aboutMenu = tk.Menu(menu, tearoff=0, background="white")
|
||||
|
||||
settingLabel = ttk.Label(win, textvariable=settingLabelText)
|
||||
|
||||
settingMouseToKeyboard = ttk.Button(show, text="启动键盘映射(已启用)")
|
||||
settingButton = ttk.Button(show, text="添加或覆盖键盘映射设置", command=Settings)
|
||||
|
||||
settingMouseToKeyboard.configure(state=tk.DISABLED)
|
||||
|
||||
style = ttkthemes.ThemedStyle(window)
|
||||
style.set_theme("breeze")
|
||||
window.resizable(0, 0)
|
||||
window.iconphoto(False, tk.PhotoImage(file=iconPath))
|
||||
window.title("uengine 键盘映射 {}".format(version))
|
||||
|
||||
menu.add_cascade(label="程序", menu=programMenu)
|
||||
menu.add_cascade(label="帮助", menu=aboutMenu)
|
||||
menu.configure(activebackground="dodgerblue")
|
||||
|
||||
programMenu.add_command(label="导入映射设置", command=Open)
|
||||
programMenu.add_command(label="导出映射设置", command=Save)
|
||||
programMenu.add_command(label="删除所有映射设置", command=Clean)
|
||||
programMenu.add_separator()
|
||||
programMenu.add_command(label="退出程序", command=sys.exit)
|
||||
programMenu.configure(activebackground="dodgerblue")
|
||||
|
||||
aboutMenu.add_command(label="关于", command=About)
|
||||
|
||||
window.config(menu=menu) # 显示菜单栏
|
||||
|
||||
show.grid(row=1, column=0)
|
||||
|
||||
settingLabel.grid(row=0, column=0)
|
||||
|
||||
settingMouseToKeyboard.grid(row=0, column=0)
|
||||
settingButton.grid(row=0, column=1)
|
||||
|
||||
win.pack(fill="both", expand="yes")
|
||||
|
||||
threading.Thread(target=Key).start()
|
||||
threading.Thread(target=ShowTips).start()
|
||||
|
||||
window.mainloop()
|
|
@ -2,8 +2,8 @@
|
|||
# 使用系统默认的 python3 运行
|
||||
###########################################################################################
|
||||
# 作者:gfdgd xi<3025613752@qq.com>
|
||||
# 版本:1.3.2
|
||||
# 更新时间:2021年8月15日
|
||||
# 版本:1.4.0
|
||||
# 更新时间:2021年8月26日
|
||||
# 感谢:anbox、deepin 和 UOS
|
||||
# 基于 Python3 的 tkinter 构建
|
||||
# 更新:actionchen<917981399@qq.com>
|
||||
|
@ -369,6 +369,9 @@ def saveicon():
|
|||
print(iconSavePath+"iconpaths")
|
||||
SaveApkIcon(temppath, iconSavePath)
|
||||
|
||||
def KeyboardToMouse():
|
||||
threading.Thread(target=os.system, args=["pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY {}/uengine-keyboard".format(programPath)]).start()
|
||||
|
||||
# 用户自行保存APK
|
||||
def SaveIconToOtherPath():
|
||||
apkPath = ComboInstallPath.get()
|
||||
|
@ -696,7 +699,7 @@ title = "uengine 运行器 {}".format(version)
|
|||
updateTime = information["Time"]
|
||||
updateThings = "{} 更新内容:\n{}\n更新时间:{}".format(version, updateThingsString, updateTime, time.strftime("%Y"))
|
||||
iconPath = "{}/icon.png".format(os.path.split(os.path.realpath(__file__))[0])
|
||||
desktop = "/opt/apps/uengine-runner/UengineAndroidProgramList.desktop"
|
||||
desktop = programPath + "/UengineAndroidProgramList.desktop"
|
||||
desktopName = "UengineAndroidProgramList.desktop"
|
||||
contribute = "\n".join(information["Contribute"])
|
||||
useProgram = "\n".join(information["Use"])
|
||||
|
@ -884,6 +887,7 @@ programmenu.add_separator() # 设置分界线
|
|||
programmenu.add_command(label="退出程序", command=window.quit) # 设置“退出程序”
|
||||
|
||||
uengine.add_command(label="uengine 应用打包", command=OpenUengineDebBuilder)
|
||||
uengine.add_command(label="uengine 键盘映射", command=KeyboardToMouse)
|
||||
uengine.add_cascade(label="uengine 服务", menu=uengineService)
|
||||
uengine.add_cascade(label="uengine 网络桥接", menu=uengineInternet)
|
||||
uengine.add_cascade(label="uengine 快捷方式", menu=uengineIcon)
|
||||
|
|
0
new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/uengine-runner-about
Normal file → Executable file
0
new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/uengine-runner-about
Normal file → Executable file
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import shutil
|
||||
import requests
|
||||
import traceback
|
||||
|
||||
# 读取文本文档
|
||||
def read_txt(path):
|
||||
f = open(path,"r") # 设置文件对象
|
||||
str = f.read() # 获取内容
|
||||
f.close() # 关闭文本对象
|
||||
return str # 返回结果
|
||||
|
||||
def GetPackageUpdateInformation():
|
||||
global setting
|
||||
global package
|
||||
for i in allJson['Program']:
|
||||
if i['Package'] == package:
|
||||
return i
|
||||
|
||||
try:
|
||||
setting = json.loads(read_txt("{}/setting.json".format(os.path.split(os.path.realpath(__file__))[0])))
|
||||
except:
|
||||
traceback.print_exc()
|
||||
print("配置文件无法访问!")
|
||||
package = setting['Package']
|
||||
nowVersion = setting['Version']
|
||||
try:
|
||||
jsons = requests.get(setting["Url"])
|
||||
except:
|
||||
traceback.print_exc()
|
||||
print("服务器出现错误!")
|
||||
sys.exit(1)
|
||||
allJson = json.loads(jsons.text)
|
||||
updateInformation = GetPackageUpdateInformation()
|
||||
name = updateInformation['Name']
|
||||
newVersion = updateInformation['Version']
|
||||
print("更新程序:{}".format(name))
|
||||
print("最新版本:{}".format(newVersion))
|
||||
print("目前版本:{}".format(nowVersion))
|
||||
if nowVersion == newVersion:
|
||||
print("目前是最新版本,无需更新!")
|
||||
quit()
|
||||
print("更新内容:")
|
||||
print(updateInformation['New Things'])
|
||||
choose = input("更新?[Y/N]")
|
||||
if choose.upper() == "N":
|
||||
quit()
|
||||
if os.path.exists("/tmp/update-console-{}".format(package)):
|
||||
shutil.rmtree("/tmp/update-console-{}".format(package))
|
||||
os.mkdir("/tmp/update-console-{}".format(package))
|
||||
if updateInformation["Linux App Url"][0] == None:
|
||||
print("没有可用包源")
|
||||
quit()
|
||||
os.system("wget '{}' -P '/tmp/update-console-{}'".format(updateInformation["Linux App Url"][0], package))
|
||||
os.system("sudo dpkg -i /tmp/update-console-{}/*".format(package))
|
||||
os.system("sudo apt install -f -y")
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"Package": "com.gitee.uengine.runner.spark",
|
||||
"Update": true,
|
||||
"Version": "1.4.1",
|
||||
"Url": "https://gfdgd-xi.github.io/update-program/data/UpdateInformation.json"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"Package": "spark-uengine-runner",
|
||||
"Update": true,
|
||||
"Version": "1.4.1",
|
||||
"Url": "https://gfdgd-xi.github.io/update-program/data/UpdateInformation.json"
|
||||
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,209 @@
|
|||
#!/usr/bin/env python3
|
||||
#########################################
|
||||
# 版本:1.4.0
|
||||
# 更新时间:2021年08月26日
|
||||
#########################################
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import shutil
|
||||
import keyboard
|
||||
import traceback
|
||||
import ttkthemes
|
||||
import pyautogui
|
||||
import threading
|
||||
import tkinter as tk
|
||||
import tkinter.ttk as ttk
|
||||
import tkinter.messagebox as messagebox
|
||||
import tkinter.filedialog as filedialog
|
||||
|
||||
########################
|
||||
#
|
||||
########################
|
||||
def Inputt(key):
|
||||
if key.event_type == "down":
|
||||
global setting
|
||||
if setting:
|
||||
Setting(key)
|
||||
else:
|
||||
Mouse(key)
|
||||
|
||||
def Open():
|
||||
path = filedialog.askopenfilename(title="打开", filetypes=[["json 文件", "*.json"], ["全部文件", ["*.*"]]])
|
||||
if not path == "" or path == ():
|
||||
shutil.copy(path, get_home() + "/.config/uengine-keyboard/key.json")
|
||||
if messagebox.askyesno(title="提示", message="导入成功!是否现在重启程序以便生效?"):
|
||||
ReStartProgram()
|
||||
|
||||
def Save():
|
||||
path = filedialog.asksaveasfilename(title="打开", filetypes=[["json 文件", "*.json"], ["全部文件", ["*.*"]]])
|
||||
if not path == "" or path == ():
|
||||
shutil.copy(get_home() + "/.config/uengine-keyboard/key.json", path)
|
||||
messagebox.showinfo(title="提示", message="导出成功!")
|
||||
|
||||
# 重启本应用程序
|
||||
def ReStartProgram()->"重启本应用程序":
|
||||
python = sys.executable
|
||||
os.execl(python, python, * sys.argv)
|
||||
|
||||
|
||||
def Mouse(key):
|
||||
if keybo.__contains__(key.name):
|
||||
print(keybo[key.name]["MousePlace"])
|
||||
pyautogui.click(keybo[key.name]["MousePlace"][0], keybo[key.name]["MousePlace"][1])
|
||||
|
||||
def Setting(key):
|
||||
if key.event_type == 'up':
|
||||
keybo[key.name] = {"Mouse": "Left", "MousePlace": pyautogui.position()}
|
||||
write_txt("{}/.config/uengine-keyboard/key.json".format(get_home()), json.dumps(keybo))
|
||||
global inputs
|
||||
inputs = True
|
||||
global setting
|
||||
setting = False
|
||||
return False
|
||||
|
||||
def ShowTips():
|
||||
try:
|
||||
if setting:
|
||||
settingLabelText.set('''设置方法:把鼠标移动带所需位置然后按下需要设置的按键即可({}x{})
|
||||
提示:
|
||||
1、目前不支持同时按两个及以上按键,只支持在单一时间内按一个按键;
|
||||
2、使用映射不能关闭本窗口,但可以最小化;
|
||||
3、本程序需要 root 权限才能使用;
|
||||
4、映射时会占用鼠标,所以在使用时最好不要使用鼠标;'''.format(pyautogui.position()[0], pyautogui.position()[1]))
|
||||
settingButton.configure(state=tk.DISABLED)
|
||||
else:
|
||||
settingLabelText.set('''点击“设置”按钮设置映射({}x{})
|
||||
提示:
|
||||
1、目前不支持同时按两个及以上按键,只支持在单一时间内按一个按键;
|
||||
2、使用映射不能关闭本窗口,但可以最小化;
|
||||
3、本程序需要 root 权限才能使用;
|
||||
4、映射时会占用鼠标,所以在使用时最好不要使用鼠标;'''.format(pyautogui.position()[0], pyautogui.position()[1]))
|
||||
settingButton.configure(state=tk.NORMAL)
|
||||
time.sleep(0.1)
|
||||
ShowTips()
|
||||
except:
|
||||
pass
|
||||
|
||||
def Key():
|
||||
global inputs
|
||||
keyboard.hook(Inputt)
|
||||
|
||||
# 获取用户主目录
|
||||
def get_home()->"获取用户主目录":
|
||||
return os.path.expanduser('~')
|
||||
|
||||
# 写入文本文档
|
||||
def write_txt(path: "路径", things: "内容")->"写入文本文档":
|
||||
TxtDir = os.path.dirname(path)
|
||||
print(TxtDir)
|
||||
if not os.path.exists(TxtDir):
|
||||
os.makedirs(TxtDir,exist_ok=True)
|
||||
file = open(path, 'w', encoding='UTF-8') # 设置文件对象
|
||||
file.write(things) # 写入文本
|
||||
file.close() # 关闭文本对象
|
||||
|
||||
# 读取文本文档
|
||||
def readtxt(path: "路径")->"读取文本文档":
|
||||
f = open(path, "r") # 设置文件对象
|
||||
str = f.read() # 获取内容
|
||||
f.close() # 关闭文本对象
|
||||
return str # 返回结果
|
||||
|
||||
def Settings():
|
||||
global setting
|
||||
setting = True
|
||||
|
||||
def Clean():
|
||||
if messagebox.askokcancel(title="提示", message="你确定要删除吗?"):
|
||||
shutil.rmtree("{}/.config/uengine-keyboard".format(get_home()))
|
||||
if messagebox.askyesno(title="提示", message="删除成功!是否现在重启程序以便生效?"):
|
||||
ReStartProgram()
|
||||
|
||||
def About():
|
||||
threading.Thread(target=os.system, args=["{}/uengine-runner-about".format(programPath)]).start()
|
||||
|
||||
###################
|
||||
#
|
||||
###################
|
||||
if not os.path.exists("{}/.config/uengine-keyboard".format(get_home())):
|
||||
os.mkdir("{}/.config/uengine-keyboard".format(get_home()))
|
||||
if not os.path.exists("{}/.config/uengine-keyboard/key.json".format(get_home())):
|
||||
write_txt("{}/.config/uengine-keyboard/key.json".format(get_home()), "{}")
|
||||
|
||||
###################
|
||||
#
|
||||
###################
|
||||
setting = False
|
||||
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
|
||||
iconPath = "{}/icon.png".format(os.path.split(os.path.realpath(__file__))[0])
|
||||
keybo = json.loads(readtxt("{}/.config/uengine-keyboard/key.json".format(get_home())))
|
||||
version = json.loads(readtxt("{}/information.json".format(programPath)))["Version"]
|
||||
|
||||
###################
|
||||
# 判断是不是 root
|
||||
###################
|
||||
if os.geteuid() != 0:
|
||||
print("不是以 root 权限运行本程序!")
|
||||
root = tk.Tk()
|
||||
root.overrideredirect(1)
|
||||
root.withdraw()
|
||||
messagebox.showerror(title="错误", message="不是以 root 权限运行本程序!")
|
||||
sys.exit(1)
|
||||
|
||||
###################
|
||||
#
|
||||
###################
|
||||
window = tk.Tk()
|
||||
win = ttk.Frame(window)
|
||||
show = ttk.Frame(win)
|
||||
|
||||
settingLabelText = tk.StringVar()
|
||||
|
||||
# 设置菜单栏
|
||||
menu = tk.Menu(window, tearoff=0, background="white")
|
||||
programMenu = tk.Menu(menu, tearoff=0, background="white")
|
||||
aboutMenu = tk.Menu(menu, tearoff=0, background="white")
|
||||
|
||||
settingLabel = ttk.Label(win, textvariable=settingLabelText)
|
||||
|
||||
settingMouseToKeyboard = ttk.Button(show, text="启动键盘映射(已启用)")
|
||||
settingButton = ttk.Button(show, text="添加或覆盖键盘映射设置", command=Settings)
|
||||
|
||||
settingMouseToKeyboard.configure(state=tk.DISABLED)
|
||||
|
||||
style = ttkthemes.ThemedStyle(window)
|
||||
style.set_theme("breeze")
|
||||
window.resizable(0, 0)
|
||||
window.iconphoto(False, tk.PhotoImage(file=iconPath))
|
||||
window.title("uengine 键盘映射 {}".format(version))
|
||||
|
||||
menu.add_cascade(label="程序", menu=programMenu)
|
||||
menu.add_cascade(label="帮助", menu=aboutMenu)
|
||||
menu.configure(activebackground="dodgerblue")
|
||||
|
||||
programMenu.add_command(label="导入映射设置", command=Open)
|
||||
programMenu.add_command(label="导出映射设置", command=Save)
|
||||
programMenu.add_command(label="删除所有映射设置", command=Clean)
|
||||
programMenu.add_separator()
|
||||
programMenu.add_command(label="退出程序", command=sys.exit)
|
||||
programMenu.configure(activebackground="dodgerblue")
|
||||
|
||||
aboutMenu.add_command(label="关于", command=About)
|
||||
|
||||
window.config(menu=menu) # 显示菜单栏
|
||||
|
||||
show.grid(row=1, column=0)
|
||||
|
||||
settingLabel.grid(row=0, column=0)
|
||||
|
||||
settingMouseToKeyboard.grid(row=0, column=0)
|
||||
settingButton.grid(row=0, column=1)
|
||||
|
||||
win.pack(fill="both", expand="yes")
|
||||
|
||||
threading.Thread(target=Key).start()
|
||||
threading.Thread(target=ShowTips).start()
|
||||
|
||||
window.mainloop()
|
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import shutil
|
||||
import requests
|
||||
import traceback
|
||||
|
||||
# 读取文本文档
|
||||
def read_txt(path):
|
||||
f = open(path,"r") # 设置文件对象
|
||||
str = f.read() # 获取内容
|
||||
f.close() # 关闭文本对象
|
||||
return str # 返回结果
|
||||
|
||||
def GetPackageUpdateInformation():
|
||||
global setting
|
||||
global package
|
||||
for i in allJson['Program']:
|
||||
if i['Package'] == package:
|
||||
return i
|
||||
|
||||
try:
|
||||
setting = json.loads(read_txt("{}/setting.json".format(os.path.split(os.path.realpath(__file__))[0])))
|
||||
except:
|
||||
traceback.print_exc()
|
||||
print("配置文件无法访问!")
|
||||
package = setting['Package']
|
||||
nowVersion = setting['Version']
|
||||
try:
|
||||
jsons = requests.get(setting["Url"])
|
||||
except:
|
||||
traceback.print_exc()
|
||||
print("服务器出现错误!")
|
||||
sys.exit(1)
|
||||
allJson = json.loads(jsons.text)
|
||||
updateInformation = GetPackageUpdateInformation()
|
||||
name = updateInformation['Name']
|
||||
newVersion = updateInformation['Version']
|
||||
print("更新程序:{}".format(name))
|
||||
print("最新版本:{}".format(newVersion))
|
||||
print("目前版本:{}".format(nowVersion))
|
||||
if nowVersion == newVersion:
|
||||
print("目前是最新版本,无需更新!")
|
||||
quit()
|
||||
print("更新内容:")
|
||||
print(updateInformation['New Things'])
|
||||
choose = input("更新?[Y/N]")
|
||||
if choose.upper() == "N":
|
||||
quit()
|
||||
if os.path.exists("/tmp/update-console-{}".format(package)):
|
||||
shutil.rmtree("/tmp/update-console-{}".format(package))
|
||||
os.mkdir("/tmp/update-console-{}".format(package))
|
||||
if updateInformation["Linux App Url"][0] == None:
|
||||
print("没有可用包源")
|
||||
quit()
|
||||
os.system("wget '{}' -P '/tmp/update-console-{}'".format(updateInformation["Linux App Url"][0], package))
|
||||
os.system("sudo dpkg -i /tmp/update-console-{}/*".format(package))
|
||||
os.system("sudo apt install -f -y")
|
Loading…
Reference in New Issue