-
Notifications
You must be signed in to change notification settings - Fork 1
/
tyr.py
110 lines (110 loc) · 3.48 KB
/
tyr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env python3
#coding = utf-8
import os
import sys
import termios
import time
def runtype (num:int):#这个函数用来执行切换
if num == 1:
sta = os.system('sudo sh /data/adb/modules/uperf/script/powercfg_main.sh auto')
elif num == 2:
sta = os.system('sudo sh /data/adb/modules/uperf/script/powercfg_main.sh balance')
elif num == 3:
sta = os.system('sudo sh /data/adb/modules/uperf/script/powercfg_main.sh powersave')
elif num == 4:
sta = os.system('sudo sh /data/adb/modules/uperf/script/powercfg_main.sh performance')
elif num == 5:
sta = os.system('sudo sh /data/adb/modules/uperf/script/powercfg_main.sh fast')
return sta#sta为状态码
def installer (num:int):#安装tsu和tome linux的函数(1为安装tsu,2为安装tome linux)
if num == 1:
os.system("pkg install tsu")
os.system("tyr")
exit()
elif num == 2:
os.system('bash -c "$(curl -fsSL https://gitee.com/mo2/linux/raw/2/2)"')
os.system("tyr")
exit()
return null
def press_any_key_exit ():
fd = sys.stdin.fileno()
old_ttyinfo = termios.tcgetattr(fd)
new_ttyinfo = old_ttyinfo[:]
new_ttyinfo[3] &= ~termios.ICANON
new_ttyinfo[3] &= ~termios.ECHO
sys.stdout.write("成功切换,按任意键退出……")
sys.stdout.flush()
termios.tcsetattr(fd, termios.TCSANOW, new_ttyinfo)
os.read(fd, 7)
termios.tcsetattr(fd, termios.TCSANOW, old_ttyinfo)
def autoboot (num:int):#自启动开关1为开启 0为关闭
if num == 1:
with open('/data/data/com.termux/files/usr/etc/profile.d/run.sh','w') as file_read:
file_read.write('tyr')
print("已开启")
time.sleep(1)
os.system("clear")
os.system("tyr")
exit()
elif num == 0:
os.system("rm -rf /data/data/com.termux/files/usr/etc/profile.d/run.sh")
print("已关闭")
time.sleep(1)
os.system("clear")
os.system("tyr")
exit()
return null
try:
userinpf = sys.argv[1]
userinp = int(userinpf)
except IndexError:
print("1.切换到自动模式")
print("2.切换到均衡模式")
print("3.切换到卡顿模式")
print("4.切换到费电模式")
print("5.切换到性能模式")
print("6.启动tome linux")
print("7.termux换源")
print("8.开启自启动")
print("9.关闭自启动")
print("10..退出")
try:
userinp = int(input("请输入序号"))
except ValueError:
exit("请输入合法的整数值")
if userinp >=1 | userinp <=5:
sta = runtype(userinp)
if sta == 32512:
chooseinp = int(input("未安装tsu,是否需要安装(1/0)"))
if chooseinp == 1:
installer(1)
if chooseinp == 0:
os.system("clear")
os.system("tyr")
exit()
elif sta == 0:
press_any_key_exit()
elif userinp == 6:
sta = os.system("debian")
if sta == 32512:
chooseinp = int(input("未安装tome linux,是否需要安装(1/0)"))
if chooseinp == 1:
installer(2)
elif chooseinp == 0:
os.system("clear")
os.system("tyr")
exit()
elif 1 == 1:
exit("请输入正确的序号")
elif userinp == 7:
os.system("termux-change-repo")
os.system("clear")
os.system("tyr")
elif userinp == 8:
autoboot(1)
elif userinp == 9:
autoboot(0)
elif userinp == 10:
exit()
elif 1 == 1:
exit("请输入正确的序号")