coreelec与安卓 双系统共存-默认CoreElec引导后10秒计时进入android插件
在把coreelec写入emmc后,默认打开coreelec,然后通过电源可以重启进入安卓。需要多点好多步骤,下面我通过自己制作的插件来实现开机倒计时默认进入安卓
- 首先需要打开设置服务里的允许本地控制,并且重启生效,
- 编写自动启动脚本 storage/.config/autostart.sh
chmod +x autostart.sh
#!/bin/sh
(
sleep 20 # 等待 Kodi 启动完成,可以根据需要调整等待时间
/usr/bin/kodi-send --action="RunAddon(script.countdown)"
) &
- 制作插件在/storage/.kodi/建立新文件夹 script.countdown,并且放入两个文件
addon.xml
<?xml version="1.0" encoding="UTF-8"?>
<addon id="script.countdown" name="Countdown" version="1.0.0" provider-name="Your Name">
<extension point="xbmc.python.script" library="main.py">
<provides>navigatescript</provides>
</extension>
</addon>
main.py
import xbmcgui
import xbmc
import time
import subprocess
import threading
class CountdownThread(threading.Thread):
def __init__(self, duration):
super(CountdownThread, self).__init__()
self.duration = duration
self._stop_event = threading.Event()
def run(self):
for remaining in range(self.duration, 0, -1):
if self.stopped():
break
self.show_notification(remaining)
time.sleep(1)
if not self.stopped():
self.show_notification(0)
restart_device()
def stop(self):
self._stop_event.set()
def stopped(self):
return self._stop_event.is_set()
def show_notification(self, remaining):
xbmcgui.Dialog().notification("重启安卓倒计时", f"剩余时间:{remaining} 秒")
def start_timer(duration):
countdown_thread = CountdownThread(duration)
countdown_thread.start()
return countdown_thread
def stop_timer(countdown_thread):
countdown_thread.stop()
# 执行外部命令的函数
def run_external_command(command):
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = process.communicate()
return output.decode(), error.decode()
def restart_device():
run_external_command("rebootfromnand")
run_external_command("reboot -f")
if __name__ == '__main__':
dialog = xbmcgui.Dialog()
timer = start_timer(10)
#dialog.ok("计时器", "计时已开始")
dialog.yesno("计时器", "要停止计时吗?")
stop_timer(timer)
- 重启打开插件,查看和激活启用countdown。可以运行一下看下效果。
四步都完成了就可以了,在coreElec 20.2-Nexus的X96 MAX+测试通过。应该问题不大。
插件测试挺顺利,ssh直接用MobaXterm_Personal_23.0 访问开了ssh的kodi,
后面开机指令的发送出了点问题,因为第一步本地服务里的本地控制没有打开,造成kodi-send始终不执行。所以四步完成,一个方便一点的双系统就成了。
整个过程的chat-gpt的提示下完成,后来google也没帮太大忙。运气
下载地址 http://pan.ezdial.cn/nasone/tvbox/script.countdown.zip