Raspberry Pi 4 Model B 8GB - 安裝
Raspberry Pi 4 Model B - 8GB RAM - 256GB micro sd 卡
01.使用 Raspberry Pi Imager
機器:Raspberry Pi 4
系統:Raspberry Pi OS(64bit)
初始設定
hostname, Username/Password, SSID/Password
Wireless LAN country:TW
Time zone:Asia/Taipei
Keyboard layout:tw
Enable SSH, Use password authentication
02.將記憶卡放入 Raspberry Pi 4 裡面,開啟電源
03.切換GUI模式
terminal
sudo raspi-config
→6 Advanced Options→A6 Wayland→W1 X11→Ok→Ok→Finish→Yes
04.調整設定
樹莓圖示→Preferences→Raspberry Pi Configuration
◎Localisation
Locale(Language:zh(Chinese), Country:TW(Taiwan), Character Set:UTF-8)→Ok
Keyboard(Model:Generic 104-key PC, Layout: Taiwanese, Variant:Taiwanese)→Ok
→OK→Yes
05.調整設定
樹莓圖示→偏好設定→Raspberry Pi 設定
◎介面 (VNC→On)
◎Display (過掃描→On, Headless Resolution:1920x1080)
◎系統 (Browser:Firefox)
→OK→Yes
06.調整設定
樹莓圖示→偏好設定→外觀設定
◎桌面 勾選 Documents
◎選單列 選取 底部
→OK
07.新增酷音輸入法(類似注音輸入法)
樹莓圖示→偏好設定→Add/Remove Software
輸入 fcitx 並按下 enter
勾選 fcitx5-5.0.21-3(64位元)
勾選 fcitx5-chewing-5.0.13-1(64位元)
→OK→輸入密碼→確定
樹莓圖示→登出→Reboot (這樣開機後,輸入法就可以套用)
開啟 geany (或其他記事本之類的軟體)
在 keybaord 圖示上面按滑鼠右鍵→設定→附加元件→經典使用者介面
→(字體、功能表字體、托盤字體 都改為 36)→確定→關閉
這樣候選字就可以很大,看得清楚了。
08.調整遠端遙控軟體
在 Real VNC 圖示上面按滑鼠右鍵→Options→
(Encryption:Prefer off)(Authentication:VNC Password)
→Apply→(輸入 Password, Confirm Password 並勾選 Allow connections from legacy VNC Viewer users)
→OK→OK
09.更新
[terminal] sudo apt update
[terminal] sudo apt upgrade -y
10.安裝辦公室軟體
[terminal] sudo apt install libreoffice -y
------到此為止,一台簡單的文書機已完成------
raspberry pi 5 用 x11 時,強制螢幕休眠
底下程式執行,螢幕就休眠,一動鍵盤或滑鼠,就會恢復螢幕畫面。
這是用 python 來執行。
import os
os.system("xset dpms force off") # 關閉螢幕(休眠)
事實上,最重要的是這一行指令,在 terminal 底下一執行就可以
xset dpms force off
用 js 抓出所有可用的多媒體裝置
●test.htm (要放在有 https 的地方)
<!doctype html>
<html lang="zh-Hant-TW">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=classDevice-width, initial-scale=1.0">
<title>裝置媒體裝置列舉</title>
<style>
body
{
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
button
{
padding: 10px 15px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover
{
background-color: #45a049;
}
.classDevice
{
padding: 10px;
margin: 5px 0;
background-color: #f5f5f5;
border-radius: 4px;
}
.classDeviceList
{
margin-top: 20px;
}
.classDeviceCategory
{
margin-bottom: 30px;
}
</style>
</head>
<body>
<h1>媒體裝置列舉</h1>
<p>此頁面將列出所有可用的攝影鏡頭和麥克風裝置。</p>
<button id="btnRefresh" onclick="funcEnumerateDevices();">重新整理裝置列表</button>
<div class="classDeviceList">
<div class="classDeviceCategory">
<h2>攝影鏡頭</h2>
<div id="divVideoInputDevices"></div>
</div>
<div class="classDeviceCategory">
<h2>麥克風</h2>
<div id="divAudioInputDevices"></div>
</div>
</div>
<script>
async function funcEnumerateDevices()
{
try
{
// 請求使用者權限(這會觸發瀏覽器的權限對話框)
await navigator.mediaDevices.getUserMedia({ audio: true, video: true });
// 列舉所有媒體裝置
const oDevices=await navigator.mediaDevices.enumerateDevices();
// 過濾並顯示攝影鏡頭
const oVideoInputDevices=oDevices.filter(oDevice => oDevice.kind==='videoinput');
funcDisplayDevices(oVideoInputDevices, 'divVideoInputDevices');
// 過濾並顯示麥克風
const oAudioInputDevices=oDevices.filter(oDevice => oDevice.kind==='audioinput');
funcDisplayDevices(oAudioInputDevices, 'divAudioInputDevices');
}
catch(oError)
{
console.error('列舉裝置時發生錯誤:', oError);
alert('列舉裝置時發生錯誤: ' + oError.message);
}
}
function funcDisplayDevices(oDevices, strElementId)
{
const oContainer=document.getElementById(strElementId);
oContainer.innerHTML='';
if(oDevices.length === 0)
{
oContainer.innerHTML='<div class="classDevice">未找到裝置</div>';
return;
}
oDevices.forEach(
oDevice =>
{
const oDeviceElement=document.createElement('div');
oDeviceElement.className='classDevice';
const strDeviceId=oDevice.deviceId || '無ID';
const strDeviceLabel=oDevice.label || '未命名裝置';
oDeviceElement.innerHTML
='<strong>名稱:</strong> '+strDeviceLabel+'<br>'
+'<strong>ID:</strong> '+strDeviceId+'<br>'
+'<strong>類型:</strong> '+oDevice.kind+'';
oContainer.appendChild(oDeviceElement);
}
);
}
</script>
</body>
</html>
用 python 解析 qrcode
# sudo apt install python3-pyzbar
# sudo apt install python3-pillow
from pyzbar.pyzbar import decode
from PIL import Image
oImg=Image.open('13.jpg')
oResults=decode(oImg)
for oResult in oResults:
print("QR Code data:", oResult.data.decode("utf-8"))
用 python 來產生 odt 檔案
# pip install odfpy
from odf.opendocument import OpenDocumentText
from odf.table import Table, TableRow, TableCell, TableColumn
from odf.style import Style, PageLayout, PageLayoutProperties, MasterPage
from odf.style import Footer, FooterStyle, ParagraphProperties
from odf.style import TableProperties, TableColumnProperties, TableCellProperties
from odf.style import TextProperties, FontFace
from odf.text import P, Span, PageNumber, PageCount
oDoc=OpenDocumentText()
# 字型
oFontFace=FontFace(name="標楷體", fontfamily="標楷體")
oDoc.fontfacedecls.addElement(oFontFace)
# 版面
oPageLayout=PageLayout(name="pagelayout20250424154200")
oPageLayoutProperties=PageLayoutProperties(
margin="1cm", # 留白 1cm
pagewidth="29.7cm", # A4 橫向
pageheight="21cm", # A4 橫向
printorientation="landscape", # 橫向
writingmode="tb-rl" # 直書
)
oPageLayout.addElement(oPageLayoutProperties)
oDoc.automaticstyles.addElement(oPageLayout)
# 頁尾
oFooterStyle=Style(name="footerstyle20250424140000", family="paragraph")
oFooterStyle.addElement(ParagraphProperties(textalign="center"))
oFooterStyle.addElement(TextProperties(fontnameasian="標楷體",fontsizeasian="12pt",fontname="Consolas",fontsize="12pt"))
oDoc.styles.addElement(oFooterStyle)
oFooter=Footer()
oFotterParagraph=P(stylename=oFooterStyle)
oFotterParagraph.addText("2025-04-24 大乘起信論勝異方便")
oFotterParagraph.addText(" ")
oFotterParagraph.addElement(PageNumber(selectpage="current"))
oFotterParagraph.addText(" / ")
oFotterParagraph.addElement(PageCount())
oFooter.addElement(oFotterParagraph)
# 版面+頁尾
oMasterPage=MasterPage(name="Standard", pagelayoutname=oPageLayout)
oMasterPage.addElement(oFooter)
oDoc.masterstyles.addElement(oMasterPage)
# 表格與欄位樣式
oTableStyle=Style(name="tablestyle20250424154200", family="table")
oTableStyle.addElement(TableProperties(width="18cm", align="left"))
oColumnStyle = Style(name="columnstyle20250424154300", family="table-column")
oColumnStyle.addElement(TableColumnProperties(columnwidth="18cm"))
oCellStyleAZero=Style(name="cellstyle20250424163630", family="table-cell")
oCellStyleAZero.addElement(TableCellProperties(backgroundcolor="#D6D5F0", border="0.002cm solid #000000",padding="0.1cm"))
oCellStyleA=Style(name="cellstyle20250424163600", family="table-cell")
oCellStyleA.addElement(TableCellProperties(backgroundcolor="#D6D5F0", borderleft="0.002cm solid #000000",borderright="0.002cm solid #000000",borderbottom="0.002cm solid #000000",padding="0.1cm"))
oCellStyleB=Style(name="cellstyle20250424220700", family="table-cell")
oCellStyleB.addElement(TableCellProperties(backgroundcolor="#ffffff", borderleft="0.002cm solid #000000",borderright="0.002cm solid #000000",borderbottom="0.002cm solid #000000",padding="0.1cm"))
oCellStyleC=Style(name="cellstyle20250424220730", family="table-cell")
oCellStyleC.addElement(TableCellProperties(backgroundcolor="#CDEFF7", borderleft="0.002cm solid #000000",borderright="0.002cm solid #000000",borderbottom="0.002cm solid #000000",padding="0.1cm"))
oCellStyleD=Style(name="cellstyle20250424220800", family="table-cell")
oCellStyleD.addElement(TableCellProperties(backgroundcolor="#ffffff", borderleft="0.002cm solid #000000",borderright="0.002cm solid #000000",borderbottom="0.002cm solid #000000",padding="0.1cm"))
oTextStyleA=Style(name="textstyle20250424165600", family="paragraph")
oTextStyleA.addElement(TextProperties(fontnameasian="標楷體",fontsizeasian="12pt",fontweightasian="bold",fontname="標楷體",fontsize="12pt",fontweight="bold"))
oTextStyleB=Style(name="textstyle20250425085700", family="paragraph")
oTextStyleB.addElement(TextProperties(fontnameasian="標楷體",fontsizeasian="24pt",fontweightasian="bold",fontname="標楷體",fontsize="24pt",fontweight="bold"))
oTextStyleC=Style(name="textstyle20250425085900", family="paragraph")
oTextStyleC.addElement(TextProperties(fontnameasian="標楷體",fontsizeasian="12pt",fontweightasian="bold",fontname="標楷體",fontsize="12pt",fontweight="bold"))
oTextStyleD1=Style(name="textstyle20250425090800", family="paragraph")
oTextStyleD1.addElement(TextProperties(fontnameasian="標楷體",fontsizeasian="16pt",fontname="標楷體",fontsize="16pt"))
oTextStyleD1.addElement(ParagraphProperties(backgroundcolor="#dddddd"))
oTextStyleD2=Style(name="textstyle20250425090830", family="paragraph")
oTextStyleD2.addElement(TextProperties(fontnameasian="標楷體",fontsizeasian="12pt",fontname="標楷體",fontsize="12pt"))
oTextStyleD2.addElement(ParagraphProperties(backgroundcolor="#ffffff"))
oDoc.automaticstyles.addElement(oTableStyle)
oDoc.automaticstyles.addElement(oColumnStyle)
oDoc.automaticstyles.addElement(oCellStyleAZero)
oDoc.automaticstyles.addElement(oCellStyleA)
oDoc.automaticstyles.addElement(oCellStyleB)
oDoc.automaticstyles.addElement(oCellStyleC)
oDoc.automaticstyles.addElement(oCellStyleD)
oDoc.automaticstyles.addElement(oTextStyleA)
oDoc.automaticstyles.addElement(oTextStyleB)
oDoc.automaticstyles.addElement(oTextStyleC)
oDoc.automaticstyles.addElement(oTextStyleD1)
oDoc.automaticstyles.addElement(oTextStyleD2)
# 先加入一行空白行
oDoc.text.addElement(P(text=""))
# 表格
oTable = Table(name="table20250424141000", stylename=oTableStyle)
oTable.addElement(TableColumn(stylename=oColumnStyle))
oDoc.text.addElement(oTable)
# 第一格
oRow=TableRow()
oCell=TableCell(stylename=oCellStyleAZero)
oCell.addElement(P(stylename=oTextStyleA, text="大乘起信論勝異方便"))
oRow.addElement(oCell)
oTable.addElement(oRow)
# 第二格
oRow=TableRow()
oCell=TableCell(stylename=oCellStyleB)
oCell.addElement(P(stylename=oTextStyleB, text="[開場白]"))
oRow.addElement(oCell)
oTable.addElement(oRow)
# 第三格
oRow=TableRow()
oCell=TableCell(stylename=oCellStyleC)
oCell.addElement(P(stylename=oTextStyleC, text="講稿與辭典"))
oRow.addElement(oCell)
oTable.addElement(oRow)
# 第四格
oRow=TableRow()
oCell=TableCell(stylename=oCellStyleD)
oCell.addElement(P(stylename=oTextStyleD1, text="請看裂網疏「又識論云。此信心所。自性澄清。亦能淨餘心心所等。如水清珠。能清濁水。」我們先看這一段。"))
oCell.addElement(P(stylename=oTextStyleD2, text="【又】FROM【教育部重編國語辭典修訂本】\r\n[副]1.表示重複或反覆。如:「一天又一天」、「看了又看」。唐.白居易〈賦得古原草送別〉詩:「野火燒不盡,春風吹又生。」"))
oRow.addElement(oCell)
oTable.addElement(oRow)
# 最後加入一行空白行
oDoc.text.addElement(P(text=""))
# 儲存檔案
oDoc.save("20250424_02.odt")