| Crates.io | deskfile |
| lib.rs | deskfile |
| version | 0.1.1 |
| created_at | 2025-11-21 07:46:42.219586+00 |
| updated_at | 2025-11-21 07:46:42.219586+00 |
| description | A CLI tool for generating freedesktop.org compliant .desktop files |
| homepage | |
| repository | https://github.com/Liangdi/deskfile |
| max_upload_size | |
| id | 1943221 |
| size | 87,284 |
一个用于生成 Linux .desktop 文件的命令行工具,完全兼容 freedesktop.org 规范。
English Version: README_en.md
cargo install deskfile
git clone https://github.com/Liangdi/deskfile
cd deskfile
cargo build --release
# 创建基本的 .desktop 文件
deskfile create -n "MyApp" -e "/usr/bin/myapp" -i "/usr/share/icons/myapp.png"
# 创建带分类和关键词的 .desktop 文件
deskfile create -n "文本编辑器" -e "/usr/bin/textedit" -i "text-editor" \
--categories "Office,TextEditor" --keywords "文本,编辑器,写作"
# 创建终端应用程序 .desktop 文件
deskfile create -n "终端应用" -e "/usr/bin/termapp" -i "terminal" \
--terminal true --comment "基于终端的应用程序"
# 指定输出路径并验证
deskfile create -n "MyApp" -e "/usr/bin/myapp" -i "myapp" \
-o "~/Desktop/myapp.desktop" --validate
# 安装到系统应用目录
deskfile create -n "MyApp" -e "/usr/bin/myapp" -i "myapp" --install
# 强制安装到系统应用目录(覆盖已存在文件)
deskfile create -n "MyApp" -e "/usr/bin/myapp" -i "myapp" --install --force
--name, -n <NAME>: 应用程序名称--exec, -e <EXEC>: 可执行文件路径--icon, -i <ICON>: 图标文件路径--type, -t <TYPE>: 应用程序类型(默认: Application)--comment, -c <COMMENT>: 应用程序描述--categories <CATEGORIES>: 应用程序分类,逗号分隔--keywords <KEYWORDS>: 搜索关键词,逗号分隔--terminal, -T: 是否在终端中运行(默认: false)--startup-notify: 是否显示启动通知(默认: true)--output, -o <OUTPUT>: 输出文件路径(默认: ./--install: 安装到系统应用目录--force: 强制覆盖已存在文件(与 --install 配合使用)--validate: 生成后验证文件工具会自动检测并选择最合适的系统应用目录:
用户目录(优先,无需特殊权限):
~/.local/share/applications/系统目录(需要 root 权限):
/usr/share/applications//usr/local/share/applications/安装完成后会自动调用 update-desktop-database 更新系统桌面数据库。
# 运行测试
cargo test
# 静态检查
cargo check
# 构建项目
cargo build --release
MIT License - 详见 LICENSE 文件
欢迎提交 Issue 和 Pull Request!请查看我们的 贡献指南。