2025年5月8日 星期四

修改開機畫面

 

目標

在 Raspberry Pi 3 上,開機時顯示自訂圖片(如公司 logo、個人圖片)取代開機訊息。


你需要準備

  • 一張圖片:建議解析度 800x480(適合 7 吋螢幕),格式為 .png

  • 圖片命名為 splash.png(或其他也行)


步驟一:安裝 Plymouth

sudo apt update
sudo apt install plymouth plymouth-themes

步驟二:手動啟用 initramfs

  1. 打開設定檔:

sudo nano /boot/config.txt
  1. 在最下方加上這一行:

initramfs initrd.img-$(uname -r) followkernel

或者指定版本(例如你是 6.1.21):

initramfs initrd.img-6.1.21-v7+ followkernel
  1. 存檔後建立 initramfs:

sudo update-initramfs -c -k $(uname -r)

步驟三:建立自訂主題

1. 建立主題資料夾

sudo mkdir /usr/share/plymouth/themes/mysplash
cd /usr/share/plymouth/themes/mysplash

2. 複製你的圖片(這是你要顯示的圖片)

sudo cp /path/to/your/splash.png .

例子(如果圖片放在主目錄):

sudo cp ~/splash.png .

3. 建立主題設定檔 mysplash.plymouth

sudo nano mysplash.plymouth

貼上以下內容:

[Plymouth Theme]
Name=MySplash Description=Custom Splash Image ModuleName=script [script] ImageDir=/usr/share/plymouth/themes/mysplash ScriptFile=/usr/share/plymouth/themes/mysplash/mysplash.script

建立mysplash.script

sudo nano mysplash.script

貼上以下內容(圖片會居中顯示):

wallpaper_image = Image("splash.png");
screen_width = Window.GetWidth(); screen_height = Window.GetHeight(); image_width = wallpaper_image.GetWidth(); image_height = wallpaper_image.GetHeight(); Window.SetBackgroundTopColor(0.0, 0.0, 0.0); // 黑色背景 Window.SetBackgroundBottomColor(0.0, 0.0, 0.0); wallpaper_sprite = Sprite(wallpaper_image); wallpaper_sprite.SetPosition( (screen_width - image_width) / 2, (screen_height - image_height) / 2 );

步驟四:套用主題並更新

sudo plymouth-set-default-theme mysplash
sudo update-initramfs -u

步驟五:隱藏開機訊息(讓畫面乾淨)

編輯 /boot/cmdline.txt

sudo nano /boot/cmdline.txt

在原本的那一行(只有一行)中 加上這些參數

quiet splash loglevel=0 vt.global_cursor_default=0

 確保所有內容都在同一行,中間用空格隔開,不要換行!


步驟六:重開機測試

sudo reboot

沒有留言:

張貼留言