Skip to content

Commit 0ce19f5

Browse files
committed
update custom.conf, init, manifest.json
1 parent fd24f13 commit 0ce19f5

File tree

3 files changed

+53
-10
lines changed

3 files changed

+53
-10
lines changed

custom.conf

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
{
22
"title": "背光控制",
3-
"content": "控制背光",
3+
"content": "自动熄灭",
44
"button1": {
5-
"cmd": "lua /system/share/lua/5.1/tp_entry.lua sys_api.release_backlight",
5+
"cmd": "/data/apps/backlight/init release_backlight",
66
"txt": "自动熄灭",
77
"code": {"0": "执行成功", "-1": "执行失败"}
88
},
99
"button2": {
10-
"cmd": "lua /system/share/lua/5.1/tp_entry.lua sys_api.lock_backlight",
10+
"cmd": "/data/apps/backlight/init lock_backlight",
1111
"txt": "屏幕长亮",
1212
"code": {"0": "执行成功", "-1": "执行失败"}
13-
}
13+
},
14+
"button3": {
15+
"cmd": "/data/apps/backlight/init config",
16+
"txt": "熄灭间隔",
17+
"code": {"0": "执行成功", "-1": "执行失败"}
18+
}
1419
}

init

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ REMOVE="/bin/rm -f"
2020
LUA_BIN="/system/bin/lua"
2121
LUA_SCRIPT_PATH="/system/share/lua/5.1/tp_entry.lua"
2222

23+
INTERVAL="$CURWDIR/interval.conf";
24+
2325
usage() {
2426
echo "ERROR: action missing"
2527
echo "syntax: $0 <start|stop|restart|status|config|install|uninstall>"
@@ -38,7 +40,8 @@ stop() {
3840
fi
3941
}
4042

41-
config() {
43+
install()
44+
{
4245
echo "{" > "$PROGRAM_NAME.conf"
4346
echo "\"name\" : \"$TITLE\"," >> "$PROGRAM_NAME.conf"
4447
echo "\"icon\" : \"$CURWDIR/$ICON\"," >> "$PROGRAM_NAME.conf"
@@ -49,6 +52,9 @@ config() {
4952

5053
$INSTALL_BIN -d $LAUNCHER_CONFIG_DIR
5154
$INSTALL_BIN "$PROGRAM_NAME.conf" "$LAUNCHER_CONFIG_FILE"
55+
56+
code=`basename $CURWDIR`;
57+
/bin/sed -ie "s/data\/apps\/backlight/data\/apps\/$code/g" $CURWDIR/custom.conf;
5258
}
5359

5460
uninstall() {
@@ -58,22 +64,54 @@ uninstall() {
5864
release_backlight() {
5965
RC=$($LUA_BIN $LUA_SCRIPT_PATH sys_api.release_backlight)
6066
echo -n $RC
67+
68+
[ -f $CUSTOM_CONFIG_FILE ] && /bin/sed -ie "s/\"content\": \"屏幕长亮\"\,/\"content\": \"自动熄灭\"\,/g" $CUSTOM_CONFIG_FILE;
69+
pid=`ps |grep custom|grep -v grep|awk '{print $1}'`;
70+
kill -SIGUSR1 $pid;
6171
}
6272

6373
lock_backlight() {
6474
RC=$($LUA_BIN $LUA_SCRIPT_PATH sys_api.lock_backlight)
6575
echo -n $RC
76+
77+
[ -f $CUSTOM_CONFIG_FILE ] && /bin/sed -ie "s/\"content\": \"自动熄灭\"\,/\"content\": \"屏幕长亮\"\,/g" $CUSTOM_CONFIG_FILE;
78+
pid=`ps |grep custom|grep -v grep|awk '{print $1}'`;
79+
kill -SIGUSR1 $pid;
6680
}
6781

6882
backlight_on() {
6983
RC=$($LUA_BIN $LUA_SCRIPT_PATH sys_api.wakeup_backlight)
7084
echo -n $RC
85+
86+
pid=`ps |grep custom|grep -v grep|awk '{print $1}'`;
87+
kill -SIGUSR1 $pid;
7188
}
7289

7390
backlight_off() {
7491
echo -n '{"msg": "falilure", "code": -1}'
7592
}
7693

94+
config()
95+
{
96+
/bin/input-text "" "间隔时间(单位秒)" "$INTERVAL" 1 10;
97+
sec=`cat $INTERVAL`;
98+
line=`echo $sec|grep "[^0-9]"|wc -l`;
99+
if [ $line -eq 0 ]; then
100+
pid=`ps|grep blcontrol|grep -v grep|awk '{print $1}'`;
101+
[ "$sec" != "" ] && nvram_set 2860 BLtime $sec;
102+
res=$?;
103+
if [ $res -eq 0 ]; then
104+
kill $pid;
105+
/bin/blcontrol -t $sec -s NULL &
106+
return 0;
107+
else
108+
return 1;
109+
fi
110+
else
111+
return 1;
112+
fi
113+
}
114+
77115
# main
78116
if [ $# -lt 1 ]; then
79117
usage
@@ -89,11 +127,11 @@ case "$1" in
89127
start
90128
stop;;
91129
"install" )
92-
config;;
130+
install;;
93131
"uninstall" )
94132
uninstall;;
95133
"config" )
96-
config;;
134+
config;;
97135
"release_backlight" )
98136
release_backlight;;
99137
"lock_backlight" )

manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"author": "魔豆开发团队",
55
"author_mail": "[email protected]",
66
"homepage": "www.modouwifi.com",
7-
"version": "0.3.0",
8-
"release_date": "2014.09.09",
7+
"version": "0.3.2",
8+
"release_date": "2014.09.20",
99
"icon": "./appicon_backlight_normal.png",
1010
"location": "internal",
1111
"description": "使用此应用可以开启或关闭魔豆屏幕的背光自动熄灭功能",
1212
"instruction": "开启应用后就两个按钮,简单明了",
1313
"os_version": "0.6.17"
14-
}
14+
}

0 commit comments

Comments
 (0)