Linux自定义应用程序及其菜单图标

Posted awakenedy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux自定义应用程序及其菜单图标相关的知识,希望对你有一定的参考价值。

在Linux桌面系统中,如果需要自己添加一个应用程序,如果是标准的bin, lib, share结构,我通常将其放在/usr/local/bin中。如果非这样,或者程序文件很多,易造成Linux系统目录结构混乱,我通常把应用程序放在/opt目录下。然后给该程序添加开始菜单快捷方式图标、图标文件、MIME配置等。文件权限均为rw-r--r--。

图标文件放在 /usr/share/icons

MIME配置文件放在 /usr/share/mime

启动图标(.desktop)文件放在 /usr/share/applications

最后为了使desktop文件及mime找到图标,必须更新图标缓存,通过

gtk-update-icon-cache /usr/share/icons/hicolor

更新。

以firefox软件Linux版本为例

firefox.desktop内容为:

[Desktop Entry]
Version=1.0
Name=Firefox
GenericName=Web Browser
GenericName[ca]=Navegador web
GenericName[cs]=Webový prohlí?e?
GenericName[es]=Navegador web
GenericName[fa]=?????? ????????
GenericName[fi]=WWW-selain
GenericName[fr]=Navigateur Web
GenericName[hu]=Webböngész?
GenericName[it]=Browser Web
GenericName[ja]=ウェブ?ブラウザ
GenericName[ko]=? ????
GenericName[nb]=Nettleser
GenericName[nl]=Webbrowser
GenericName[nn]=Nettlesar
GenericName[no]=Nettleser
GenericName[pl]=Przegl?darka WWW
GenericName[pt]=Navegador Web
GenericName[pt_BR]=Navegador Web
GenericName[sk]=Internetový prehliada?
GenericName[sv]=Webbläsare
Comment=Browse the Web
Comment[ca]=Navegueu per el web
Comment[cs]=Prohlí?ení stránek World Wide Webu
Comment[de]=Im Internet surfen
Comment[es]=Navegue por la web
Comment[fa]=????? ???? ????? ??????? ?? ???? ??????
Comment[fi]=Selaa Internetin WWW-sivuja
Comment[fr]=Navigue sur Internet
Comment[hu]=A világháló böngészése
Comment[it]=Esplora il web
Comment[ja]=ウェブを閲覧します
Comment[ko]=?? ?? ????
Comment[nb]=Surf på nettet
Comment[nl]=Verken het internet
Comment[nn]=Surf på nettet
Comment[no]=Surf på nettet
Comment[pl]=Przegl?danie stron WWW
Comment[pt]=Navegue na Internet
Comment[pt_BR]=Navegue na Internet
Comment[sk]=Prehliadanie internetu
Comment[sv]=Surfa på webben
Exec=firefox %u
Icon=firefox
Terminal=false
Type=Application
MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;
StartupNotify=true
Categories=Network;WebBrowser;
Keywords=web;browser;internet;
Actions=new-window;new-private-window;

X-Desktop-File-Install-Version=0.23

[Desktop Action new-window]
Name=Open a New Window
Name[ach]=Dirica manyen
Name[af]=Nuwe venster
Name[an]=Nueva finestra
Name[ar]=????? ?????
Name[as]=???? ??????
Name[ast]=Ventana nueva
Name[az]=Yeni P?nc?r?
Name[be]=Новае акно
Name[bg]=Нов прозорец
Name[bn-BD]=???? ?????? (N)
Name[bn-IN]=???? ??????
Name[br]=Prenestr nevez
Name[brx]=????? ?????‘(N)
Name[bs]=Novi prozor
Name[ca]=Finestra nova
Name[cak]=K‘ak‘a‘ tzuwäch
Name[cs]=Nové okno
Name[cy]=Ffenestr Newydd
Name[da]=Nyt vindue
Name[de]=Neues Fenster
Name[dsb]=Nowe wokno
Name[el]=Ν?ο παρ?θυρο
Name[en-GB]=New Window
Name[en-US]=New Window
Name[en-ZA]=New Window
Name[eo]=Nova fenestro
Name[es-AR]=Nueva ventana
Name[es-CL]=Nueva ventana
Name[es-ES]=Nueva ventana
Name[es-MX]=Nueva ventana
Name[et]=Uus aken
Name[eu]=Leiho berria
Name[fa]=????? ????‌
Name[ff]=Henorde Hesere
Name[fi]=Uusi ikkuna
Name[fr]=Nouvelle fenêtre
Name[fy-NL]=Nij finster
Name[ga-IE]=Fuinneog Nua
Name[gd]=Uinneag ùr
Name[gl]=Nova xanela
Name[gn]=Ovetã pyahu
Name[gu-IN]=??? ??????
Name[he]=???? ???
Name[hi-IN]=??? ?????
Name[hr]=Novi prozor
Name[hsb]=Nowe wokno
Name[hu]=Új ablak
Name[hy-AM]=??? ????????
Name[id]=Jendela Baru
Name[is]=Nýr gluggi
Name[it]=Nuova finestra
Name[ja]=新しいウィンドウ
Name[ja-JP-mac]=新規ウインドウ
Name[ka]=????? ???????
Name[kk]=Жа?а терезе
Name[km]=?????????????
Name[kn]=??? ?????
Name[ko]=? ?
Name[kok]=???? ????
Name[ks]=??? ?????
Name[lij]=Neuvo barcon
Name[lo]=????????????
Name[lt]=Naujas langas
Name[ltg]=Jauns lūgs
Name[lv]=Jauns logs
Name[mai]=?? ?????
Name[mk]=Нов прозорец
Name[ml]=????? ?????
Name[mr]=???? ???
Name[ms]=Tetingkap Baru
Name[my]=????????????
Name[nb-NO]=Nytt vindu
Name[ne-NP]=???? ????????
Name[nl]=Nieuw venster
Name[nn-NO]=Nytt vindauge
Name[or]=???? ??????
Name[pa-IN]=???? ?????
Name[pl]=Nowe okno
Name[pt-BR]=Nova janela
Name[pt-PT]=Nova janela
Name[rm]=Nova fanestra
Name[ro]=Fereastr? nou?
Name[ru]=Новое окно
Name[sat]=???? ????? (N)
Name[si]=?? ????????
Name[sk]=Nové okno
Name[sl]=Novo okno
Name[son]=Zanfun taaga
Name[sq]=Dritare e Re
Name[sr]=Нови прозор
Name[sv-SE]=Nytt fönster
Name[ta]=????? ??????
Name[te]=????? ?????
Name[th]=????????????
Name[tr]=Yeni pencere
Name[tsz]=Eraatarakua jimpani
Name[uk]=Нове в?кно
Name[ur]=??? ?????
Name[uz]=Yangi oyna
Name[vi]=C?a s? m?i
Name[wo]=Palanteer bu bees
Name[xh]=Ifestile entsha
Name[zh-CN]=新建窗口
Name[zh-TW]=開新視窗


Exec=firefox %u

[Desktop Action new-private-window]
Name=Open a New Private Window
Name[ach]=Dirica manyen me mung
Name[af]=Nuwe privaatvenster
Name[an]=Nueva finestra privada
Name[ar]=????? ???? ?????
Name[as]=???? ????????? ??????
Name[ast]=Ventana privada nueva
Name[az]=Yeni M?xfi P?nc?r?
Name[be]=Новае акно адасаблення
Name[bg]=Нов прозорец за поверително сърфиране
Name[bn-BD]=???? ????????? ??????
Name[bn-IN]=???? ????????? ??????
Name[br]=Prenestr merdeiñ prevez nevez
Name[brx]=????? ???????? ?????‘
Name[bs]=Novi privatni prozor
Name[ca]=Finestra privada nova
Name[cak]=K‘ak‘a‘ ichinan tzuwäch
Name[cs]=Nové anonymní okno
Name[cy]=Ffenestr Breifat Newydd
Name[da]=Nyt privat vindue
Name[de]=Neues privates Fenster
Name[dsb]=Nowe priwatne wokno
Name[el]=Ν?ο παρ?θυρο ιδιωτικ?ς περι?γησης
Name[en-GB]=New Private Window
Name[en-US]=New Private Window
Name[en-ZA]=New Private Window
Name[eo]=Nova privata fenestro
Name[es-AR]=Nueva ventana privada
Name[es-CL]=Nueva ventana privada
Name[es-ES]=Nueva ventana privada
Name[es-MX]=Nueva ventana privada
Name[et]=Uus privaatne aken
Name[eu]=Leiho pribatu berria
Name[fa]=????? ?????? ????
Name[ff]=Henorde Suturo Hesere
Name[fi]=Uusi yksityinen ikkuna
Name[fr]=Nouvelle fenêtre de navigation privée
Name[fy-NL]=Nij priveefinster
Name[ga-IE]=Fuinneog Nua Phríobháideach
Name[gd]=Uinneag phrìobhaideach ùr
Name[gl]=Nova xanela privada
Name[gn]=Ovetã ñemi pyahu
Name[gu-IN]=??? ????? ??????
Name[he]=???? ???? ???
Name[hi-IN]=??? ???? ?????
Name[hr]=Novi privatni prozor
Name[hsb]=Nowe priwatne wokno
Name[hu]=Új privát ablak
Name[hy-AM]=????? ?????? ?????????
Name[id]=Jendela Mode Pribadi Baru
Name[is]=Nýr huliðsgluggi
Name[it]=Nuova finestra anonima
Name[ja]=新しいプライベートウィンドウ
Name[ja-JP-mac]=新規プライベートウインドウ
Name[ka]=????? ?????? ???????
Name[kk]=Жа?а жекел?к терезе
Name[km]=????????????????
Name[kn]=??? ????? ?????
Name[ko]=? ??? ?? ??
Name[kok]=??? ????? ?????
Name[ks]=??? ?????? ?????&
Name[lij]=Neuvo barcon privou
Name[lo]=????????????????????????????
Name[lt]=Naujas privataus naršymo langas
Name[ltg]=Jauns privatais lūgs
Name[lv]=Jauns privātais logs
Name[mai]=??? ??? ????? (W)
Name[mk]=Нов приватен прозорец
Name[ml]=????? ???????? ?????
Name[mr]=???? ???????? ???
Name[ms]=Tetingkap Persendirian Baharu
Name[my]=New Private Window
Name[nb-NO]=Nytt privat vindu
Name[ne-NP]=???? ???? ????????
Name[nl]=Nieuw privévenster
Name[nn-NO]=Nytt privat vindauge
Name[or]=???? ????????? ??????
Name[pa-IN]=???? ???????? ?????
Name[pl]=Nowe okno prywatne
Name[pt-BR]=Nova janela privativa
Name[pt-PT]=Nova janela privada
Name[rm]=Nova fanestra privata
Name[ro]=Fereastr? privat? nou?
Name[ru]=Новое приватное окно
Name[sat]=???? ???????? ????? (W )
Name[si]=?? ???????? ?????? (W)
Name[sk]=Nové okno v re?ime Súkromné prehliadanie
Name[sl]=Novo zasebno okno
Name[son]=Sutura zanfun taaga
Name[sq]=Dritare e Re Private
Name[sr]=Нови приватан прозор
Name[sv-SE]=Nytt privat fönster
Name[ta]=????? ????????? ??????
Name[te]=????? ???????? ?????
Name[th]=???????????????????
Name[tr]=Yeni gizli pencere
Name[tsz]=Juchiiti eraatarakua jimpani
Name[uk]=Приватне в?кно
Name[ur]=??? ??? ?????
Name[uz]=Yangi maxfiy oyna
Name[vi]=C?a s? riêng t? m?i
Name[wo]=Panlanteeru biir bu bees
Name[xh]=Ifestile yangasese entsha
Name[zh-CN]=新建隐私浏览窗口
Name[zh-TW]=新增隱私視窗
Exec=firefox --private-window %u

firefox 图标

技术图片

https://image.cha138.com/20210726/cc14a280600241409d16bba50ec2542c.jpg

 

技术图片

 

 

https://image.cha138.com/20210726/38f79d096d324b25a507171533182fda.jpg

图标自己选或去网上找自己喜欢的

把firefox.png 放到/usr/share/icons/hicolor/256*256/apps/里

$ sudo cp firefox.png  /usr/share/icons/hicolor/256*256/apps/
firefox.desktop 放到/usr/share/applications/里

$ sudo cp firefox /usr/share/applications/

通过 gtk-update-icon-cache /usr/share/icons/hicolor 更新。

$ sudo gtk-update-icon-cache /usr/share/icons/hicolor

以上是关于Linux自定义应用程序及其菜单图标的主要内容,如果未能解决你的问题,请参考以下文章

win10开始菜单程序怎么自定义

php CSS菜单图标/ Wordpress自定义菜单图标

easyui 导航菜单如何使用自定义图标

如何更改wordpress仪表盘图标及其左侧菜单导航文字

如何自定义Windows窗体的系统菜单?

如何在自定义帖子类型UI菜单图标区域添加字体真棒图标?