-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathwrench-ext.lua
140 lines (115 loc) · 3.21 KB
/
wrench-ext.lua
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
local is_useful_notification
local should_use_internal_pop
local private_config = {}
local M = {}
local file_exists = function(name)
local f=io.open(name,"r")
if f ~= nil then
io.close(f)
return true
else
return false
end
end
local dofile_res = nil
local configDir = os.getenv("WRENCH_CONFIG_DIR")
private_ext_file = configDir .. package.config:sub(1, 1) .. "my-wrench-ext.lua"
if file_exists(private_ext_file) then
dofile_res, private_config = pcall(dofile, private_ext_file)
if not dofile_res then
private_config = {}
end
end
local ignored_pkgs = {
"com.google.android.apps.maps",
"android",
"com.android.settings",
"com.bhj.setclip",
"com.android.systemui",
"com.github.shadowsocks",
}
function is_dup(s1, s2)
if s2:len() > s1:len() then
s1, s2 = s2, s1
end
if s1:sub(1, s2:len()) == s2 or s1:sub(-s2:len()) == s2 then
return true
end
return false
end
M.rewrite_notification_text = function(key, pkg, title, text, ticker)
if pkg == "com.tencent.mobileqq" then
return ticker
end
if pkg == "com.android.mms" and title:match("通の新しいメッセージ") then
return ticker
end
if ticker ~= "" and not is_dup(ticker, text) then
return ("%s ticker(%s)"):format(text, ticker)
end
return text
end
is_useful_notification = function(key, pkg, title, text, ticker)
if private_config.is_useful_notification and
private_config.is_useful_notification(key, pkg, title, text) == 0 then
return 0
end
if title == "" or (text == "" and ticker == "") then
return 0
end
if text == "" and title == ticker and
(
title:match("件の新しいメール") or
title:match("封新邮件")
)
then
return 0
end
if pkg == "com.github.shadowsocks" and title == "Default" then
return 0
end
for _, p in ipairs(ignored_pkgs) do
if pkg == p then
return 0
end
end
return 1;
end
should_use_internal_pop = function()
if private_config.should_use_internal_pop then
return private_config.should_use_internal_pop()
end
return 1;
end
M.is_useful_notification = is_useful_notification
M.should_use_internal_pop = should_use_internal_pop
M.configs = {
["phone-width"] = 1080,
["phone-height"] = 1920,
["wheel-scale"] = 1,
["vnc-server-command"] = "/data/data/com.android.shell/androidvncserver",
}
dofile_res, vnc_mode = pcall(dofile, configDir .. package.config:sub(1, 1) .. "vnc-mode.lua")
if not dofile_res then
vnc_mode = "演示模式"
end
if vnc_mode ~= "演示模式" then
M.configs["vnc-server-command"] = "/data/data/com.android.shell/androidvncserver -s 100"
M.configs["allow-vnc-resize"] = "true"
if vnc_mode == "横屏高清" then
M.configs["phone-width"] = 1920
M.configs["phone-height"] = 1080
elseif vnc_mode == "竖屏高清" then
M.configs["phone-width"] = 1080
M.configs["phone-height"] = 1920
end
end
M.configs['vnc_mode'] = vnc_mode
M.getConfig = function(config)
-- if true then return "" end
if private_config.configs and private_config.configs[config] then
return private_config.configs[config]
end
return M.configs[config] or ""
end
return M