Restore favorites on reboot

This commit is contained in:
bergware
2023-12-27 10:09:17 +01:00
parent 0e20a0a30e
commit 261e680c7d
3 changed files with 40 additions and 3 deletions

View File

@@ -0,0 +1,21 @@
#!/usr/bin/php -q
<?PHP
$cfg = '/boot/config/favorites.cfg';
if (!file_exists($cfg)) exit(0);
$file = fopen($cfg,'r');
while (($page = fgets($file))!==false) {
// update each favorite
$page = rtrim($page);
$line = fopen($page,'r');
// get current Menu settings
extract(parse_ini_string(fgets($line)));
fclose($line);
// remove and re-add label and escape single quotes for sed command
$Menu = str_replace([' MyFavorites',"'"],['',"'\''"],$Menu).' MyFavorites';
// update Menu settings
exec("sed -ri '0,/^Menu=\".+\"$/s//Menu=\"$Menu\"/' $page 2>/dev/null");
}
fclose($file);
exit(0);
?>