Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed TeXmacs/misc/images/texmacs-128.png
Binary file not shown.
Binary file removed TeXmacs/misc/images/texmacs-16.png
Binary file not shown.
Binary file removed TeXmacs/misc/images/texmacs-192.png
Binary file not shown.
Binary file removed TeXmacs/misc/images/texmacs-20.png
Binary file not shown.
Binary file removed TeXmacs/misc/images/texmacs-22.png
Binary file not shown.
Binary file removed TeXmacs/misc/images/texmacs-24.png
Binary file not shown.
Binary file removed TeXmacs/misc/images/texmacs-256.png
Binary file not shown.
Binary file removed TeXmacs/misc/images/texmacs-32.png
Binary file not shown.
Binary file removed TeXmacs/misc/images/texmacs-36.png
Binary file not shown.
Binary file removed TeXmacs/misc/images/texmacs-40.png
Binary file not shown.
Binary file removed TeXmacs/misc/images/texmacs-48.png
Binary file not shown.
Binary file removed TeXmacs/misc/images/texmacs-512.png
Binary file not shown.
Binary file removed TeXmacs/misc/images/texmacs-64.png
Binary file not shown.
Binary file removed TeXmacs/misc/images/texmacs-72.png
Binary file not shown.
Binary file removed TeXmacs/misc/images/texmacs-96.png
Binary file not shown.
Binary file added TeXmacs/misc/images/texmacs-document-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TeXmacs/misc/images/texmacs-document-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TeXmacs/misc/images/texmacs-document-192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TeXmacs/misc/images/texmacs-document-20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TeXmacs/misc/images/texmacs-document-22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TeXmacs/misc/images/texmacs-document-24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TeXmacs/misc/images/texmacs-document-256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TeXmacs/misc/images/texmacs-document-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TeXmacs/misc/images/texmacs-document-36.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TeXmacs/misc/images/texmacs-document-40.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TeXmacs/misc/images/texmacs-document-48.png
Binary file added TeXmacs/misc/images/texmacs-document-512.png
Binary file added TeXmacs/misc/images/texmacs-document-64.png
Binary file added TeXmacs/misc/images/texmacs-document-72.png
Binary file added TeXmacs/misc/images/texmacs-document-96.png
Binary file added TeXmacs/misc/images/texmacs-document.png
1 change: 1 addition & 0 deletions TeXmacs/misc/images/texmacs-document.svg

Large diffs are not rendered by default.

Binary file removed TeXmacs/misc/images/text-x-texmacs-128.png
Diff not rendered.
Binary file removed TeXmacs/misc/images/text-x-texmacs-16.png
Diff not rendered.
Binary file removed TeXmacs/misc/images/text-x-texmacs-192.png
Diff not rendered.
Binary file removed TeXmacs/misc/images/text-x-texmacs-20.png
Diff not rendered.
Binary file removed TeXmacs/misc/images/text-x-texmacs-22.png
Diff not rendered.
Binary file removed TeXmacs/misc/images/text-x-texmacs-24.png
Diff not rendered.
Binary file removed TeXmacs/misc/images/text-x-texmacs-256.png
Diff not rendered.
Binary file removed TeXmacs/misc/images/text-x-texmacs-32.png
Diff not rendered.
Binary file removed TeXmacs/misc/images/text-x-texmacs-36.png
Diff not rendered.
Binary file removed TeXmacs/misc/images/text-x-texmacs-40.png
Diff not rendered.
Binary file removed TeXmacs/misc/images/text-x-texmacs-48.png
Diff not rendered.
Binary file removed TeXmacs/misc/images/text-x-texmacs-512.png
Diff not rendered.
Binary file removed TeXmacs/misc/images/text-x-texmacs-64.png
Diff not rendered.
Binary file removed TeXmacs/misc/images/text-x-texmacs-72.png
Diff not rendered.
Binary file removed TeXmacs/misc/images/text-x-texmacs-96.png
Diff not rendered.
15 changes: 10 additions & 5 deletions TeXmacs/misc/mime/texmacs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
<match type="string" value="TeXmacs" offset="1:7"/>
</magic>
<glob weight="90" pattern="*.ts"/>
<icon name="text-x-texmacs"/>
<generic-icon name="text-x-texmacs"/>
<icon name="texmacs-document"/>
<generic-icon name="texmacs-document"/>
</mime-type>
<mime-type type="text/x-texmacs.doc">
<comment>TeXmacs document</comment>
Expand Down Expand Up @@ -94,12 +94,17 @@
<match type="string" value="TeXmacs" offset="1:7"/>
</magic>
<glob weight="90" pattern="*.tm"/>
<icon name="text-x-texmacs"/>
<generic-icon name="text-x-texmacs"/>
<icon name="texmacs-document"/>
<generic-icon name="texmacs-document"/>
</mime-type>
<mime-type type="text/x-tmu-doc">
<comment>TMU document</comment>
<comment xml:lang="zh_CN">TMU文档</comment>
<glob pattern="*.tmu"/>
<magic priority="90">
<match type="string" value="TeXmacs" offset="1:7"/>
</magic>
<glob weight="90" pattern="*.tmu"/>
<icon name="texmacs-document"/>
<generic-icon name="texmacs-document"/>
</mime-type>
</mime-info>
28 changes: 28 additions & 0 deletions devel/200_47.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# [200_47] 修改软件专用后缀文件的图标
## 如何测试
- macos
- 本地打包
- 安装
- 清理Dock和Finder缓存
- `sudo rm -rf /Library/Caches/com.apple.iconservices.store`
- `killall Dock`
- `killall Finder`
- 将tmu文件默认打开方式更换为 mogan
- windows
- 本地打包
- 安装
- linux
- 本地打包
- 安装

## 完成情况
- [x] macos
- [x] windows
- [x] linux


## 2026/02/05 更换图标文件,增加linux文档图标,macos 磁盘宗卷图标
What?
- 更新了图片资源
- linux打包脚本优化

261 changes: 219 additions & 42 deletions packages/debian/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# ================= 配置部分 =================
APP_NAME="mogan-stem"
BINARY_NAME="moganstem"
ARCH="amd64"
ARCH=$(dpkg --print-architecture)
INSTALL_PREFIX="/opt/$APP_NAME"

# 图标源路径 (相对于项目根目录)
ICON_SOURCE_REL="3rdparty/qwindowkitty/src/styles/app/stem.png"

# 尝试获取 VERSION
if [ -z "$VERSION" ]; then
VERSION="2025.2.3"
VERSION="2026.2.0"
else
echo "✅ 检测到版本号: $VERSION"
fi
Expand Down Expand Up @@ -44,44 +44,83 @@ if [ ! -f "$APP_DIR/usr/bin/$BINARY_NAME" ]; then
exit 1
fi

# ================= 2. 处理图标 (直接复制 PNG) =================
# ================= 2. 处理图标 (应用程序图标和 MIME 类型图标) =================
echo "🎨 [2/6] 处理图标文件..."

# 2.1 应用程序图标
ICON_SRC="$APP_HOME/$ICON_SOURCE_REL"
# 这里假设图标足够清晰,放入 256x256 目录(如果图标尺寸不同,Linux 也能显示,只是目录归类不太规范)
ICON_DEST_DIR="$APP_DIR/usr/share/icons/hicolor/256x256/apps"
mkdir -p "$ICON_DEST_DIR"

if [ -f "$ICON_SRC" ]; then
echo " -> 复制图标: $ICON_SRC"
# 将图标重命名为 包名.png (mogan-stem.png)
cp "$ICON_SRC" "$ICON_DEST_DIR/$APP_NAME.png"
ICON_FINAL_NAME="$APP_NAME" # .desktop 文件里通常不需要写 .png 后缀
# 只复制关键尺寸,减少不必要的复制
KEY_ICON_SIZES="16 32 48 64 128 256 512"
for size in $KEY_ICON_SIZES; do
ICON_DEST_DIR="$APP_DIR/usr/share/icons/hicolor/${size}x${size}/apps"
mkdir -p "$ICON_DEST_DIR"

if [ -f "$ICON_SRC" ]; then
echo " -> 复制应用程序图标 ${size}x${size}"
cp "$ICON_SRC" "$ICON_DEST_DIR/$APP_NAME.png"
else
echo "⚠️ 警告: 未找到应用程序图标源文件: $ICON_SRC"
touch "$ICON_DEST_DIR/$APP_NAME.png"
fi
done

# 2.2 MIME 类型图标 (用于 .tm, .tmu, .ts 文件)
echo " -> 处理 MIME 类型图标..."
MIME_ICON_SRC_DIR="$APP_HOME/TeXmacs/misc/images"
MIME_ICON_NAME="texmacs-document"
MIME_PNG_SRC="$MIME_ICON_SRC_DIR/$MIME_ICON_NAME.png"
MIME_SVG_SRC="$MIME_ICON_SRC_DIR/$MIME_ICON_NAME.svg"

if [ -f "$MIME_PNG_SRC" ] || [ -f "$MIME_SVG_SRC" ]; then
echo " -> 找到 MIME 类型图标源文件"

# 复制 PNG 图标到关键尺寸
if [ -f "$MIME_PNG_SRC" ]; then
for size in $KEY_ICON_SIZES; do
MIME_ICON_DEST_DIR="$APP_DIR/usr/share/icons/hicolor/${size}x${size}/mimetypes"
mkdir -p "$MIME_ICON_DEST_DIR"
cp "$MIME_PNG_SRC" "$MIME_ICON_DEST_DIR/$MIME_ICON_NAME.png"
done
fi
Comment on lines +78 to +84
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Debian package script tries to copy texmacs-document.png (a single PNG file without size suffix) to multiple size directories. However, this approach is flawed because:

  1. It copies the same PNG file to all size directories (16x16, 32x32, etc.), regardless of the actual size of the source file
  2. This will result in poor icon quality at smaller sizes (downscaling) or blurry icons at larger sizes (upscaling)
  3. The script should either:
    • Use the size-specific PNG files (texmacs-document-{size}.png) that already exist, OR
    • Only copy the SVG file and let the system scale it appropriately

The xmake.lua correctly installs size-specific PNGs and then renames them, but the Debian script bypasses this logic and uses a single PNG for all sizes.

Copilot uses AI. Check for mistakes.

# 复制 SVG 图标
if [ -f "$MIME_SVG_SRC" ]; then
MIME_ICON_DEST_DIR="$APP_DIR/usr/share/icons/hicolor/scalable/mimetypes"
mkdir -p "$MIME_ICON_DEST_DIR"
cp "$MIME_SVG_SRC" "$MIME_ICON_DEST_DIR/$MIME_ICON_NAME.svg"
fi

echo " -> MIME 类型图标复制完成"
else
echo "⚠️ 警告: 未找到 MIME 类型图标源文件: $MIME_ICON_SRC_DIR/$MIME_ICON_NAME.{png,svg}"
fi

# ================= 3. 确保 .desktop 文件存在并正确 =================
DESKTOP_PATH="$APP_DIR/usr/share/applications/$APP_NAME.desktop"
if [ ! -f "$DESKTOP_PATH" ]; then
echo "📄 [3/6] 生成 .desktop 文件..."
mkdir -p "$(dirname "$DESKTOP_PATH")"
cat > "$DESKTOP_PATH" <<EOF
[Desktop Entry]
Version=$VERSION
Type=Application
Name=Mogan STEM
GenericName=Mogan STEM
Comment=Scientific Editor
MimeType=text/x-texmacs.doc;text/x-texmacs.sty;text/plain;text/x-tex;
Exec=$BINARY_NAME
Icon=$APP_NAME
Terminal=false
Categories=Education;Science;Math;
X-KDE-Priority=TopLevel
EOF
else
echo "⚠️ 警告: 未找到图标源文件: $ICON_SRC"
touch "$ICON_DEST_DIR/$APP_NAME.png"
ICON_FINAL_NAME="$APP_NAME"
fi

# # ================= 3. 确保 .desktop 文件存在并正确 =================
# DESKTOP_PATH="$APP_DIR/usr/share/applications/$APP_NAME.desktop"
# if [ ! -f "$DESKTOP_PATH" ]; then
# echo "📄 [3/6] 生成 .desktop 文件..."
# mkdir -p "$(dirname "$DESKTOP_PATH")"
# cat > "$DESKTOP_PATH" <<EOF
# [Desktop Entry]
# Type=Application
# Name=Mogan Stem
# Comment=Scientific Editor
# Exec=$BINARY_NAME
# Icon=$ICON_FINAL_NAME
# Categories=Education;Science;Qt;
# Terminal=false
# EOF
# else
# # 强制修正 Icon 字段,确保它使用我们刚才复制进去的图标名
# echo " -> 更新现有 .desktop 文件的图标设置..."
# sed -i "s|^Icon=.*|Icon=$ICON_FINAL_NAME|" "$DESKTOP_PATH"
# fi
# 强制修正 Icon 字段,确保它使用我们刚才复制进去的图标名
echo " -> 更新现有 .desktop 文件的图标设置..."
sed -i "s|^Icon=.*|Icon=$APP_NAME|" "$DESKTOP_PATH"
# 确保Exec路径正确
sed -i "s|^Exec=.*|Exec=$BINARY_NAME|" "$DESKTOP_PATH"
fi


# ================= 4. 准备工具 =================
Expand Down Expand Up @@ -140,10 +179,46 @@ mkdir -p "$DEB_BUILD_DIR$INSTALL_PREFIX"
# 移动内容到 /opt/mogan-stem
cp -r "$APP_DIR/usr/"* "$DEB_BUILD_DIR$INSTALL_PREFIX/"

# 修正 Exec 路径为绝对路径
TARGET_DESKTOP=$(find "$DEB_BUILD_DIR$INSTALL_PREFIX/share/applications" -name "*.desktop" | head -n 1)
if [ -f "$TARGET_DESKTOP" ]; then
sed -i "s|^Exec=.*|Exec=$INSTALL_PREFIX/bin/$BINARY_NAME|" "$TARGET_DESKTOP"
# 移动 .desktop 文件到 /usr/share/applications/
DESKTOP_SRC=$(find "$DEB_BUILD_DIR$INSTALL_PREFIX/share/applications" -name "*.desktop" | head -n 1)
if [ -f "$DESKTOP_SRC" ]; then
mkdir -p "$DEB_BUILD_DIR/usr/share/applications"
DESKTOP_DEST="$DEB_BUILD_DIR/usr/share/applications/$(basename "$DESKTOP_SRC")"
cp "$DESKTOP_SRC" "$DESKTOP_DEST"
# 修正 Exec 路径为绝对路径
sed -i "s|^Exec=.*|Exec=$INSTALL_PREFIX/bin/$BINARY_NAME|" "$DESKTOP_DEST"
# 删除原始位置的文件
rm "$DESKTOP_SRC"
fi

# 移动图标文件到 /usr/share/icons/
ICON_SRC_DIR="$DEB_BUILD_DIR$INSTALL_PREFIX/share/icons"
if [ -d "$ICON_SRC_DIR" ]; then
mkdir -p "$DEB_BUILD_DIR/usr/share/icons"
# 只复制hicolor目录,保留MIME图标
if [ -d "$ICON_SRC_DIR/hicolor" ]; then
cp -r "$ICON_SRC_DIR/hicolor" "$DEB_BUILD_DIR/usr/share/icons/"
fi
rm -rf "$ICON_SRC_DIR"
fi

# 移动 MIME 文件到 /usr/share/mime/
MIME_SRC_DIR="$DEB_BUILD_DIR$INSTALL_PREFIX/share/mime"
if [ -d "$MIME_SRC_DIR" ]; then
mkdir -p "$DEB_BUILD_DIR/usr/share/mime"
cp -r "$MIME_SRC_DIR/"* "$DEB_BUILD_DIR/usr/share/mime/"
rm -rf "$MIME_SRC_DIR"
else
# 如果 xmake install 没有安装 MIME 文件,手动复制
echo " -> 手动复制 MIME 类型定义文件..."
MIME_SRC_FILE="$APP_HOME/TeXmacs/misc/mime/texmacs.xml"
if [ -f "$MIME_SRC_FILE" ]; then
mkdir -p "$DEB_BUILD_DIR/usr/share/mime/packages"
cp "$MIME_SRC_FILE" "$DEB_BUILD_DIR/usr/share/mime/packages/"
echo " -> 已复制 MIME 类型定义文件"
else
echo "⚠️ 警告: 未找到 MIME 类型定义文件: $MIME_SRC_FILE"
fi
fi

# 生成 Control
Expand All @@ -161,7 +236,109 @@ Description: Mogan Stem
Installed in $INSTALL_PREFIX.
EOF

# 生成 post-install 脚本,更新 MIME 数据库和创建命令行别名
cat > "$DEB_BUILD_DIR/DEBIAN/postinst" <<EOF
#!/bin/bash
set -e

echo "Updating MIME type database..."
if command -v update-mime-database >/dev/null 2>&1; then
if ! update-mime-database /usr/share/mime; then
echo "Error: Failed to update MIME database" >&2
else
echo "MIME database updated"
fi
else
echo "Warning: update-mime-database command not found"
fi

echo "Updating desktop icon cache..."
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
if ! gtk-update-icon-cache -f /usr/share/icons/hicolor; then
echo "Error: Failed to update GTK icon cache" >&2
else
echo "GTK icon cache updated"
fi
else
echo "Warning: gtk-update-icon-cache command not found"
fi

if command -v kbuildsycoca5 >/dev/null 2>&1; then
if ! kbuildsycoca5 --noincremental; then
echo "Error: Failed to update KDE system configuration cache" >&2
else
echo "KDE system configuration cache updated"
fi
elif command -v kbuildsycoca6 >/dev/null 2>&1; then
if ! kbuildsycoca6 --noincremental; then
echo "Error: Failed to update KDE system configuration cache" >&2
else
echo "KDE system configuration cache updated"
fi
fi
Comment on lines +244 to +278
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The postinst script updates the MIME database and icon cache but does not handle potential errors gracefully. While error messages are printed, the script continues execution even when these critical updates fail.

Consider whether the package installation should fail if these updates fail, or if continuing is acceptable. The current behavior might leave the system in an inconsistent state where MIME associations don't work properly until the user manually runs the update commands.

Copilot uses AI. Check for mistakes.

echo "Creating command-line alias..."
# Create command-line alias so users can run mogan-stem directly
BINARY_PATH="/opt/mogan-stem/bin/moganstem"
ALIAS_NAME="mogan-stem"
TARGET_LINK="/usr/local/bin/\$ALIAS_NAME"

if [ -f "\$BINARY_PATH" ] && [ -x "\$BINARY_PATH" ]; then
# Create symbolic link in /usr/local/bin
if [ -d "/usr/local/bin" ]; then
if [ -L "\$TARGET_LINK" ]; then
# 如果是符号链接,安全覆盖
ln -sf "\$BINARY_PATH" "\$TARGET_LINK"
echo " -> Updated existing symlink: mogan-stem"
echo " (symlink: /usr/local/bin/mogan-stem -> /opt/mogan-stem/bin/moganstem)"
elif [ -e "\$TARGET_LINK" ]; then
# 如果是普通文件,警告用户
echo " -> Warning: \$TARGET_LINK already exists and is not a symlink"
echo " Skipping alias creation to avoid overwriting user file"
echo " You can manually create symlink: ln -s /opt/mogan-stem/bin/moganstem /usr/local/bin/mogan-stem"
else
# 文件不存在,安全创建
ln -s "\$BINARY_PATH" "\$TARGET_LINK"
echo " -> Created command-line alias: mogan-stem"
echo " (symlink: /usr/local/bin/mogan-stem -> /opt/mogan-stem/bin/moganstem)"
fi
else
echo " -> Warning: /usr/local/bin directory does not exist"
fi
else
echo " -> Error: Binary not found or not executable: \$BINARY_PATH" >&2
fi

echo "Installation complete! You can now:"
echo " 1. Run from terminal: mogan-stem (if alias was created)"
echo " 2. Launch from application menu: Mogan Stem"
echo " 3. Double-click .tm, .tmu, .ts files to open with Mogan Stem"
EOF

chmod 755 "$DEB_BUILD_DIR/DEBIAN/postinst"

# 生成 pre-remove 脚本,清理符号链接
cat > "$DEB_BUILD_DIR/DEBIAN/prerm" <<EOF
#!/bin/bash
set -e

echo "Cleaning up command-line alias..."
ALIAS_NAME="mogan-stem"

# Remove symbolic link from /usr/local/bin
if [ -L "/usr/local/bin/\$ALIAS_NAME" ]; then
rm -f "/usr/local/bin/\$ALIAS_NAME"
echo " -> Removed command-line alias: mogan-stem"
fi
EOF

chmod 755 "$DEB_BUILD_DIR/DEBIAN/prerm"

OUTPUT_DEB="${APP_HOME}/../${APP_NAME}_${VERSION}_${ARCH}.deb"
dpkg-deb --build "$DEB_BUILD_DIR" "$OUTPUT_DEB"

echo "✅ 打包完成: $OUTPUT_DEB"
# 设置适当的权限,避免安装时出现 _apt 用户权限警告
chmod 644 "$OUTPUT_DEB"

echo "✅ 打包完成: $OUTPUT_DEB"
echo "💡 安装命令: sudo dpkg -i \"$OUTPUT_DEB\""
Binary file modified packages/macos/TeXmacs-document.icns
Binary file not shown.
Binary file removed packages/macos/TeXmacs-document.psd
Diff not rendered.
Binary file added packages/macos/driver.icns
Binary file not shown.
Binary file modified packages/windows/TeXmacs.ico
Binary file not shown.
5 changes: 0 additions & 5 deletions packages/windows/generate_ico.sh

This file was deleted.

Loading