[Share Experiences] 自定义文件添加图标以及右键打开功能,以onnx文件为例
Tofloor
poster avatar
川顺页
deepin
2023-03-26 21:22
Author

前言

  • 仅在ubuntu下面测试通过,deepin可能略有不同

教程开始

  1. /usr/share/mime/目录注册 *.onnx文件,图标将会使用 netron的图标。
  • 编辑命令
sudo vim /usr/share/mime/packages/onnx.xml
  • 内容如下:

  
    Open Neural Network Exchange file
    
    
  

  1. 安装netron应用,将AppImage文件用A2D(星火商店可搜)打包成deb文件,然后安装deb。
  2. 修改桌面启动方式,添加 application/onnx类型注册,修改过程如下:
  • 修改命令
sudo vim /usr/share/applications/netron.desktop
  • 修改后的内容(多了一个 MimeType=application/onnx;以及将 AppRun %U改成了 netron %f)
[Desktop Entry]
Name=Netron
Exec=/opt/durapps/a2d-packages/netron/squashfs-root/netron %f
Terminal=false
Type=Application
Icon=/opt/durapps/a2d-packages/netron/netron.png
MimeType=application/onnx;
StartupWMClass=Netron
X-AppImage-Version=6.7.8
Comment=Visualizer for neural network, deep learning, and machine learning models
Categories=Development;
  1. 添加图标,将 Icon=/opt/durapps/a2d-packages/netron/netron.png拿出来,这个是512X512像素的,随便找个在线网站将图标改改分辨率,参考 ~/.local/share/icons/hicolor目录下的分辨率,分别建立对应文件和文件夹。
  • 弄好后目录结构大概长这样
. (294.52 KB)
.
├── hicolor
│   ├── 128x128
│   │   └── apps
│   │       └── netron.png
│   ├── 16x16
│   │   └── apps
│   │       └── netron.png
│   ├── 24x24
│   │   └── apps
│   │       └── netron.png
│   ├── 256x256
│   │   └── apps
│   │       └── netron.png
│   ├── 32x32
│   │   └── apps
│   │       └── netron.png
│   ├── 40x40
│   │   └── apps
│   │       └── netron.png
│   ├── 48x48
│   │   └── apps
│   │       └── netron.png
│   ├── 64x64
│   │   └── apps
│   │       └── netron.png
│   ├── 72x72
│   │   └── apps
│   │       └── netron.png
│   ├── 80x80
│   │   └── apps
│   │       └── netron.png
│   └── 96x96
│       └── apps
│           └── netron.png
└── netron.png
  • 然后将图标放到对应目录
cp hicolor -r ~/.local/share/icons/
  1. 刷新mine和icon以及desktop(如果没有 gtk-update-icon-cache命令,可以换成 update-icon-caches命令)
sudo update-mime-database /usr/share/mime/
sudo gtk-update-icon-cache -t -f ~/.local/share/icons/hicolor
sudo update-desktop-database /usr/share/applications/
  1. 此时基本正常显示,如果还不行,将一个64x64的图标放到对应主题文件夹的icon文件夹下,例如 ~/.local/share/icons/WhiteSur/apps/scalable
  2. 最终成品如下(双击*.onnx文件即自动调用netron打开文件):
    image.png
Reply Favorite View the author
All Replies
川顺页
deepin
2023-03-26 21:28
#1

参考了部分chatGPT给出的答案,特此感谢!
image.png

Reply View the author
fuuko
deepin
2023-03-27 16:37
#2

可以多关联几个,把ncnn、torchscript这些都塞进去ok

Reply View the author
l***[email protected]
deepin
2023-05-18 20:53
#3
It has been deleted!
S***[email protected]
deepin
2023-06-26 21:29
#4
It has been deleted!
l***[email protected]
deepin
2023-08-02 18:24
#5
It has been deleted!
a***[email protected]
deepin
2024-02-01 18:05
#6
It has been deleted!
l***[email protected]
deepin
2024-04-24 17:15
#7
It has been deleted!
p***[email protected]
deepin
2024-05-25 00:31
#8
It has been deleted!
m***[email protected]
deepin
2024-07-01 15:16
#9

It has been deleted by geometry dash subzero!

Reply View the author