gnome打开方式修改

在Gnome的文件管理器(nautilus)里,双击一个文件的时候,系统会自动调用相应的程序去打开这个文件。在Nautilus里通过右键菜单固然可以修改默认的打开方式,但是缺乏灵活性和可操作性,比如,不能删除一些候选的打开方式,不能批量增加一些打开方式等等。
GNMOE的打开方式的配置方式涉及到以下几个目录和文件:
/usr/share/applications
~/.local/share/applications
/usr/share/applications/mimeinfo.cache
~/.local/share/applications/mimeinfo.cache
 
去这几个目录看一下,就会发现很多以。desktop为后缀的文件。
从总体上讲/etc/gnome/defaults.list 保存了全局的打开方式;
~/.local/share/applications/defaults.list 保存了个人的打开方式;当两着不一致是,优先采用局部的个人设置。
 
~/.local/share/applications
/usr/share/applications
这两个分别是局部的desktop项和全局的desktop项
 
/usr/share/applications/mimeinfo.cache
~/.local/share/applications/mimeinfo.cache
这两个分别是全局的和局部的打开方式缓存,想删除某种打开方式,或者修改默认的打开方式,在这里删除或改变顺序即可。
 
/usr/share/applications/defaults.list的结构 是这样的一种形式
程序的类型/文件类型=打开这个文件的项;[项2;]…[项n;]
候选打开方式可以有好几种中间用;隔开,不留其余字符
要修改一个文件的打开方式,需要先确定这个文件的类型
以纯文本文件为例 类型是plain 打开方式默认为vim.desktop候选的是firefox.desktop
text/plain=vim.desktop;firefox.desktop
 
可以直接编辑
~/.local/share/applications/defaults.list
编辑完之后,手工修改
/usr/share/applications/mimeinfo.cache
~/.local/share/applications/mimeinfo.cache
这两个cache文件。
 
下面看一下desktop文件的结构
  [Desktop Entry]
 
  Encoding=UTF-8 //字符编码
 
  Name=vim  //现实的名字
 
  MimeType=text/plain; //类型
 
  Exec=vim %f //运行的程序 %f表示一个参数
 
  Type=Application //类型
 
  Terminal=true //是否使用终端
 
  NoDisplay=true //是否显示在gnome菜单里
===========================================================================================================
[alex@localhost ~]$ls /usr/share/applications/
about-this-computer.desktop      fedora-release-notes.desktop         gnome-font-viewer.desktop                          gpilotd-control-applet.desktop  redhat-usermount.desktop
audacious2.desktop               fedora-SciTE.desktop                 gnome-gcalctool.desktop                            gpk-application.desktop         redhat-userpasswd.desktop
audacious2-gtkui.desktop         fedora-seahorse.desktop              gnome-gnomine.desktop                              gpk-install-catalog.desktop     rednotebook.desktop
audacious-ffaudio.desktop        fedora-system-config-vsftpd.desktop  gnome-gucharmap.desktop                            gpk-install-file.desktop        rhythmbox.desktop
authconfig.desktop               fedora-wine.desktop                  gnome-iagno.desktop                                gpk-prefs.desktop               screensavers
bluetooth-properties.desktop     fedora-wine-mime-msi.desktop         gnome-istanbul.desktop                             gpk-update-viewer.desktop       setroubleshoot.desktop
brasero-copy-medium.desktop      fedora-wine-notepad.desktop          gnome-keybinding.desktop                           gthumb.desktop                  shotwell.desktop
brasero.desktop                  fedora-wine-oleview.desktop          gnome-keyboard.desktop                             gthumb-import.desktop           shotwell-viewer.desktop
brasero-nautilus.desktop         fedora-wine-regedit.desktop          gnome-nautilus-autorun-software.desktop            ibus.desktop                    shutter.desktop
cheese.desktop                   fedora-wine-uninstaller.desktop      gnome-nautilus-computer.desktop                    ibus-setup.desktop              simple-scan.desktop
compiz-gtk.desktop               fedora-wine-wineboot.desktop         gnome-nautilus.desktop                             kde                             sound-juicer.desktop
defaults.list                    fedora-wine-winecfg.desktop          gnome-nautilus-file-management-properties.desktop  kde4                            system-config-audit.desktop
deja-dup.desktop                 fedora-wine-winefile.desktop         gnome-nautilus-folder-handler.desktop              lifeograph.desktop              system-config-bind.desktop
desktop-effects.desktop          fedora-wine-winemine.desktop         gnome-nautilus-home.desktop                        liveinst.desktop                system-config-date.desktop
emacs.desktop                    fedora-wine-winhelp.desktop          gnome-network-properties.desktop                   livna-alc.desktop               system-config-display.desktop
emesene.desktop                  fedora-wine-wordpad.desktop          gnome-network-scheme.desktop                       livna-amule.desktop             system-config-firewall.desktop
evince.desktop                   fedora-yumex.desktop                 gnome-panel.desktop                                livna-amulegui.desktop          system-config-httpd.desktop
evolution.desktop                gcm-import.desktop                   gnome-power-preferences.desktop                    livna-audacious-aac.desktop     system-config-keyboard.desktop
evolution-settings.desktop       gcm-prefs.desktop                    gnome-screensaver-preferences.desktop              livna-audacious-mp3.desktop     system-config-language.desktop
fedora-abiword.desktop           gedit.desktop                        gnome-screenshot.desktop                           livna-mplayer.desktop           system-config-nfs.desktop
fedora-abrt.desktop              gimp.desktop                         gnome-search-tool.desktop                          livna-wxcas.desktop             system-config-printer.desktop
fedora-anjuta.desktop            gnome-about.desktop                  gnome-session-properties.desktop                   manage-print-jobs.desktop       system-config-samba.desktop
fedora-deluge.desktop            gnome-about-me.desktop               gnome-settings-mouse.desktop                       metacity.desktop                system-config-services.desktop
fedora-dia.desktop               gnome-appearance-properties.desktop  gnome-sol.desktop                                  mimeinfo.cache                  system-config-users.desktop
fedora-empathy-accounts.desktop  gnome-at-properties.desktop          gnome-sudoku.desktop                               mount-archive.desktop           totem.desktop
fedora-empathy.desktop           gnome-baobab.desktop                 gnome-system-monitor.desktop                       mozilla-firefox.desktop         transmission.desktop
fedora-filezilla.desktop         gnomecc.desktop                      gnome-terminal.desktop                             nm-connection-editor.desktop    tsclient.desktop
fedora-gnochm.desktop            gnome-default-applications.desktop   gnome-theme-installer.desktop                      nm-openvpn.desktop              vinagre.desktop
fedora-gnumeric.desktop          gnome-devhelp.desktop                gnome-user-share-properties.desktop                palimpsest.desktop              vinagre-file.desktop
fedora-gvim.desktop              gnome-dictionary.desktop             gnome-vino-preferences.desktop                     pino.desktop                    virtualbox.desktop
fedora-im-chooser.desktop        gnome-display-properties.desktop     gnome-volume-control.desktop                       planner.desktop                 vncviewer.desktop
fedora-iok.desktop               gnome-eog.desktop                    gnome-yelp.desktop                                 qt4-qtconfig.desktop            xchat.desktop
fedora-meld.desktop              gnome-file-roller.desktop            gnote.desktop                                      redhat-userinfo.desktop         xfce4-im-chooser.desktop
===========================================================================================================
[alex@localhost ~]$ls /usr/local/share/applications/
defaults.list  google-chrome.desktop  mimeinfo.cache
===========================================================================================================
[alex@localhost ~]$ls ~/.local/share/applications/
defaults.list   mimeapps.list   preferred-mail-reader.desktop  wine-extension-chm.desktop  wine-extension-htm.desktop   wine-extension-ini.desktop  wine-extension-txt.desktop  wine-extension-xml.desktop
defaults.list~  mimeinfo.cache  preferred-web-browser.desktop  wine-extension-hlp.desktop  wine-extension-html.desktop  wine-extension-rtf.desktop  wine-extension-wri.desktop
===========================================================================================================
[alex@localhost ~]$cat ~/.local/share/applications/defaults.list
[Default Applications]
text/html=google-chrome.desktop
application/x-chm=fedora-gnochm.desktop
===========================================================================================================
[alex@localhost ~]$cat /usr/local/share/applications/google-chrome.desktop 
[Desktop Entry]
Version=1.0
Name=Google Chrome
# Only KDE 4 seems to use GenericName, so we reuse the KDE strings.
# From Ubuntu’s language-pack-kde-XX-base packages, version 9.04-20090413.
GenericName=Web Browser
GenericName[ar]=متصفح الشبكة
GenericName[bg]=Уеб браузър
GenericName[ca]=Navegador web
GenericName[cs]=WWW prohlížeč
GenericName[da]=Browser
GenericName[de]=Web-Browser
GenericName[el]=Περιηγητής ιστού
GenericName[en_GB]=Web Browser
GenericName[es]=Navegador web
GenericName[et]=Veebibrauser
GenericName[fi]=WWW-selain
GenericName[fr]=Navigateur Web
GenericName[gu]=વેબ બ્રાઉઝર
GenericName[he]=דפדפן אינטרנט
GenericName[hi]=वेब ब्राउज़र
GenericName[hu]=Webböngésző
GenericName[it]=Browser Web
GenericName[ja]=ウェブブラウザ
GenericName[kn]=ಜಾಲ ವೀಕ್ಷಕ
GenericName[ko]=웹 브라우저
GenericName[lt]=Žiniatinklio naršyklė
GenericName[lv]=Tīmekļa pārlūks
GenericName[ml]=വെബ് ബ്രൌസര്‍
GenericName[mr]=वेब ब्राऊजर
GenericName[nb]=Nettleser
GenericName[nl]=Webbrowser
GenericName[pl]=Przeglądarka WWW
GenericName[pt]=Navegador Web
GenericName[pt_BR]=Navegador da Internet
GenericName[ro]=Navigator de Internet
GenericName[ru]=Веб-браузер
GenericName[sl]=Spletni brskalnik
GenericName[sv]=Webbläsare
GenericName[ta]=இணைய உலாவி
GenericName[th]=เว็บเบราว์เซอร์
GenericName[tr]=Web Tarayıcı
GenericName[uk]=Навігатор Тенет
GenericName[zh_CN]=网页浏览器
GenericName[zh_HK]=網頁瀏覽器
GenericName[zh_TW]=網頁瀏覽器
# Not translated in KDE, from Epiphany 2.26.1-0ubuntu1.
GenericName[bn]=ওয়েব ব্রাউজার
GenericName[fil]=Web Browser
GenericName[hr]=Web preglednik
GenericName[id]=Browser Web
GenericName[or]=ଓ୍ବେବ ବ୍ରାଉଜର
GenericName[sk]=WWW prehliadač
GenericName[sr]=Интернет прегледник
GenericName[te]=మహాతల అన్వేషి
GenericName[vi]=Bộ duyệt Web
# Gnome and KDE 3 uses Comment.
Comment=Access the Internet
Comment[ar]=الدخول إلى الإنترنت
Comment[bg]=Достъп до интернет
Comment[bn]=ইন্টারনেটটি অ্যাক্সেস করুন
Comment[ca]=Accedeix a Internet
Comment[cs]=Přístup k internetu
Comment[da]=Få adgang til internettet
Comment[de]=Internetzugriff
Comment[el]=Πρόσβαση στο Διαδίκτυο
Comment[en_GB]=Access the Internet
Comment[es]=Accede a Internet.
Comment[et]=Pääs Internetti
Comment[fi]=Käytä internetiä
Comment[fil]=I-access ang Internet
Comment[fr]=Accéder à Internet
Comment[gu]=ઇંટરનેટ ઍક્સેસ કરો
Comment[he]=גישה אל האינטרנט
Comment[hi]=इंटरनेट तक पहुंच स्थापित करें
Comment[hr]=Pristup Internetu
Comment[hu]=Internetelérés
Comment[id]=Akses Internet
Comment[it]=Accesso a Internet
Comment[ja]=インターネットにアクセス
Comment[kn]=ಇಂಟರ್ನೆಟ್ ಅನ್ನು ಪ್ರವೇಶಿಸಿ
Comment[ko]=인터넷 연결
Comment[lt]=Interneto prieiga
Comment[lv]=Piekļūt internetam
Comment[ml]=ഇന്റര്‍‌നെറ്റ് ആക്‌സസ് ചെയ്യുക
Comment[mr]=इंटरनेटमध्ये प्रवेश करा
Comment[nb]=Gå til Internett
Comment[nl]=Verbinding maken met internet
Comment[or]=ଇଣ୍ଟର୍ନେଟ୍ ପ୍ରବେଶ କରନ୍ତୁ
Comment[pl]=Skorzystaj z internetu
Comment[pt]=Aceder à Internet
Comment[pt_BR]=Acessar a internet
Comment[ro]=Accesaţi Internetul
Comment[ru]=Доступ в Интернет
Comment[sk]=Prístup do siete Internet
Comment[sl]=Dostop do interneta
Comment[sr]=Приступите Интернету
Comment[sv]=Gå ut på Internet
Comment[ta]=இணையத்தை அணுகுதல்
Comment[te]=ఇంటర్నెట్‌ను ఆక్సెస్ చెయ్యండి
Comment[th]=เข้าถึงอินเทอร์เน็ต
Comment[tr]=İnternet’e erişin
Comment[uk]=Доступ до Інтернету
Comment[vi]=Truy cập Internet
Comment[zh_CN]=访问互联网
Comment[zh_HK]=連線到網際網路
Comment[zh_TW]=連線到網際網路
Exec=/opt/google/chrome/google-chrome %U
Terminal=false
Icon=google-chrome
Type=Application
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml_xml;
===========================================================================================================
Advertisements
This entry was posted in Computers and Internet. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s