feat: 添加 HPLIP 插件安装提示功能

- 安装 HP 驱动后自动检测 hplip 版本
- 显示对应版本插件的下载地址和安装命令
- 添加 README.md 项目说明文档

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-01 16:48:46 +08:00
parent 799e190ea8
commit f41b44238f
2 changed files with 181 additions and 0 deletions

View File

@@ -737,11 +737,53 @@ install_pantum_driver() {
rm -rf "$tmp_dir"
}
# 显示 HPLIP 插件安装提示
show_hplip_plugin_notice() {
# 检测 hplip 版本
local hplip_version=""
if command -v hp-info > /dev/null 2>&1; then
hplip_version=$(hp-info -v 2>/dev/null | grep -oP 'HPLIP \K[0-9.]+' | head -1)
fi
# 如果上面方法失败,尝试从包管理器获取
if [ -z "$hplip_version" ]; then
hplip_version=$(dpkg -s hplip 2>/dev/null | grep "^Version:" | awk '{print $2}' | cut -d'-' -f1 | cut -d'+' -f1)
fi
if [ -z "$hplip_version" ]; then
warn "无法检测 HPLIP 版本"
return
fi
echo ""
echo -e "${YELLOW}╔══════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${YELLOW}${RED}重要提示HP 打印机需要安装专有插件才能正常工作!${NC} ${YELLOW}${NC}"
echo -e "${YELLOW}╠══════════════════════════════════════════════════════════════════╣${NC}"
echo -e "${YELLOW}${NC} 检测到 HPLIP 版本: ${GREEN}${hplip_version}${NC} ${YELLOW}${NC}"
echo -e "${YELLOW}${NC} ${YELLOW}${NC}"
echo -e "${YELLOW}${NC} ${BLUE}请手动下载并安装对应版本的插件:${NC} ${YELLOW}${NC}"
echo -e "${YELLOW}${NC} ${YELLOW}${NC}"
echo -e "${YELLOW}${NC} 1. 下载地址: ${YELLOW}${NC}"
echo -e "${YELLOW}${NC} ${GREEN}https://sourceforge.net/projects/hplip/files/${NC} ${YELLOW}${NC}"
echo -e "${YELLOW}${NC} ${GREEN}hplip/${hplip_version}/hplip-${hplip_version}-plugin.run${NC} ${YELLOW}${NC}"
echo -e "${YELLOW}${NC} ${YELLOW}${NC}"
echo -e "${YELLOW}${NC} 2. 上传到服务器后执行: ${YELLOW}${NC}"
echo -e "${YELLOW}${NC} ${GREEN}sudo hp-plugin -i -p /tmp/hplip-${hplip_version}-plugin.run${NC} ${YELLOW}${NC}"
echo -e "${YELLOW}${NC} ${YELLOW}${NC}"
echo -e "${YELLOW}${NC} 3. 安装过程中如提示 GPG 验证失败,输入 ${GREEN}y${NC} 继续即可 ${YELLOW}${NC}"
echo -e "${YELLOW}╚══════════════════════════════════════════════════════════════════╝${NC}"
echo ""
# 保存版本号供后续使用
HPLIP_VERSION="$hplip_version"
}
# 安装驱动
install_drivers() {
local packages=""
local install_pantum=false
local install_pdf=false
local install_hp=false
for choice in $driver_choice; do
case $choice in
@@ -752,6 +794,7 @@ install_drivers() {
2)
info "添加 HP 驱动..."
packages="$packages hplip"
install_hp=true
;;
3)
info "添加爱普生驱动..."
@@ -767,6 +810,7 @@ install_drivers() {
6)
info "添加全部驱动..."
packages="printer-driver-all hplip printer-driver-gutenprint printer-driver-brlaser"
install_hp=true
;;
7)
install_pdf=true
@@ -792,6 +836,11 @@ install_drivers() {
if [ "$install_pdf" = true ]; then
install_pdf_printer
fi
# 显示 HP 插件安装提示
if [ "$install_hp" = true ]; then
show_hplip_plugin_notice
fi
}
# 安装中文界面模板