https://wiki.archlinux.org/api.php?action=feedcontributions&user=Andy+Crowd&feedformat=atomArchWiki - User contributions [en]2024-03-28T10:20:00ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Desktop_entries&diff=450366Desktop entries2016-09-11T15:37:39Z<p>Andy Crowd: /* List or search in .desktop files */ changed --less to --list , the old options --less can still be used</p>
<hr />
<div>[[Category:Package development]]<br />
[[ja:デスクトップエントリ]]<br />
[[zh-CN:Desktop entries]]<br />
The freedesktop [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html Desktop Entry specification] provides a standard for applications to integrate into a [[desktop environment]]. Desktop entries are the configuration files that describe how an application is launched and which data it can handle. They also configure how an application appears in a menu with an icon, which is subject to the related [https://specifications.freedesktop.org/menu-spec/menu-spec-latest.html menu specification] standard. <br />
<br />
The most common desktop entries are the {{ic|.desktop}} and {{ic|.directory}} files. This article explains briefly how to create useful and standard compliant desktop entries. It is mainly intended for package contributors and maintainers, but may also be useful for software developers and others.<br />
<br />
There are roughly three types of desktop entries:<br />
<br />
; Application : a shortcut to an application<br />
; Link : a shortcut to a web link.<br />
; Directory : a container of meta data of a menu entry<br />
<br />
The following sections will roughly explain how these are created and validated. <br />
<br />
Related to this content, and also defined in {{ic|.desktop}} files, are MIME-type associations for data files. [[Default applications]] describes how these are configured. <br />
<br />
== Application entry ==<br />
<br />
Desktop entries for applications, or {{ic|.desktop}} files, are generally a combination of meta information resources and a shortcut of an application. These files usually reside in {{ic|/usr/share/applications}} or {{ic|/usr/local/share/applications}} for applications installed system-wide, or {{ic|~/.local/share/applications}} for user-specific applications. User entries take precedence over system entries.<br />
<br />
=== File example ===<br />
<br />
Following is an example of its structure with additional comments. The example is only meant to give a quick impression, and does not show how to utilize all possible entry keys. The complete list of keys can be found in the [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys freedesktop.org specification].<br />
<br />
[Desktop Entry]<br />
<br />
# The type as listed above<br />
Type=Application<br />
<br />
# The version of the desktop entry specification to which this file complies<br />
Version=1.0<br />
<br />
# The name of the application<br />
Name=jMemorize<br />
<br />
# A comment which can/will be used as a tooltip<br />
Comment=Flash card based learning tool<br />
<br />
# The path to the folder in which the executable is run<br />
Path=/opt/jmemorise<br />
<br />
# The executable of the application.<br />
Exec=jmemorize<br />
<br />
# The name of the icon that will be used to display this entry<br />
Icon=jmemorize<br />
<br />
# Describes whether this application needs to be run in a terminal or not<br />
Terminal=false<br />
<br />
# Describes the categories in which this entry should be shown<br />
Categories=Education;Languages;Java;<br />
<br />
=== Key definition ===<br />
<br />
All Desktop recognized desktop entries can be found on the [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys freedesktop.org] site.<br />
For example, the {{Ic|Type}} key defines three types of desktop entries: Application (type 1), Link (type 2) and Directory (type 3).<br />
<br />
* {{Ic|Version}} key does not stand for the version of the application, but for the version of the desktop entry specification to which this file complies.<br />
<br />
* {{Ic|Name}}, {{Ic|GenericName}} and {{Ic|Comment}} often contain redundant values in the form of combinations of them, like:<br />
<br />
Name=Pidgin Internet Messenger<br />
GenericName=Internet Messenger<br />
or<br />
Name=NoteCase notes manager<br />
Comment=Notes Manager<br />
<br />
This should be avoided, as it will only be confusing to users. The {{Ic|Name}} key should only contain the name, or maybe an abbreviation/acronym if available.<br />
<br />
* {{Ic|GenericName}} should state what you would generally call an application that does what this specific application offers (i.e. Firefox is a "Web Browser").<br />
* {{Ic|Comment}} is intended to contain any usefull additional information.<br />
<br />
==== Deprecation ====<br />
<br />
There are quite some keys that have become deprecated over time as the standard has matured. The best/simplest way is to use the tool {{Ic|desktop-file-validate}} which is part of the package {{Pkg|desktop-file-utils}}. To validate, run<br />
$ desktop-file-validate <your desktop file><br />
This will give you very verbose and useful warnings and error messages.<br />
<br />
== Icons ==<br />
<br />
See also the [https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html Icon Theme Specification].<br />
<br />
=== Common image formats ===<br />
<br />
Here is a short overview of image formats commonly used for icons.<br />
<br />
{| class="wikitable" align="center"<br />
|+ Support for image formats for icons as specified by the freedesktop.org standard.<br />
! Extension<br />
! Full Name and/or Description<br />
! Graphics Type<br />
! Container Format<br />
! Supported<br />
|-<br />
!align="left" | .[[wikipedia:Portable Network Graphics|png]]<br />
| Portable Network Graphics<br />
| [[wikipedia:Raster graphics|Raster]]<br />
| {{No}}<br />
| {{Yes}}<br />
|-<br />
!align="left" | .[[wikipedia:Scalable Vector Graphics|svg(z)]]<br />
| Scalable Vector Graphics<br />
| [[wikipedia:Vector graphics|Vector]]<br />
| {{No}}<br />
| {{G|Yes (optional)}}<br />
|-<br />
!align="left" | .[[wikipedia:X PixMap|xpm]]<br />
| X PixMap<br />
| [[wikipedia:Raster graphics|Raster]]<br />
| {{No}}<br />
| {{Y|Yes (deprecated)}}<br />
|-<br />
!align="left" | .[[wikipedia:Graphics Interchange Format|gif]]<br />
| Graphics Interchange Format<br />
| [[wikipedia:Raster graphics|Raster]]<br />
| {{No}}<br />
| {{No}}<br />
|-<br />
!align="left" | .[[wikipedia:ICO (icon image file format)|ico]]<br />
| MS Windows Icon Format<br />
| [[wikipedia:Raster graphics|Raster]]<br />
| {{Yes}}<br />
| {{No}}<br />
|-<br />
!align="left" | .[[wikipedia:Apple Icon Image|icns]]<br />
| Apple Icon Image<br />
| [[wikipedia:Raster graphics|Raster]]<br />
| {{Yes}}<br />
| {{No}}<br />
|-<br />
|}<br />
<br />
=== Converting icons ===<br />
<br />
If you stumble across an icon which is in a format that is not supported by the freedesktop.org standard (like {{ic|gif}} or {{ic|ico}}), you can use the ''convert'' tool (which is part of the {{Pkg|imagemagick}} package) to convert it to a supported/recommended format, e.g.:<br />
<br />
$ convert <icon name>.gif <icon name>.png<br />
<br />
If you convert from a container format like {{ic|ico}}, you will get all images that were encapsulated in the {{ic|ico}} file in the form {{ic|<icon name>-<number>.png}}. If you want to know the size of the image, or the number of images in a container file like {{ic|ico}} you can use the ''identify'' tool (also part of the {{Pkg|imagemagick}} package):<br />
<br />
{{hc|$ identify /usr/share/vlc/vlc48x48.ico|<br />
/usr/share/vlc/vlc48x48.ico[0] ICO 32x32 32x32+0+0 8-bit DirectClass 84.3kb<br />
/usr/share/vlc/vlc48x48.ico[1] ICO 16x16 16x16+0+0 8-bit DirectClass 84.3kb<br />
/usr/share/vlc/vlc48x48.ico[2] ICO 128x128 128x128+0+0 8-bit DirectClass 84.3kb<br />
/usr/share/vlc/vlc48x48.ico[3] ICO 48x48 48x48+0+0 8-bit DirectClass 84.3kb<br />
/usr/share/vlc/vlc48x48.ico[4] ICO 32x32 32x32+0+0 8-bit DirectClass 84.3kb<br />
/usr/share/vlc/vlc48x48.ico[5] ICO 16x16 16x16+0+0 8-bit DirectClass 84.3kb<br />
}}<br />
<br />
As you can see, the example ''ico'' file, although its name might suggest a single image of size 48x48, contains no less than 6 different sizes, of which one is even greater than 48x48, namely 128x128.<br />
<br />
Alternatively, you can use ''icotool'' (from {{Pkg|icoutils}}) to extract png images from ico container:<br />
$ icotool -x <icon name>.ico<br />
<br />
For extracting images from .icns container, you can use ''icns2png'' (provided by {{Aur|libicns}}):<br />
$ icns2png -x <icon name>.icns<br />
<br />
=== Obtaining icons ===<br />
<br />
Although packages that already ship with a .desktop-file most certainly contain an icon or a set of icons, there is sometimes the case when a developer has not created a .desktop-file, but may ship icons, nonetheless. So a good start is to look for icons in the source package.<br />
You can i.e. first filter for the extension with '''find''' and then use '''grep''' to filter further for certain buzzwords like the package name, "icon", "logo", etc, if there are quite a lot of images in the source package.<br />
$ find /path/to/source/package -regex ".*\.\(svg\|png\|xpm\|gif\|ico\)$"<br />
If the developers of an application do not include icons in their source packages, the next step would be to search on their web sites.<br />
Some projects, like i.e. ''tvbrowser'' have an [http://enwiki.tvbrowser.org/index.php/Banners,_Logos_and_other_Promotion_Material artwork/logo page] where additional icons may be found. If a project is multi-platform, there may be the case that even if the linux/unix package does not come with an icon, the Windows package might provide one. If the project uses a [[wikipedia:Version control system|Version control system]] like CVS/SVN/etc. and you have some experience with it, you also might consider browsing it for icons.<br />
If everything fails, the project might simply have no icon/logo yet.<br />
<br />
== Tools ==<br />
<br />
=== gendesk ===<br />
{{Pkg|gendesk}} started as an Arch Linux-specific tool for generating .desktop files by fetching the needed information directly from PKGBUILD files. Now it is a general tool that takes command-line arguments.<br />
<br />
Icons can be automatically downloaded from [http://openiconlibrary.sourceforge.net/ openiconlibrary], if available. (The source for icons can easily be changed in the future).<br />
<br />
==== How to use ====<br />
<br />
* Add {{Ic|gendesk}} to makedepends<br />
<br />
* Start the {{Ic|prepare()}} function with:<br />
<br />
{{bc|gendesk --pkgname "$pkgname" --pkgdesc "$pkgdesc"}}<br />
<br />
* Alternatively, if an icon is already provided ($pkgname.png, for instance). The {{Ic|-n}} flag is for not downloading an icon or using the default icon. Example:<br />
<br />
{{bc|gendesk -n --pkgname "$pkgname" --pkgdesc "$pkgdesc"}}<br />
<br />
* {{Ic|$srcdir/$pkgname.desktop}}&nbsp;will be created and can be installed in the {{Ic|package()}} function with:<br />
<br />
{{bc|install -Dm644 "$pkgname.desktop" "$pkgdir/usr/share/applications/$pkgname.desktop"}}<br />
<br />
* The icon can be installed with:<br />
<br />
{{bc|install -Dm644 "$pkgname.png" "$pkgdir/usr/share/pixmaps/$pkgname.png"}}<br />
<br />
* Use {{Ic|1=--name='Program Name'}} for choosing a name for the menu entry.<br />
<br />
* Use {{Ic|1=--exec='/opt/some_app/elf --with-ponies'}} for setting the exec field.<br />
<br />
* See the [https://github.com/xyproto/gendesk gendesk project] for more information.<br />
<br />
=== List or search in .desktop files ===<br />
<br />
The {{AUR|lsdesktopf}} script is listing available ''.desktop'' files or searching in their content.<br />
<br />
Examples<br />
$ lsdesktopf<br />
$ lsdesktopf --list<br />
$ lsdesktopf --list gtk zh_TW,zh_CN,en_GB<br />
<br />
List MIME-types or parts of MIME-types found in ''.desktop'', and which desktop files shares same MIME-type, output is equal as in [[Default applications#Configuration of the mimeapps.list file|mimeapps.list]] for section {{ic|[Added Associations]}}. <br />
<br />
$ lsdesktopf --gm<br />
$ lsdesktopf --gm [options]<br />
<br />
For more options use {{ic|lsdesktopf --help}}.<br />
<br />
=== fbrokendesktop ===<br />
<br />
The {{AUR|fbrokendesktop}} bash script using command ''which'' to detect broken {{ic|Exec}} that points to not existing path. Without any parameters it uses preset folders in {{ic|DskPath}} array. It shows only broken ''.desktop'' with full path and filename that is missing.<br />
<br />
Examples<br />
<br />
$ fbrokendesktop<br />
$ fbrokendesktop /usr<br />
$ fbrokendesktop /usr/share/apps/kdm/sessions/icewm.desktop<br />
<br />
== Tips and tricks ==<br />
<br />
=== Hide desktop entries ===<br />
<br />
Firstly, copy the desktop entry file in question to {{ic|~/.local/share/applications}} to avoid your changes being overwritten.<br />
<br />
Then, to hide the entry in all environments, open the desktop entry file in a text editor and add the following line: {{ic|NoDisplay&#61;true}}.<br />
<br />
To hide the entry in a specific desktop, add the following line to the desktop entry file: {{ic|NotShowIn&#61;''desktop-name''}}<br />
<br />
where ''desktop-name'' can be option such as ''GNOME'', ''Xfce'', ''KDE'' etc. A desktop entry can be hidden in more than desktop at once - simply separate the desktop names with a semi-colon.<br />
<br />
=== Autostart ===<br />
<br />
If you use an XDG-compliant desktop environment, such as GNOME or KDE, the desktop environment will automatically start [[Desktop entries|*.desktop]] files found in the following directories:<br />
<br />
* System-wide: {{ic|$XDG_CONFIG_DIRS/autostart/}} ({{ic|/etc/xdg/autostart/}} by default)<br />
:* GNOME also starts files found in {{ic|/usr/share/gnome/autostart/}}<br />
* User-specific: {{ic|$XDG_CONFIG_HOME/autostart/}} ({{ic|~/.config/autostart/}} by default)<br />
<br />
Users can override system-wide {{ic|*.desktop}} files by copying them into the user-specific {{ic|~/.config/autostart/}} folder.<br />
<br />
For a more specific description of directories used, [http://standards.freedesktop.org/autostart-spec/autostart-spec-latest.html Desktop Application Autostart Specification]. <br />
<br />
{{Note|This method is supported only by XDG-compliant desktop environments. Tools like {{AUR|dapper}}, {{pkg|dex}}, or {{AUR|fbautostart}} can be used to offer XDG autostart in unsupported desktop environments as long as some other autostart mechanism exists. Use the existing mechanism to start the xdg compliant autostart tool.}}<br />
<br />
=== Modify environment variables ===<br />
<br />
Edit the {{ic|Exec}} command by appending {{ic|env}}, for example:<br />
<br />
{{hc|~/.local/share/applications/abiword.desktop|2=<br />
Exec=env LANG=he_IL.UTF-8 abiword %U<br />
}}<br />
<br />
== See also ==<br />
<br />
* [[DeveloperWiki:Removal of desktop files]]<br />
* [[Wikipedia:.desktop|desktop wikipedia article]]<br />
* [http://freedesktop.org/wiki/Howto_desktop_files information for developers]</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Xinit&diff=449004Xinit2016-09-01T17:45:21Z<p>Andy Crowd: /* Switching between desktop environments/window managers */ added example of "lsdesktopf" for preview or start X sessions</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Desktop environments]]<br />
[[Category:X server]]<br />
[[de:Xinitrc]]<br />
[[el:Xinitrc]]<br />
[[es:Xinitrc]]<br />
[[fr:Startx]]<br />
[[it:Xinitrc]]<br />
[[ja:Xinitrc]]<br />
[[ru:Xinitrc]]<br />
[[zh-CN:Xinitrc]]<br />
{{Related articles start}}<br />
{{Related|Display manager}}<br />
{{Related|Xorg}}<br />
{{Related|xprofile}}<br />
{{Related|Xresources}}<br />
{{Related articles end}}<br />
<br />
The {{ic|~/.xinitrc}} file is a shell script read by ''xinit'' and by its front-end ''startx''. It is mainly used to execute [[desktop environment]]s, [[window manager]]s and other programs when starting the X server (e.g., starting daemons and setting environment variables). The ''xinit'' program starts the [[X Window System]] server and works as first client program on systems that are not using a [[display manager]].<br />
<br />
One of the main functions of {{ic|~/.xinitrc}} is to dictate which client for the X Window System is invoked with ''startx'' or ''xinit'' programs on a per-user basis. There exists numerous additional specifications and commands that may also be added to {{ic|~/.xinitrc}} as you further customize your system.<br />
<br />
Most display managers also source the similar [[xprofile]] before xinit.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|xorg-xinit}} package, which provides both ''xinit'', ''startx'', and a default xinitrc configuration file.<br />
<br />
== Configuration ==<br />
<br />
=== xserverrc ===<br />
<br />
The {{ic|xserverrc}} file is a shell script responsible for starting up the X server. Both ''startx'' and ''xinit'' execute {{ic|~/.xserverrc}} if it exists, ''startx'' will use {{ic|/etc/X11/xinit/xserverrc}} otherwise.<br />
<br />
In order to maintain an [[General troubleshooting#Session permissions|authenticated session]] with {{ic|logind}} and to prevent bypassing the screen locker by switching terminals, [[Xorg]] has to be started on the same virtual terminal where the login occurred.[http://blog.falconindy.com/articles/back-to-basics-with-x-and-systemd.html] Therefore it is recommended to specify {{ic|vt$XDG_VTNR}} in the {{ic|~/.xserverrc}} file:<br />
<br />
{{hc|~/.xserverrc|<br />
#!/bin/sh<br />
<br />
exec /usr/bin/Xorg -nolisten tcp "$@" vt$XDG_VTNR<br />
}}<br />
<br />
Alternatively, if you wish to have the X display on a separate console from the one where the server is invoked, you can do so by using the X server wrapper provided by {{ic|/usr/lib/systemd/systemd-multi-seat-x}}. For convenience, ''xinit'' and ''startx'' can be set up to use this wrapper by modifying your {{ic|~/.xserverrc}}.<br />
<br />
=== xinitrc ===<br />
<br />
If {{ic|.xinitrc}} is present in a user's home directory, ''startx'' and ''xinit'' execute it. Otherwise ''startx'' will run the default {{ic|/etc/X11/xinit/xinitrc}}.<br />
{{note|''Xinit'' has its own default behaviour instead of executing the file. See {{ic|man 1 xinit}} for details.}}<br />
This default xinitrc will start a basic environment with [[Twm]], {{Pkg|xorg-xclock}} and [[Xterm]] (assuming that the necessary packages are installed). Therefore, to start a different window manager or desktop environment, first create a copy of the default {{ic|xinitrc}} in home directory:<br />
<br />
$ cp /etc/X11/xinit/xinitrc ~/.xinitrc<br />
<br />
The reason of doing this (instead of creating one from scratch) is to preserve some desired default behaviour in the original file, such as sourcing shell scripts from {{ic|/etc/X11/xinit/xinitrc.d}}. Scripts in this directory without {{ic|.sh}} extension are not sourced.<br />
<br />
Append desired commands and ''remove/comment the conflicting lines''. Remember, lines following {{ic|exec}} would be ignored. For example, to start [[Openbox#Standalone|openbox]]:<br />
<br />
{{hc|~/.xinitrc|<br />
...<br />
<br />
if [ -d /etc/X11/xinit/xinitrc.d ] ; then<br />
for f in /etc/X11/xinit/xinitrc.d/'''?*.sh''' ; do<br />
[ -x "$f" ] && . "$f"<br />
done<br />
unset f<br />
fi<br />
<br />
# twm &<br />
# xclock -geometry 50x50-1+1 &<br />
# xterm -geometry 80x50+494+51 &<br />
# xterm -geometry 80x20+494-0 &<br />
# exec xterm -geometry 80x66+0+0 -name login<br />
<br />
## some applications that should be run in the background<br />
xscreensaver '''&'''<br />
xsetroot -cursor_name left_ptr '''&'''<br />
<br />
'''exec''' openbox-session<br />
}}<br />
<br />
{{Note|At the very least, ensure that the ''if block'' in the example above is present in your {{ic|.xinitrc}} file to ensure that the scripts in {{ic|/etc/X11/xinit/xinitrc.d}} are sourced.}} <br />
<br />
Long-running programs started before the window manager, such as a screensaver and wallpaper application, must either fork themselves or be run in the background by appending an {{ic|&}} sign. Otherwise, the script would halt and wait for each program to exit before executing the window manager or desktop environment. Note that some programs should instead not be forked, to avoid race bugs, as is the case of [[xrdb]]. Prepending {{ic|exec}} will replace the script process with the window manager process, so that X does not exit even if this process forks to the background.<br />
<br />
== Usage ==<br />
<br />
To now run Xorg as a regular user, issue:<br />
<br />
$ startx<br />
<br />
or<br />
<br />
$ xinit -- :1<br />
<br />
{{Note|''xinit'' does not handle multiple displays when another X server is already started. For that you must specify the display by appending {{ic|-- :''display_number''}}, where {{ic|''display_number''}} is 1 or more.}}<br />
<br />
Your window manager (or desktop environment) of choice should now start correctly.<br />
<br />
To quit X, run your window manager's exit function (assuming it has one). If it lacks such functionality, run:<br />
<br />
$ pkill -15 Xorg<br />
<br />
{{Note|''pkill'' will kill all running X instances. To specifically kill the window manager on the current virtual terminal, run:<br />
<br />
$ pkill -15 -t tty"$XDG_VTNR" Xorg<br />
<br />
The program {{ic|xprop}} is provided by the {{Pkg|xorg-xprop}} package.<br />
}}<br />
<br />
== Autostart X at login ==<br />
<br />
Make sure that ''startx'' is properly [[#Configuration|configured]].<br />
<br />
For [[Bash]], add the following to the bottom of {{ic|~/.bash_profile}}. If the file does not exist, copy a skeleton version from {{ic|/etc/skel/.bash_profile}}. For [[Zsh]], add it to {{ic|~/.zprofile}}.<br />
<br />
{{bc|1=<nowiki><br />
[ -z "$DISPLAY" -a "$(fgconsole)" -eq 1 ] && exec startx<br />
</nowiki>}}<br />
<br />
{{Note|<br />
* You can replace the {{ic|-eq 1}} comparison with one like {{ic|-le 3}} (for vt1 to vt3) if you want to use graphical logins on more than one virtual terminal.<br />
* If you would like to remain logged in when the X session ends, remove {{ic|exec}}.<br />
}}<br />
<br />
See also [[Fish#Start X at login]] and [[Systemd/User#Automatic login into Xorg without display manager]].<br />
<br />
=== Automatic login to the virtual console ===<br />
<br />
This method can be combined with [[automatic login to virtual console]].<br />
<br />
== Tips and tricks ==<br />
<br />
=== Override xinitrc from command line ===<br />
<br />
If you have a working {{ic|~/.xinitrc}}, but just want to try other window manager or desktop environment, you can run it by issuing ''startx'' followed by the path to the window manager:<br />
<br />
$ startx /full/path/to/window-manager<br />
<br />
If the window manager takes arguments, they need to be enquoted to be recognized as part of the first parameter of ''startx'':<br />
<br />
$ startx "/full/path/to/window-manager --key value"<br />
<br />
Note that the full path is '''required'''. Optionally, you can also specify custom options for [[#xserverrc]] script by appending them after {{ic|--}}, e.g.:<br />
<br />
$ startx /usr/bin/enlightenment -- -br +bs -dpi 96<br />
<br />
See also {{ic|man startx}}.<br />
<br />
{{Tip|This can be used even to start a regular GUI programs but without any of the window manager features. See also [[#Starting applications without a window manager]] and [[Running program in separate X display]].}}<br />
<br />
=== Switching between desktop environments/window managers ===<br />
<br />
If you are frequently switching between different desktop environments or window managers, it is convenient to either use a [[display manager]] or expand {{ic|.xinitrc}} to make the switching possible.<br />
<br />
The following example {{ic|~/.xinitrc}} shows how to start a particular desktop environment or window manager with an argument:<br />
<br />
{{hc|~/.xinitrc|<nowiki><br />
...<br />
<br />
# Here Xfce is kept as default<br />
session=${1:-xfce}<br />
<br />
case $session in<br />
awesome ) exec awesome;;<br />
bspwm ) exec bspwm;;<br />
catwm ) exec catwm;;<br />
cinnamon ) exec cinnamon-session;;<br />
dwm ) exec dwm;;<br />
enlightenment ) exec enlightenment_start;;<br />
ede ) exec startede;;<br />
fluxbox ) exec startfluxbox;;<br />
gnome ) exec gnome-session;;<br />
gnome-classic ) exec gnome-session --session=gnome-classic;;<br />
i3|i3wm ) exec i3;;<br />
icewm ) exec icewm-session;;<br />
jwm ) exec jwm;;<br />
kde ) exec startkde;;<br />
mate ) exec mate-session;;<br />
monster|monsterwm ) exec monsterwm;;<br />
notion ) exec notion;;<br />
openbox ) exec openbox-session;;<br />
unity ) exec unity;;<br />
xfce|xfce4 ) exec startxfce4;;<br />
xmonad ) exec xmonad;;<br />
# No known session, try to run it as command<br />
*) exec $1;;<br />
esac<br />
</nowiki>}}<br />
<br />
To pass the argument:<br />
<br />
$ xinit<br />
$ xinit gnome<br />
$ xinit kde<br />
$ xinit wmaker<br />
<br />
or<br />
<br />
$ startx<br />
$ startx ~/.xinitrc gnome<br />
$ startx ~/.xinitrc kde<br />
$ startx ~/.xinitrc wmaker<br />
<br />
As an alternative you can use {{AUR|lsdesktopf}} that can read content of .desktop files, preview executable content by few ways or start X sessions.<br />
<br />
Will only show numbered content of .desktop files located in {{ic|/usr/share/xsessions/}}<br />
<br />
lsdesktopf --sxs<br />
lsdesktopf --sxs n<br />
<br />
To run X session from list of available by entering the associated order number<br />
<br />
lsdesktopf --rxs<br />
lsdesktopf --rxs n<br />
<br />
For more options for starting or preview available X sessions use {{ic|lsdesktopf --help ses}}.<br />
<br />
=== Starting applications without a window manager ===<br />
<br />
It is possible to start only specific applications without a window manager, although most likely this is only useful with a single application shown in full-screen mode. For example:<br />
<br />
{{hc|~/.xinitrc|<br />
...<br />
<br />
exec chromium<br />
}}<br />
<br />
With this method you need to set each application window's geometry through its own configuration files, if possible at all.<br />
<br />
{{Tip|This method can be useful to launch graphical games, especially on systems where excluding the memory or CPU usage of a window manager or desktop environment, and possible accessory applications, can help improve the game's execution performance.}}<br />
<br />
See also [[Display manager#Starting applications without a window manager]].</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Talk:Media_Transfer_Protocol&diff=447465Talk:Media Transfer Protocol2016-08-22T19:32:37Z<p>Andy Crowd: fixed some style, by adding "::" infront my posts</p>
<hr />
<div>== Custom udev rules and rebooting ==<br />
<br />
In a couple of places {{ic|/usr/lib/udev/rules.d/}} is used as location for custom {{ic|udev}} rules. Isn't the {{ic|/etc/udev/rules.d/}} a better place for them? If so I propose to change {{ic|/usr/lib/udev/rules.d/}} to {{ic|/etc/udev/rules.d/}}.<br />
<br />
Also, there's no need for rebooting the system, as suggested in [[MTP#gvfs-mtp troubleshooting]]. What is that? A Windows? ;} I think this should be removed or changed to some other means like “relogging”.<br />
<br />
--thebodzio 22:34, 29 December 2014 (UTC)<br />
<br />
:Yes to both, [[Udev#About udev rules]] and [[Udev#Loading new rules]]. -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 01:39, 31 December 2014 (UTC)<br />
<br />
:: May be it must be removed "This article or section is a candidate for merging with udev."? I have added more related info to gvfs-mtp but not related to udev, I think that it is good if will stay here as it is. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:28, 17 August 2016 (UTC)).<br />
<br />
::I am not sure about two probably similar [[udev]] rules [[MTP#Media_players]] and [[MTP#gvfs-mtp]], may be to have only one is enough and merge both?(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 22:58, 19 August 2016 (UTC)) <br />
:: EDIT: <br />
:: I will try to merge them after few days, I hope it is OK. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 21:24, 20 August 2016 (UTC))<br />
<br />
:: This is what I mean about merging Media players and gvfs-mtp sections and udev rules:<br />
ATTR{idVendor}=="04b7", ATTR{idProduct}=="88a9", SYMLINK+="libmtp", MODE="660", ENV{ID_MTP_DEVICE}="1"<br />
+<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04b7", ATTR{idProduct}=="88a9", MODE="0666", OWNER="[username]"<br />
=<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04b7", ATTR{idProduct}=="88a9", MODE="0660", GROUP="uucp", ENV{ID_MTP_DEVICE}="1", SYMLINK+="libmtp"<br />
:: (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:42, 21 August 2016 (UTC)).<br />
<br />
:: In Archlinux I have no problem with detecting my phone without Udev rules but in Debian I have tested both udev rules and only the last that I combined worked perfect, I could both see and mount MTP in Thunar.<br />
<br />
:: (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 11:12, 22 August 2016 (UTC))<br />
<br />
:: About restarting computer: after changing Udev rules and reload them is not working, I think that it is also necessary restart gvfsd and related to it processes or just reboot computer that helped me much better. Did some else tested it?<br />
:: (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:46, 22 August 2016 (UTC)).</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Talk:Media_Transfer_Protocol&diff=447463Talk:Media Transfer Protocol2016-08-22T18:48:26Z<p>Andy Crowd: Udev update and restart computer is better than reload Udev rules? I think gvfsd and/or fuse related keeps something in memory. Some tested it?</p>
<hr />
<div>== Custom udev rules and rebooting ==<br />
<br />
In a couple of places {{ic|/usr/lib/udev/rules.d/}} is used as location for custom {{ic|udev}} rules. Isn't the {{ic|/etc/udev/rules.d/}} a better place for them? If so I propose to change {{ic|/usr/lib/udev/rules.d/}} to {{ic|/etc/udev/rules.d/}}.<br />
<br />
Also, there's no need for rebooting the system, as suggested in [[MTP#gvfs-mtp troubleshooting]]. What is that? A Windows? ;} I think this should be removed or changed to some other means like “relogging”.<br />
<br />
--thebodzio 22:34, 29 December 2014 (UTC)<br />
<br />
:Yes to both, [[Udev#About udev rules]] and [[Udev#Loading new rules]]. -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 01:39, 31 December 2014 (UTC)<br />
<br />
:: May be it must be removed "This article or section is a candidate for merging with udev."? I have added more related info to gvfs-mtp but not related to udev, I think that it is good if will stay here as it is. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:28, 17 August 2016 (UTC)).<br />
<br />
::I am not sure about two probably similar [[udev]] rules [[MTP#Media_players]] and [[MTP#gvfs-mtp]], may be to have only one is enough and merge both?(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 22:58, 19 August 2016 (UTC)) <br />
:: EDIT: <br />
:: I will try to merge them after few days, I hope it is OK. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 21:24, 20 August 2016 (UTC))<br />
<br />
:: This is what I mean about merging Media players and gvfs-mtp sections and udev rules:<br />
ATTR{idVendor}=="04b7", ATTR{idProduct}=="88a9", SYMLINK+="libmtp", MODE="660", ENV{ID_MTP_DEVICE}="1"<br />
+<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04b7", ATTR{idProduct}=="88a9", MODE="0666", OWNER="[username]"<br />
=<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04b7", ATTR{idProduct}=="88a9", MODE="0660", GROUP="uucp", ENV{ID_MTP_DEVICE}="1", SYMLINK+="libmtp"<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:42, 21 August 2016 (UTC)).<br />
<br />
In Archlinux I have no problem with detecting my phone without Udev rules but in Debian I have tested both udev rules and only the last that I combined worked perfect, I could both see and mount MTP in Thunar.<br />
<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 11:12, 22 August 2016 (UTC))<br />
<br />
About restarting computer: after changing Udev rules and reload them is not working, I think that it is also necessary restart gvfsd and related to it processes or just reboot computer that helped me much better. Did some else tested it?<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:46, 22 August 2016 (UTC)).</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Media_Transfer_Protocol&diff=447354Media Transfer Protocol2016-08-22T11:21:34Z<p>Andy Crowd: /* gvfs-mtp */ replaced with tested updated and working udev rule</p>
<hr />
<div>[[Category:Storage]]<br />
[[Category:Mobile devices]]<br />
[[fa:MTP]]<br />
[[ja:MTP]]<br />
[[ru:MTP]]<br />
[[zh-CN:MTP]]<br />
{{Related articles start}}<br />
{{Related|USB storage devices}}<br />
{{Related articles end}}<br />
[[Wikipedia:Media_Transfer_Protocol|MTP]], or the ''Media Transfer Protocol'', is a USB device class which is used by many mobile phones (e.g. Samsung Galaxy S4) and media players (e.g. Creative Zen).<br />
<br />
== Installation ==<br />
<br />
=== Functionality ===<br />
<br />
Linux MTP support is provided by [[installing]] the {{Pkg|libmtp}} package. It can be installed on its own and used to access devices. However, a number of packages are available that use it as a dependency and add additional convenience (e.g. filemanager) functionalities and compatibility with particular device types - which includes improving transfer access speeds. <br />
<br />
These packages to choose from all implement a [[Wikipedia:Filesystem in Userspace]]: <br />
<br />
* {{Pkg|mtpfs}}<br />
* {{AUR|jmtpfs}} - is reported to work well for newer Android 4+ devices <br />
* {{AUR|go-mtpfs-git}} - is reported to work well for newer Android 3+ devices <br />
* {{AUR|simple-mtpfs}}<br />
* {{Pkg|android-file-transfer}} - MTP client with minimalistic UI<br />
<br />
All of them aim at better functionality and performance over {{ic|libmtp}}. Since there are a lot of different USB devices, you might want to research first which one looks most suitable for yours. <br />
<br />
{{Tip|It is recommended to reboot your computer after installing MTP related packages.}}<br />
<br />
=== Integration with file managers ===<br />
<br />
To view the contents of your Android device's storage via MTP in your file manager, install the corresponding plugin:<br />
<br />
* For file managers that use [[GVFS]] (GNOME Files), install {{Pkg|gvfs-mtp}} for MTP or {{Pkg|gvfs-gphoto2}} for PTP support.<br />
* For file managers that use KIO (KDE's Dolphin), MTP support is included in {{Pkg|kio-extras}} (dependency of dolphin).<br />
<br />
After installing the required package, the device should show up in the file manager automatically and be accessible via an URL, for example {{ic|mtp://[usb:002,013]/}}.<br />
<br />
== Usage ==<br />
<br />
It might be required to create a mount-point directory first. The directory {{ic|~/mnt}} is used as an example below. Also do not forget to unlock your phone's screen before connecting it to the computer.<br />
<br />
=== libmtp ===<br />
<br />
Detect your device:<br />
<br />
# mtp-detect<br />
<br />
If an error is returned, see [[#libmtp 2|troubleshooting libmtp]]. <br />
<br />
{{Note|Your regular user must be in the {{ic|uucp}} [[users_and_groups#Example_adding_a_user|group]].}}<br />
<br />
Connect to your device:<br />
# mtp-connect<br />
<br />
If connection is successful, there are several switch options to use in conjunction with ''mtp-connect'' to access data on the device. You might want to use some stand alone commands:<br />
mtp-albumart mtp-emptyfolders mtp-getplaylist mtp-reset mtp-trexist<br />
mtp-albums mtp-files mtp-hotplug mtp-sendfile<br />
mtp-connect mtp-folders mtp-newfolder mtp-sendtr<br />
mtp-delfile mtp-format mtp-newplaylist mtp-thumb<br />
mtp-detect mtp-getfile mtp-playlists mtp-tracks<br />
<br />
=== mtpfs ===<br />
<br />
{{Note | The following is likely to not work and you might have to resort to [[Digital_Cameras#libgphoto2|gphoto2]] or a file manager with gvfs support like [[PCManFM]]. }}<br />
<br />
First edit your {{ic|/etc/fuse.conf}} and uncomment the following line:<br />
user_allow_other<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
$ mtpfs -o allow_other ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== jmtpfs ===<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ jmtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
Make this cohere to the rest of Linux (use regular mount/umount commands) by doing two steps<br />
<br />
$# ln -s <actual mount command's path/name> <a name consistent with Linux's mount convention><br />
$ ln -s /sbin/jmtpfs /sbin/mount.jmtpfs<br />
<br />
add this line to /etc/fstab; <br />
<br />
#jmtpfs <mount path> fuse nodev,allow_other,<other options> 0 0<br />
jmtpfs /home/sam/run/motog fuse nodev,allow_other,rw,user,noauto,noatime,uid=1000,gid=1000 0 0<br />
<br />
Now mount the device and see if the options "took"<br />
<br />
$ mount /home/sam/run/motog<br />
Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).<br />
Android device detected, assigning default bug flags<br />
$ mount <br />
...<br />
jmtpfs on /home/sam/run/motog type fuse.jmtpfs (rw,nosuid,nodev,noexec,noatime,user_id=1000,group_id=1000,allow_other,user=sam)<br />
<br />
=== go-mtpfs ===<br />
<br />
{{Note|Mounting with {{ic|go-mtpfs}} might fail if an external SD Card is present. If you try to access your device while having an SD card and go-mtpfs complains, try removing the SD card and mounting again.}}<br />
<br />
Install {{Pkg|android-udev}}, which will allow you to edit {{ic|/etc/udev/rules.d/51-android.rules}} and apply to your {{ic|idVendor}} and {{ic|idProduct}}, which you can see after running ''mtp-detect''. To the end of the line, add your user {{ic|<nowiki>OWNER="<user>"</nowiki>}}.<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ go-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== simple-mtpfs ===<br />
<br />
List MTP devices:<br />
<br />
$ simple-mtpfs --list-devices<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
<br />
$ simple-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== Android File Transfer ===<br />
<br />
;FUSE interface<br />
<br />
Mount your device on {{ic|~/my-device}}:<br />
$ mkdir ~/my-device<br />
$ aft-mtp-mount ~/my-device<br />
<br />
If you want album art to be displayed, it must be named {{ic|albumart.xxx}} and placed first in the destination folder. Then copy other files. Also, note that fuse could be 7-8 times slower than ui/cli file transfer.<br />
<br />
Unmount device mounted on {{ic|~/my-device}}:<br />
<br />
$ fusermount -u ~/my-device<br />
<br />
;Qt user interface<br />
<br />
Start the application, choose a destination folder and click any button on the toolbar. Available options are: ''Upload Album'', ''Upload Directory'' and ''Upload Files''. The latter two are self-explanatory. ''Upload album'' searches the source directory for album covers, and sets the best available cover.<br />
<br />
=== Media players ===<br />
<br />
You can also use your MTP device in music players such as Amarok. To achieve this, you might have to edit {{ic|/etc/udev/rules.d/51-android.rules}} (the MTP device used in the following example is a Galaxy Nexus). <br />
Run:<br />
<br />
$ lsusb<br />
<br />
Search for your device. It should be something like that:<br />
Bus 003 Device 011: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-P7500 [Galaxy Tab 10.1]<br />
<br />
And entry to {{ic|/etc/udev/rules.d/51-android.rules}} will be this:<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="[username]"<br />
<br />
Also reload udev rules:<br />
# udevadm control --reload<br />
<br />
=== gvfs-mtp ===<br />
<br />
{{Merge|udev}}<br />
<br />
The {{Pkg|gvfs-mtp}} is available in the official repositories.<br />
<br />
With {{ic|lsusb}} you can get information about your device where Bus and Device numbers can be used with {{ic|gvfs-mtp}} and device ID for creating of an [[udev]] rule.<br />
Bus '''002''' Device '''018''': ID '''04b7''':'''88a9''' Compal Electronics, Inc.<br />
(...)<br />
<br />
To see detected device with enabled MTP<br />
<br />
Use ''gvfs-mount'':<br />
<br />
{{hc|<NOWIKI>gvfs-mount -li | grep -e ^Volume -e activation_root</NOWIKI>|2=<br />
Volume(0): MT65xx Android Phone<br />
activation_root=mtp://[usb:'''002''','''018''']/<br />
}}<br />
<br />
Use ''lsusb'':<br />
<br />
{{hc|<NOWIKI>lsusb -v 2> /dev/null | grep -e Bus -e iInterface -e bInterfaceProtocol</NOWIKI>|<br />
(......<br />
......)<br />
Bus 002 Device 018: ID 04b7:88a9 Compal Electronics, Inc. <br />
bInterfaceProtocol 0 <br />
iInterface 5 MTP<br />
(......<br />
......)<br />
}}<br />
<br />
To mount all available connected MTP devices use inline script<br />
<br />
gvfs-mount -li | awk -F= '{if(index($2,"mtp") == 1)system("gvfs-mount "$2)}'<br />
<br />
To mount or dismount from a command with gvfs-mtp use Bus and Device numbers, e.g. to mount {{ic|gvfs-mount mtp://[usb:001,007]/}} and to unmount {{ic|gvfs-mount -u mtp://[usb:001,007]/}}. The mounted device will be available in a directory that begins with ''mtp:host='' and is located under ''/run/user/$UID/gvfs/''.<br />
<br />
Disable automount of MTP devises with gvfs you will need to change value ''true'' to ''false'' for variable ''AutoMount'' that is located in {{ic|/usr/share/gvfs/mounts/mtp.mount}}.<br />
<br />
{{Note|The file managers can have own options for automount. On start they checking for all available mountable devices.}}<br />
<br />
If your device isn't showing up in the file manager then the {{Pkg|libmtp}} is missing a native support and is not currently available in the list of the [https://sourceforge.net/p/libmtp/code/ci/HEAD/tree/src/music-players.h supported devices]. If you will try to mount by using command line you may also get an error<br />
<br />
{{bc|1=Device 0 (VID=''XXXX'' and PID=''XXXX'') is UNKNOWN.<br />
Please report this VID/PID and the device model to the libmtp development team}}<br />
<br />
The workaround to make it shown in the file manager is to write an [[udev]] rule for the device but it is no guaranty that you will be able to mount it with by using MTP connection.<br />
<br />
Use ID number that represents by pattern '''vendorId''':'''productID''',e.g. '''04b7''':'''88a9''', and make an udev rule by creating a configuration file<br />
<br />
{{hc|/etc/udev/rules.d/51-android.rules|<NOWIKI><br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04b7", ATTR{idProduct}=="88a9", MODE="0660", GROUP="uucp", ENV{ID_MTP_DEVICE}="1", SYMLINK+="libmtp"</NOWIKI><br />
}}<br />
Reload the udev rules.<br />
<br />
# udevadm control --reload<br />
<br />
The file managers with support for [[gvfs]] will be able to show MTP devices and mount them if supported by {{Pkg|libmtp}} but if has no support and cannot be opened then change settings in the phone to PTP and install {{Pkg|gvfs-gphoto2}} for having access at least to the photos, command line mounting of PTP is a little similar to mounting of the MTP devices: {{ic|gvfs-mount gphoto2://[usb:002,019]/}}.<br />
<br />
{{Note|If you getting limited access to the device and cannot use standard commands from command line such as e.g. {{ic|cp}},{{ic|ls}} then look for [[gvfs]] own alternatives, {{ic|ls -1 /usr/bin/gvfs-*}}.}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== libmtp ===<br />
<br />
==== Unable to enumerate USB device ====<br />
{{Deletion|This should be an old kernel bug, and should have been fixed already. There is no bug report to confirm though.}}<br />
{{Merge||Unrelated to MTP, perhaps suited for [[USB storage devices]]}}<br />
<br />
If you see a message like this in system log ({{ic|journalctl}})<br />
<br />
usb usb4-port2: unable to enumerate USB device<br />
<br />
You can try following temporary [https://bbs.archlinux.org/viewtopic.php?pid=1087323#p1087323 workaround]<br />
<br />
# modprobe -vr uhci_hcd<br />
# modprobe -va ohci_hcd<br />
# modprobe -va uhci_hcd<br />
<br />
If it works you should create {{ic|/etc/modprobe.d/usb_hci_order.conf}} with following content<br />
<br />
# create a dependency on ohci for uhci, which fixes problems<br />
# with external usb devices not showing up<br />
#<br />
softdep uhci_hcd pre: ohci_hcd<br />
<br />
=== jmtpfs ===<br />
<br />
==== Input/output error upon first access ====<br />
<br />
Symptoms: jmtpfs successfully mounts, but as soon as one attempts to access files on the device (e.g. via {{ic|ls}}), an error is reported:<br />
<br />
cannot access <mount-point>: Input/output error<br />
<br />
This appears to be a security feature: MTP does not work when the phone is locked by the lockscreen. Unlock the phone and it should work again as long as the cord remains connected.<br />
<br />
=== kio-mtp ===<br />
<br />
If you are not able to use the action "Open with File Manager", you may work around this problem by editing the file {{ic|/usr/share/apps/solid/actions/solid_mtp.desktop}}.<br />
<br />
Change the line<br />
<br />
Exec=kioclient exec mtp:udi=%i/<br />
<br />
To<br />
<br />
Exec=dolphin "mtp:/"</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Talk:Media_Transfer_Protocol&diff=447353Talk:Media Transfer Protocol2016-08-22T11:12:21Z<p>Andy Crowd: added info about result of testing udev rules, only the last was working good</p>
<hr />
<div>== Custom udev rules and rebooting ==<br />
<br />
In a couple of places {{ic|/usr/lib/udev/rules.d/}} is used as location for custom {{ic|udev}} rules. Isn't the {{ic|/etc/udev/rules.d/}} a better place for them? If so I propose to change {{ic|/usr/lib/udev/rules.d/}} to {{ic|/etc/udev/rules.d/}}.<br />
<br />
Also, there's no need for rebooting the system, as suggested in [[MTP#gvfs-mtp troubleshooting]]. What is that? A Windows? ;} I think this should be removed or changed to some other means like “relogging”.<br />
<br />
--thebodzio 22:34, 29 December 2014 (UTC)<br />
<br />
:Yes to both, [[Udev#About udev rules]] and [[Udev#Loading new rules]]. -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 01:39, 31 December 2014 (UTC)<br />
<br />
:: May be it must be removed "This article or section is a candidate for merging with udev."? I have added more related info to gvfs-mtp but not related to udev, I think that it is good if will stay here as it is. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:28, 17 August 2016 (UTC)).<br />
<br />
::I am not sure about two probably similar [[udev]] rules [[MTP#Media_players]] and [[MTP#gvfs-mtp]], may be to have only one is enough and merge both?(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 22:58, 19 August 2016 (UTC)) <br />
:: EDIT: <br />
:: I will try to merge them after few days, I hope it is OK. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 21:24, 20 August 2016 (UTC))<br />
<br />
:: This is what I mean about merging Media players and gvfs-mtp sections and udev rules:<br />
ATTR{idVendor}=="04b7", ATTR{idProduct}=="88a9", SYMLINK+="libmtp", MODE="660", ENV{ID_MTP_DEVICE}="1"<br />
+<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04b7", ATTR{idProduct}=="88a9", MODE="0666", OWNER="[username]"<br />
=<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04b7", ATTR{idProduct}=="88a9", MODE="0660", GROUP="uucp", ENV{ID_MTP_DEVICE}="1", SYMLINK+="libmtp"<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:42, 21 August 2016 (UTC)).<br />
<br />
In Archlinux I have no problem with detecting my phone without Udev rules but in Debian I have tested both udev rules and only the last that I combined worked perfect, I could both see and mount MTP in Thunar.<br />
<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 11:12, 22 August 2016 (UTC))</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Talk:Media_Transfer_Protocol&diff=447239Talk:Media Transfer Protocol2016-08-21T19:55:48Z<p>Andy Crowd: missed to add SYMLINK :(</p>
<hr />
<div>== Custom udev rules and rebooting ==<br />
<br />
In a couple of places {{ic|/usr/lib/udev/rules.d/}} is used as location for custom {{ic|udev}} rules. Isn't the {{ic|/etc/udev/rules.d/}} a better place for them? If so I propose to change {{ic|/usr/lib/udev/rules.d/}} to {{ic|/etc/udev/rules.d/}}.<br />
<br />
Also, there's no need for rebooting the system, as suggested in [[MTP#gvfs-mtp troubleshooting]]. What is that? A Windows? ;} I think this should be removed or changed to some other means like “relogging”.<br />
<br />
--thebodzio 22:34, 29 December 2014 (UTC)<br />
<br />
:Yes to both, [[Udev#About udev rules]] and [[Udev#Loading new rules]]. -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 01:39, 31 December 2014 (UTC)<br />
<br />
:: May be it must be removed "This article or section is a candidate for merging with udev."? I have added more related info to gvfs-mtp but not related to udev, I think that it is good if will stay here as it is. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:28, 17 August 2016 (UTC)).<br />
<br />
::I am not sure about two probably similar [[udev]] rules [[MTP#Media_players]] and [[MTP#gvfs-mtp]], may be to have only one is enough and merge both?(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 22:58, 19 August 2016 (UTC)) <br />
:: EDIT: <br />
:: I will try to merge them after few days, I hope it is OK. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 21:24, 20 August 2016 (UTC))<br />
<br />
:: This is what I mean about merging Media players and gvfs-mtp sections and udev rules:<br />
ATTR{idVendor}=="04b7", ATTR{idProduct}=="88a9", SYMLINK+="libmtp", MODE="660", ENV{ID_MTP_DEVICE}="1"<br />
+<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04b7", ATTR{idProduct}=="88a9", MODE="0666", OWNER="[username]"<br />
=<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04b7", ATTR{idProduct}=="88a9", MODE="0660", GROUP="uucp", ENV{ID_MTP_DEVICE}="1", SYMLINK+="libmtp"<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:42, 21 August 2016 (UTC)).</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Talk:Media_Transfer_Protocol&diff=447237Talk:Media Transfer Protocol2016-08-21T19:44:45Z<p>Andy Crowd: added example of Udev rule that I want to use when merging Media players with gvfs-mtp section. Do you have any more suggestions?</p>
<hr />
<div>== Custom udev rules and rebooting ==<br />
<br />
In a couple of places {{ic|/usr/lib/udev/rules.d/}} is used as location for custom {{ic|udev}} rules. Isn't the {{ic|/etc/udev/rules.d/}} a better place for them? If so I propose to change {{ic|/usr/lib/udev/rules.d/}} to {{ic|/etc/udev/rules.d/}}.<br />
<br />
Also, there's no need for rebooting the system, as suggested in [[MTP#gvfs-mtp troubleshooting]]. What is that? A Windows? ;} I think this should be removed or changed to some other means like “relogging”.<br />
<br />
--thebodzio 22:34, 29 December 2014 (UTC)<br />
<br />
:Yes to both, [[Udev#About udev rules]] and [[Udev#Loading new rules]]. -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 01:39, 31 December 2014 (UTC)<br />
<br />
:: May be it must be removed "This article or section is a candidate for merging with udev."? I have added more related info to gvfs-mtp but not related to udev, I think that it is good if will stay here as it is. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:28, 17 August 2016 (UTC)).<br />
<br />
::I am not sure about two probably similar [[udev]] rules [[MTP#Media_players]] and [[MTP#gvfs-mtp]], may be to have only one is enough and merge both?(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 22:58, 19 August 2016 (UTC)) <br />
:: EDIT: <br />
:: I will try to merge them after few days, I hope it is OK. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 21:24, 20 August 2016 (UTC))<br />
<br />
:: This is what I mean about merging Media players and gvfs-mtp sections and udev rules:<br />
ATTR{idVendor}=="04b7", ATTR{idProduct}=="88a9", SYMLINK+="libmtp", MODE="660", ENV{ID_MTP_DEVICE}="1"<br />
+<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04b7", ATTR{idProduct}=="88a9", MODE="0666", OWNER="[username]"<br />
=<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04b7", ATTR{idProduct}=="88a9", MODE="0660", GROUP="uucp", ENV{ID_MTP_DEVICE}="1"<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:42, 21 August 2016 (UTC)).</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Media_Transfer_Protocol&diff=447192Media Transfer Protocol2016-08-21T09:54:56Z<p>Andy Crowd: /* gvfs-mtp */ style fix and update that same ID numbers for the phone are used</p>
<hr />
<div>[[Category:Storage]]<br />
[[Category:Mobile devices]]<br />
[[fa:MTP]]<br />
[[ja:MTP]]<br />
[[ru:MTP]]<br />
[[zh-CN:MTP]]<br />
{{Related articles start}}<br />
{{Related|USB storage devices}}<br />
{{Related articles end}}<br />
[[Wikipedia:Media_Transfer_Protocol|MTP]], or the ''Media Transfer Protocol'', is a USB device class which is used by many mobile phones (e.g. Samsung Galaxy S4) and media players (e.g. Creative Zen).<br />
<br />
== Installation ==<br />
<br />
=== Functionality ===<br />
<br />
Linux MTP support is provided by [[installing]] the {{Pkg|libmtp}} package. It can be installed on its own and used to access devices. However, a number of packages are available that use it as a dependency and add additional convenience (e.g. filemanager) functionalities and compatibility with particular device types - which includes improving transfer access speeds. <br />
<br />
These packages to choose from all implement a [[Wikipedia:Filesystem in Userspace]]: <br />
<br />
* {{Pkg|mtpfs}}<br />
* {{AUR|jmtpfs}} - is reported to work well for newer Android 4+ devices <br />
* {{AUR|go-mtpfs-git}} - is reported to work well for newer Android 3+ devices <br />
* {{AUR|simple-mtpfs}}<br />
* {{Pkg|android-file-transfer}} - MTP client with minimalistic UI<br />
<br />
All of them aim at better functionality and performance over {{ic|libmtp}}. Since there are a lot of different USB devices, you might want to research first which one looks most suitable for yours. <br />
<br />
{{Tip|It is recommended to reboot your computer after installing MTP related packages.}}<br />
<br />
=== Integration with file managers ===<br />
<br />
To view the contents of your Android device's storage via MTP in your file manager, install the corresponding plugin:<br />
<br />
* For file managers that use [[GVFS]] (GNOME Files), install {{Pkg|gvfs-mtp}} for MTP or {{Pkg|gvfs-gphoto2}} for PTP support.<br />
* For file managers that use KIO (KDE's Dolphin), MTP support is included in {{Pkg|kio-extras}} (dependency of dolphin).<br />
<br />
After installing the required package, the device should show up in the file manager automatically and be accessible via an URL, for example {{ic|mtp://[usb:002,013]/}}.<br />
<br />
== Usage ==<br />
<br />
It might be required to create a mount-point directory first. The directory {{ic|~/mnt}} is used as an example below. Also do not forget to unlock your phone's screen before connecting it to the computer.<br />
<br />
=== libmtp ===<br />
<br />
Detect your device:<br />
<br />
# mtp-detect<br />
<br />
If an error is returned, see [[#libmtp 2|troubleshooting libmtp]]. <br />
<br />
{{Note|Your regular user must be in the {{ic|uucp}} [[users_and_groups#Example_adding_a_user|group]].}}<br />
<br />
Connect to your device:<br />
# mtp-connect<br />
<br />
If connection is successful, there are several switch options to use in conjunction with ''mtp-connect'' to access data on the device. You might want to use some stand alone commands:<br />
mtp-albumart mtp-emptyfolders mtp-getplaylist mtp-reset mtp-trexist<br />
mtp-albums mtp-files mtp-hotplug mtp-sendfile<br />
mtp-connect mtp-folders mtp-newfolder mtp-sendtr<br />
mtp-delfile mtp-format mtp-newplaylist mtp-thumb<br />
mtp-detect mtp-getfile mtp-playlists mtp-tracks<br />
<br />
=== mtpfs ===<br />
<br />
{{Note | The following is likely to not work and you might have to resort to [[Digital_Cameras#libgphoto2|gphoto2]] or a file manager with gvfs support like [[PCManFM]]. }}<br />
<br />
First edit your {{ic|/etc/fuse.conf}} and uncomment the following line:<br />
user_allow_other<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
$ mtpfs -o allow_other ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== jmtpfs ===<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ jmtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
Make this cohere to the rest of Linux (use regular mount/umount commands) by doing two steps<br />
<br />
$# ln -s <actual mount command's path/name> <a name consistent with Linux's mount convention><br />
$ ln -s /sbin/jmtpfs /sbin/mount.jmtpfs<br />
<br />
add this line to /etc/fstab; <br />
<br />
#jmtpfs <mount path> fuse nodev,allow_other,<other options> 0 0<br />
jmtpfs /home/sam/run/motog fuse nodev,allow_other,rw,user,noauto,noatime,uid=1000,gid=1000 0 0<br />
<br />
Now mount the device and see if the options "took"<br />
<br />
$ mount /home/sam/run/motog<br />
Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).<br />
Android device detected, assigning default bug flags<br />
$ mount <br />
...<br />
jmtpfs on /home/sam/run/motog type fuse.jmtpfs (rw,nosuid,nodev,noexec,noatime,user_id=1000,group_id=1000,allow_other,user=sam)<br />
<br />
=== go-mtpfs ===<br />
<br />
{{Note|Mounting with {{ic|go-mtpfs}} might fail if an external SD Card is present. If you try to access your device while having an SD card and go-mtpfs complains, try removing the SD card and mounting again.}}<br />
<br />
Install {{Pkg|android-udev}}, which will allow you to edit {{ic|/etc/udev/rules.d/51-android.rules}} and apply to your {{ic|idVendor}} and {{ic|idProduct}}, which you can see after running ''mtp-detect''. To the end of the line, add your user {{ic|<nowiki>OWNER="<user>"</nowiki>}}.<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ go-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== simple-mtpfs ===<br />
<br />
List MTP devices:<br />
<br />
$ simple-mtpfs --list-devices<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
<br />
$ simple-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== Android File Transfer ===<br />
<br />
;FUSE interface<br />
<br />
Mount your device on {{ic|~/my-device}}:<br />
$ mkdir ~/my-device<br />
$ aft-mtp-mount ~/my-device<br />
<br />
If you want album art to be displayed, it must be named {{ic|albumart.xxx}} and placed first in the destination folder. Then copy other files. Also, note that fuse could be 7-8 times slower than ui/cli file transfer.<br />
<br />
Unmount device mounted on {{ic|~/my-device}}:<br />
<br />
$ fusermount -u ~/my-device<br />
<br />
;Qt user interface<br />
<br />
Start the application, choose a destination folder and click any button on the toolbar. Available options are: ''Upload Album'', ''Upload Directory'' and ''Upload Files''. The latter two are self-explanatory. ''Upload album'' searches the source directory for album covers, and sets the best available cover.<br />
<br />
=== Media players ===<br />
<br />
You can also use your MTP device in music players such as Amarok. To achieve this, you might have to edit {{ic|/etc/udev/rules.d/51-android.rules}} (the MTP device used in the following example is a Galaxy Nexus). <br />
Run:<br />
<br />
$ lsusb<br />
<br />
Search for your device. It should be something like that:<br />
Bus 003 Device 011: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-P7500 [Galaxy Tab 10.1]<br />
<br />
And entry to {{ic|/etc/udev/rules.d/51-android.rules}} will be this:<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="[username]"<br />
<br />
Also reload udev rules:<br />
# udevadm control --reload<br />
<br />
=== gvfs-mtp ===<br />
<br />
{{Merge|udev}}<br />
<br />
The {{Pkg|gvfs-mtp}} is available in the official repositories.<br />
<br />
With {{ic|lsusb}} you can get information about your device where Bus and Device numbers can be used with {{ic|gvfs-mtp}} and device ID for creating of an [[udev]] rule.<br />
Bus '''002''' Device '''018''': ID '''04b7''':'''88a9''' Compal Electronics, Inc.<br />
(...)<br />
<br />
To see detected device with enabled MTP<br />
<br />
Use ''gvfs-mount'':<br />
<br />
{{hc|<NOWIKI>gvfs-mount -li | grep -e ^Volume -e activation_root</NOWIKI>|2=<br />
Volume(0): MT65xx Android Phone<br />
activation_root=mtp://[usb:'''002''','''018''']/<br />
}}<br />
<br />
Use ''lsusb'':<br />
<br />
{{hc|<NOWIKI>lsusb -v 2> /dev/null | grep -e Bus -e iInterface -e bInterfaceProtocol</NOWIKI>|<br />
(......<br />
......)<br />
Bus 002 Device 018: ID 04b7:88a9 Compal Electronics, Inc. <br />
bInterfaceProtocol 0 <br />
iInterface 5 MTP<br />
(......<br />
......)<br />
}}<br />
<br />
To mount all available connected MTP devices use inline script<br />
<br />
gvfs-mount -li | awk -F= '{if(index($2,"mtp") == 1)system("gvfs-mount "$2)}'<br />
<br />
To mount or dismount from a command with gvfs-mtp use Bus and Device numbers, e.g. to mount {{ic|gvfs-mount mtp://[usb:001,007]/}} and to unmount {{ic|gvfs-mount -u mtp://[usb:001,007]/}}. The mounted device will be available in a directory that begins with ''mtp:host='' and is located under ''/run/user/$UID/gvfs/''.<br />
<br />
Disable automount of MTP devises with gvfs you will need to change value ''true'' to ''false'' for variable ''AutoMount'' that is located in {{ic|/usr/share/gvfs/mounts/mtp.mount}}.<br />
<br />
{{Note|The file managers can have own options for automount. On start they checking for all available mountable devices.}}<br />
<br />
If your device isn't showing up in the file manager then the {{Pkg|libmtp}} is missing a native support and is not currently available in the list of the [https://sourceforge.net/p/libmtp/code/ci/HEAD/tree/src/music-players.h supported devices]. If you will try to mount by using command line you may also get an error<br />
<br />
{{bc|1=Device 0 (VID=''XXXX'' and PID=''XXXX'') is UNKNOWN.<br />
Please report this VID/PID and the device model to the libmtp development team}}<br />
<br />
The workaround to make it shown in the file manager is to write an [[udev]] rule for the device but it is no guaranty that you will be able to mount it with by using MTP connection.<br />
<br />
Use ID number that represents by pattern '''vendorId''':'''productID''',e.g. '''04b7''':'''88a9''', and make an udev rule by creating a configuration file<br />
<br />
{{hc|/etc/udev/rules.d/51-android.rules|<NOWIKI><br />
ATTR{idVendor}=="</NOWIKI>'''04b7'''<NOWIKI>", ATTR{idProduct}=="</NOWIKI>'''88a9'''<NOWIKI>", SYMLINK+="libmtp", MODE="660", ENV{ID_MTP_DEVICE}="1"</NOWIKI><br />
}}<br />
Reload the udev rules.<br />
<br />
# udevadm control --reload<br />
<br />
The file managers with support for [[gvfs]] will be able to show MTP devices and mount them if supported by {{Pkg|libmtp}} but if has no support and cannot be opened then change settings in the phone to PTP and install {{Pkg|gvfs-gphoto2}} for having access at least to the photos, command line mounting of PTP is a little similar to mounting of the MTP devices: {{ic|gvfs-mount gphoto2://[usb:002,019]/}}.<br />
<br />
{{Note|If you getting limited access to the device and cannot use standard commands from command line such as e.g. {{ic|cp}},{{ic|ls}} then look for [[gvfs]] own alternatives, {{ic|ls -1 /usr/bin/gvfs-*}}.}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== libmtp ===<br />
<br />
==== Unable to enumerate USB device ====<br />
{{Deletion|This should be an old kernel bug, and should have been fixed already. There is no bug report to confirm though.}}<br />
{{Merge||Unrelated to MTP, perhaps suited for [[USB storage devices]]}}<br />
<br />
If you see a message like this in system log ({{ic|journalctl}})<br />
<br />
usb usb4-port2: unable to enumerate USB device<br />
<br />
You can try following temporary [https://bbs.archlinux.org/viewtopic.php?pid=1087323#p1087323 workaround]<br />
<br />
# modprobe -vr uhci_hcd<br />
# modprobe -va ohci_hcd<br />
# modprobe -va uhci_hcd<br />
<br />
If it works you should create {{ic|/etc/modprobe.d/usb_hci_order.conf}} with following content<br />
<br />
# create a dependency on ohci for uhci, which fixes problems<br />
# with external usb devices not showing up<br />
#<br />
softdep uhci_hcd pre: ohci_hcd<br />
<br />
=== jmtpfs ===<br />
<br />
==== Input/output error upon first access ====<br />
<br />
Symptoms: jmtpfs successfully mounts, but as soon as one attempts to access files on the device (e.g. via {{ic|ls}}), an error is reported:<br />
<br />
cannot access <mount-point>: Input/output error<br />
<br />
This appears to be a security feature: MTP does not work when the phone is locked by the lockscreen. Unlock the phone and it should work again as long as the cord remains connected.<br />
<br />
=== kio-mtp ===<br />
<br />
If you are not able to use the action "Open with File Manager", you may work around this problem by editing the file {{ic|/usr/share/apps/solid/actions/solid_mtp.desktop}}.<br />
<br />
Change the line<br />
<br />
Exec=kioclient exec mtp:udi=%i/<br />
<br />
To<br />
<br />
Exec=dolphin "mtp:/"</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Talk:Media_Transfer_Protocol&diff=447164Talk:Media Transfer Protocol2016-08-20T21:27:15Z<p>Andy Crowd: /* Custom udev rules and rebooting */ EDIT: I will try to merge them after few days, good to make them look better as one part.</p>
<hr />
<div>== Custom udev rules and rebooting ==<br />
<br />
In a couple of places {{ic|/usr/lib/udev/rules.d/}} is used as location for custom {{ic|udev}} rules. Isn't the {{ic|/etc/udev/rules.d/}} a better place for them? If so I propose to change {{ic|/usr/lib/udev/rules.d/}} to {{ic|/etc/udev/rules.d/}}.<br />
<br />
Also, there's no need for rebooting the system, as suggested in [[MTP#gvfs-mtp troubleshooting]]. What is that? A Windows? ;} I think this should be removed or changed to some other means like “relogging”.<br />
<br />
--thebodzio 22:34, 29 December 2014 (UTC)<br />
<br />
:Yes to both, [[Udev#About udev rules]] and [[Udev#Loading new rules]]. -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 01:39, 31 December 2014 (UTC)<br />
<br />
:: May be it must be removed "This article or section is a candidate for merging with udev."? I have added more related info to gvfs-mtp but not related to udev, I think that it is good if will stay here as it is. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:28, 17 August 2016 (UTC)).<br />
<br />
::I am not sure about two probably similar [[udev]] rules [[MTP#Media_players]] and [[MTP#gvfs-mtp]], may be to have only one is enough and merge both?(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 22:58, 19 August 2016 (UTC)) <br />
:: EDIT: <br />
:: I will try to merge them after few days, I hope it is OK. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 21:24, 20 August 2016 (UTC))</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Media_Transfer_Protocol&diff=447163Media Transfer Protocol2016-08-20T21:02:48Z<p>Andy Crowd: /* Unknown device */ removed section "Unknown device" because it is now in the section gvfs-mtp</p>
<hr />
<div>[[Category:Storage]]<br />
[[Category:Mobile devices]]<br />
[[fa:MTP]]<br />
[[ja:MTP]]<br />
[[ru:MTP]]<br />
[[zh-CN:MTP]]<br />
{{Related articles start}}<br />
{{Related|USB storage devices}}<br />
{{Related articles end}}<br />
[[Wikipedia:Media_Transfer_Protocol|MTP]], or the ''Media Transfer Protocol'', is a USB device class which is used by many mobile phones (e.g. Samsung Galaxy S4) and media players (e.g. Creative Zen).<br />
<br />
== Installation ==<br />
<br />
=== Functionality ===<br />
<br />
Linux MTP support is provided by [[installing]] the {{Pkg|libmtp}} package. It can be installed on its own and used to access devices. However, a number of packages are available that use it as a dependency and add additional convenience (e.g. filemanager) functionalities and compatibility with particular device types - which includes improving transfer access speeds. <br />
<br />
These packages to choose from all implement a [[Wikipedia:Filesystem in Userspace]]: <br />
<br />
* {{Pkg|mtpfs}}<br />
* {{AUR|jmtpfs}} - is reported to work well for newer Android 4+ devices <br />
* {{AUR|go-mtpfs-git}} - is reported to work well for newer Android 3+ devices <br />
* {{AUR|simple-mtpfs}}<br />
* {{Pkg|android-file-transfer}} - MTP client with minimalistic UI<br />
<br />
All of them aim at better functionality and performance over {{ic|libmtp}}. Since there are a lot of different USB devices, you might want to research first which one looks most suitable for yours. <br />
<br />
{{Tip|It is recommended to reboot your computer after installing MTP related packages.}}<br />
<br />
=== Integration with file managers ===<br />
<br />
To view the contents of your Android device's storage via MTP in your file manager, install the corresponding plugin:<br />
<br />
* For file managers that use [[GVFS]] (GNOME Files), install {{Pkg|gvfs-mtp}} for MTP or {{Pkg|gvfs-gphoto2}} for PTP support.<br />
* For file managers that use KIO (KDE's Dolphin), MTP support is included in {{Pkg|kio-extras}} (dependency of dolphin).<br />
<br />
After installing the required package, the device should show up in the file manager automatically and be accessible via an URL, for example {{ic|mtp://[usb:002,013]/}}.<br />
<br />
== Usage ==<br />
<br />
It might be required to create a mount-point directory first. The directory {{ic|~/mnt}} is used as an example below. Also do not forget to unlock your phone's screen before connecting it to the computer.<br />
<br />
=== libmtp ===<br />
<br />
Detect your device:<br />
<br />
# mtp-detect<br />
<br />
If an error is returned, see [[#libmtp 2|troubleshooting libmtp]]. <br />
<br />
{{Note|Your regular user must be in the {{ic|uucp}} [[users_and_groups#Example_adding_a_user|group]].}}<br />
<br />
Connect to your device:<br />
# mtp-connect<br />
<br />
If connection is successful, there are several switch options to use in conjunction with ''mtp-connect'' to access data on the device. You might want to use some stand alone commands:<br />
mtp-albumart mtp-emptyfolders mtp-getplaylist mtp-reset mtp-trexist<br />
mtp-albums mtp-files mtp-hotplug mtp-sendfile<br />
mtp-connect mtp-folders mtp-newfolder mtp-sendtr<br />
mtp-delfile mtp-format mtp-newplaylist mtp-thumb<br />
mtp-detect mtp-getfile mtp-playlists mtp-tracks<br />
<br />
=== mtpfs ===<br />
<br />
{{Note | The following is likely to not work and you might have to resort to [[Digital_Cameras#libgphoto2|gphoto2]] or a file manager with gvfs support like [[PCManFM]]. }}<br />
<br />
First edit your {{ic|/etc/fuse.conf}} and uncomment the following line:<br />
user_allow_other<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
$ mtpfs -o allow_other ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== jmtpfs ===<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ jmtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
Make this cohere to the rest of Linux (use regular mount/umount commands) by doing two steps<br />
<br />
$# ln -s <actual mount command's path/name> <a name consistent with Linux's mount convention><br />
$ ln -s /sbin/jmtpfs /sbin/mount.jmtpfs<br />
<br />
add this line to /etc/fstab; <br />
<br />
#jmtpfs <mount path> fuse nodev,allow_other,<other options> 0 0<br />
jmtpfs /home/sam/run/motog fuse nodev,allow_other,rw,user,noauto,noatime,uid=1000,gid=1000 0 0<br />
<br />
Now mount the device and see if the options "took"<br />
<br />
$ mount /home/sam/run/motog<br />
Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).<br />
Android device detected, assigning default bug flags<br />
$ mount <br />
...<br />
jmtpfs on /home/sam/run/motog type fuse.jmtpfs (rw,nosuid,nodev,noexec,noatime,user_id=1000,group_id=1000,allow_other,user=sam)<br />
<br />
=== go-mtpfs ===<br />
<br />
{{Note|Mounting with {{ic|go-mtpfs}} might fail if an external SD Card is present. If you try to access your device while having an SD card and go-mtpfs complains, try removing the SD card and mounting again.}}<br />
<br />
Install {{Pkg|android-udev}}, which will allow you to edit {{ic|/etc/udev/rules.d/51-android.rules}} and apply to your {{ic|idVendor}} and {{ic|idProduct}}, which you can see after running ''mtp-detect''. To the end of the line, add your user {{ic|<nowiki>OWNER="<user>"</nowiki>}}.<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ go-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== simple-mtpfs ===<br />
<br />
List MTP devices:<br />
<br />
$ simple-mtpfs --list-devices<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
<br />
$ simple-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== Android File Transfer ===<br />
<br />
;FUSE interface<br />
<br />
Mount your device on {{ic|~/my-device}}:<br />
$ mkdir ~/my-device<br />
$ aft-mtp-mount ~/my-device<br />
<br />
If you want album art to be displayed, it must be named {{ic|albumart.xxx}} and placed first in the destination folder. Then copy other files. Also, note that fuse could be 7-8 times slower than ui/cli file transfer.<br />
<br />
Unmount device mounted on {{ic|~/my-device}}:<br />
<br />
$ fusermount -u ~/my-device<br />
<br />
;Qt user interface<br />
<br />
Start the application, choose a destination folder and click any button on the toolbar. Available options are: ''Upload Album'', ''Upload Directory'' and ''Upload Files''. The latter two are self-explanatory. ''Upload album'' searches the source directory for album covers, and sets the best available cover.<br />
<br />
=== Media players ===<br />
<br />
You can also use your MTP device in music players such as Amarok. To achieve this, you might have to edit {{ic|/etc/udev/rules.d/51-android.rules}} (the MTP device used in the following example is a Galaxy Nexus). <br />
Run:<br />
<br />
$ lsusb<br />
<br />
Search for your device. It should be something like that:<br />
Bus 003 Device 011: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-P7500 [Galaxy Tab 10.1]<br />
<br />
And entry to {{ic|/etc/udev/rules.d/51-android.rules}} will be this:<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="[username]"<br />
<br />
Also reload udev rules:<br />
# udevadm control --reload<br />
<br />
=== gvfs-mtp ===<br />
<br />
{{Merge|udev}}<br />
<br />
The {{Pkg|gvfs-mtp}} is available in the official repositories.<br />
<br />
With {{ic|lsusb}} you can get information about your device where Bus and Device numbers can be used with {{ic|gvfs-mtp}} and device ID for creating of an [[udev]] rule.<br />
Bus '''001''' Device '''007''': ID '''0421:0661''' Nokia Mobile Phones Lumia 920<br />
(...)<br />
<br />
To see detected device with enabled MTP<br />
<br />
Use ''gvfs-mount'':<br />
<br />
{{hc|<NOWIKI>gvfs-mount -li | grep -e ^Volume -e activation_root</NOWIKI>|2=<br />
Volume(0): MT65xx Android Phone<br />
activation_root=mtp://[usb:002,018]/<br />
}}<br />
<br />
Use ''lsusb'':<br />
<br />
{{hc|<NOWIKI>lsusb -v 2> /dev/null | grep -e Bus -e iInterface -e bInterfaceProtocol</NOWIKI>|<br />
(......<br />
......)<br />
Bus 002 Device 018: ID 04b7:88a9 Compal Electronics, Inc. <br />
bInterfaceProtocol 0 <br />
iInterface 5 MTP<br />
(......<br />
......)<br />
}}<br />
<br />
To mount all available connected MTP devices use inline script<br />
<br />
gvfs-mount -li | awk -F= '{if(index($2,"mtp") == 1)system("gvfs-mount "$2)}'<br />
<br />
To mount or dismount from a command with gvfs-mtp use Bus and Device numbers, e.g. to mount {{ic|gvfs-mount mtp://[usb:001,007]/}} and to unmount {{ic|gvfs-mount -u mtp://[usb:001,007]/}}. The mounted device will be available in a directory that begins with ''mtp:host='' and is located under ''/run/user/$UID/gvfs/''.<br />
<br />
Disable automount of MTP devises with gvfs you will need to change value ''true'' to ''false'' for variable ''AutoMount'' that is located in {{ic|/usr/share/gvfs/mounts/mtp.mount}}.<br />
<br />
{{Note|The file managers can have own options for automount. On start they checking for all available mountable devices.}}<br />
<br />
If your device isn't showing up in the file manager then the {{Pkg|libmtp}} is missing a native support and is not currently available in the list of the [https://sourceforge.net/p/libmtp/code/ci/HEAD/tree/src/music-players.h supported devices]. If you will try to mount by using command line you may also get an error<br />
<br />
{{bc|1=Device 0 (VID=''XXXX'' and PID=''XXXX'') is UNKNOWN.<br />
Please report this VID/PID and the device model to the libmtp development team}}<br />
<br />
The workaround to make it shown in the file manager is to write an [[udev]] rule for the device but it is no guaranty that you will be able to mount it with by using MTP connection.<br />
<br />
Use ID number that represents by pattern ''vendorId'':''productID'',e.g. ''0421'':''0661'', and make an udev rule by creating a configuration file<br />
<br />
{{hc|/etc/udev/rules.d/51-android.rules|<NOWIKI><br />
ATTR{idVendor}=="0421", ATTR{idProduct}=="0661", SYMLINK+="libmtp", MODE="660", ENV{ID_MTP_DEVICE}="1"<br />
</NOWIKI>}}<br />
Reload the udev rules.<br />
<br />
# udevadm control --reload<br />
<br />
The file managers with support for [[gvfs]] will be able to show MTP devices and mount them if supported by {{Pkg|libmtp}} but if has no support and cannot be opened then change settings in the phone to PTP and install {{Pkg|gvfs-gphoto2}} for having access at least to the photos, command line mounting of PTP is a little similar to mounting of the MTP devices: {{ic|gvfs-mount gphoto2://[usb:002,019]/}}.<br />
<br />
{{Note|If you getting limited access to the device and cannot use standard commands from command line such as e.g. {{ic|cp}},{{ic|ls}} then look for [[gvfs]] own alternatives, {{ic|ls -1 /usr/bin/gvfs-*}}.}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== libmtp ===<br />
<br />
==== Unable to enumerate USB device ====<br />
{{Deletion|This should be an old kernel bug, and should have been fixed already. There is no bug report to confirm though.}}<br />
{{Merge||Unrelated to MTP, perhaps suited for [[USB storage devices]]}}<br />
<br />
If you see a message like this in system log ({{ic|journalctl}})<br />
<br />
usb usb4-port2: unable to enumerate USB device<br />
<br />
You can try following temporary [https://bbs.archlinux.org/viewtopic.php?pid=1087323#p1087323 workaround]<br />
<br />
# modprobe -vr uhci_hcd<br />
# modprobe -va ohci_hcd<br />
# modprobe -va uhci_hcd<br />
<br />
If it works you should create {{ic|/etc/modprobe.d/usb_hci_order.conf}} with following content<br />
<br />
# create a dependency on ohci for uhci, which fixes problems<br />
# with external usb devices not showing up<br />
#<br />
softdep uhci_hcd pre: ohci_hcd<br />
<br />
=== jmtpfs ===<br />
<br />
==== Input/output error upon first access ====<br />
<br />
Symptoms: jmtpfs successfully mounts, but as soon as one attempts to access files on the device (e.g. via {{ic|ls}}), an error is reported:<br />
<br />
cannot access <mount-point>: Input/output error<br />
<br />
This appears to be a security feature: MTP does not work when the phone is locked by the lockscreen. Unlock the phone and it should work again as long as the cord remains connected.<br />
<br />
=== kio-mtp ===<br />
<br />
If you are not able to use the action "Open with File Manager", you may work around this problem by editing the file {{ic|/usr/share/apps/solid/actions/solid_mtp.desktop}}.<br />
<br />
Change the line<br />
<br />
Exec=kioclient exec mtp:udi=%i/<br />
<br />
To<br />
<br />
Exec=dolphin "mtp:/"</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Media_Transfer_Protocol&diff=447162Media Transfer Protocol2016-08-20T21:00:39Z<p>Andy Crowd: /* gvfs-mtp */ copied example from libmtp troubleshooting to make it look more logical</p>
<hr />
<div>[[Category:Storage]]<br />
[[Category:Mobile devices]]<br />
[[fa:MTP]]<br />
[[ja:MTP]]<br />
[[ru:MTP]]<br />
[[zh-CN:MTP]]<br />
{{Related articles start}}<br />
{{Related|USB storage devices}}<br />
{{Related articles end}}<br />
[[Wikipedia:Media_Transfer_Protocol|MTP]], or the ''Media Transfer Protocol'', is a USB device class which is used by many mobile phones (e.g. Samsung Galaxy S4) and media players (e.g. Creative Zen).<br />
<br />
== Installation ==<br />
<br />
=== Functionality ===<br />
<br />
Linux MTP support is provided by [[installing]] the {{Pkg|libmtp}} package. It can be installed on its own and used to access devices. However, a number of packages are available that use it as a dependency and add additional convenience (e.g. filemanager) functionalities and compatibility with particular device types - which includes improving transfer access speeds. <br />
<br />
These packages to choose from all implement a [[Wikipedia:Filesystem in Userspace]]: <br />
<br />
* {{Pkg|mtpfs}}<br />
* {{AUR|jmtpfs}} - is reported to work well for newer Android 4+ devices <br />
* {{AUR|go-mtpfs-git}} - is reported to work well for newer Android 3+ devices <br />
* {{AUR|simple-mtpfs}}<br />
* {{Pkg|android-file-transfer}} - MTP client with minimalistic UI<br />
<br />
All of them aim at better functionality and performance over {{ic|libmtp}}. Since there are a lot of different USB devices, you might want to research first which one looks most suitable for yours. <br />
<br />
{{Tip|It is recommended to reboot your computer after installing MTP related packages.}}<br />
<br />
=== Integration with file managers ===<br />
<br />
To view the contents of your Android device's storage via MTP in your file manager, install the corresponding plugin:<br />
<br />
* For file managers that use [[GVFS]] (GNOME Files), install {{Pkg|gvfs-mtp}} for MTP or {{Pkg|gvfs-gphoto2}} for PTP support.<br />
* For file managers that use KIO (KDE's Dolphin), MTP support is included in {{Pkg|kio-extras}} (dependency of dolphin).<br />
<br />
After installing the required package, the device should show up in the file manager automatically and be accessible via an URL, for example {{ic|mtp://[usb:002,013]/}}.<br />
<br />
== Usage ==<br />
<br />
It might be required to create a mount-point directory first. The directory {{ic|~/mnt}} is used as an example below. Also do not forget to unlock your phone's screen before connecting it to the computer.<br />
<br />
=== libmtp ===<br />
<br />
Detect your device:<br />
<br />
# mtp-detect<br />
<br />
If an error is returned, see [[#libmtp 2|troubleshooting libmtp]]. <br />
<br />
{{Note|Your regular user must be in the {{ic|uucp}} [[users_and_groups#Example_adding_a_user|group]].}}<br />
<br />
Connect to your device:<br />
# mtp-connect<br />
<br />
If connection is successful, there are several switch options to use in conjunction with ''mtp-connect'' to access data on the device. You might want to use some stand alone commands:<br />
mtp-albumart mtp-emptyfolders mtp-getplaylist mtp-reset mtp-trexist<br />
mtp-albums mtp-files mtp-hotplug mtp-sendfile<br />
mtp-connect mtp-folders mtp-newfolder mtp-sendtr<br />
mtp-delfile mtp-format mtp-newplaylist mtp-thumb<br />
mtp-detect mtp-getfile mtp-playlists mtp-tracks<br />
<br />
=== mtpfs ===<br />
<br />
{{Note | The following is likely to not work and you might have to resort to [[Digital_Cameras#libgphoto2|gphoto2]] or a file manager with gvfs support like [[PCManFM]]. }}<br />
<br />
First edit your {{ic|/etc/fuse.conf}} and uncomment the following line:<br />
user_allow_other<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
$ mtpfs -o allow_other ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== jmtpfs ===<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ jmtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
Make this cohere to the rest of Linux (use regular mount/umount commands) by doing two steps<br />
<br />
$# ln -s <actual mount command's path/name> <a name consistent with Linux's mount convention><br />
$ ln -s /sbin/jmtpfs /sbin/mount.jmtpfs<br />
<br />
add this line to /etc/fstab; <br />
<br />
#jmtpfs <mount path> fuse nodev,allow_other,<other options> 0 0<br />
jmtpfs /home/sam/run/motog fuse nodev,allow_other,rw,user,noauto,noatime,uid=1000,gid=1000 0 0<br />
<br />
Now mount the device and see if the options "took"<br />
<br />
$ mount /home/sam/run/motog<br />
Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).<br />
Android device detected, assigning default bug flags<br />
$ mount <br />
...<br />
jmtpfs on /home/sam/run/motog type fuse.jmtpfs (rw,nosuid,nodev,noexec,noatime,user_id=1000,group_id=1000,allow_other,user=sam)<br />
<br />
=== go-mtpfs ===<br />
<br />
{{Note|Mounting with {{ic|go-mtpfs}} might fail if an external SD Card is present. If you try to access your device while having an SD card and go-mtpfs complains, try removing the SD card and mounting again.}}<br />
<br />
Install {{Pkg|android-udev}}, which will allow you to edit {{ic|/etc/udev/rules.d/51-android.rules}} and apply to your {{ic|idVendor}} and {{ic|idProduct}}, which you can see after running ''mtp-detect''. To the end of the line, add your user {{ic|<nowiki>OWNER="<user>"</nowiki>}}.<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ go-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== simple-mtpfs ===<br />
<br />
List MTP devices:<br />
<br />
$ simple-mtpfs --list-devices<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
<br />
$ simple-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== Android File Transfer ===<br />
<br />
;FUSE interface<br />
<br />
Mount your device on {{ic|~/my-device}}:<br />
$ mkdir ~/my-device<br />
$ aft-mtp-mount ~/my-device<br />
<br />
If you want album art to be displayed, it must be named {{ic|albumart.xxx}} and placed first in the destination folder. Then copy other files. Also, note that fuse could be 7-8 times slower than ui/cli file transfer.<br />
<br />
Unmount device mounted on {{ic|~/my-device}}:<br />
<br />
$ fusermount -u ~/my-device<br />
<br />
;Qt user interface<br />
<br />
Start the application, choose a destination folder and click any button on the toolbar. Available options are: ''Upload Album'', ''Upload Directory'' and ''Upload Files''. The latter two are self-explanatory. ''Upload album'' searches the source directory for album covers, and sets the best available cover.<br />
<br />
=== Media players ===<br />
<br />
You can also use your MTP device in music players such as Amarok. To achieve this, you might have to edit {{ic|/etc/udev/rules.d/51-android.rules}} (the MTP device used in the following example is a Galaxy Nexus). <br />
Run:<br />
<br />
$ lsusb<br />
<br />
Search for your device. It should be something like that:<br />
Bus 003 Device 011: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-P7500 [Galaxy Tab 10.1]<br />
<br />
And entry to {{ic|/etc/udev/rules.d/51-android.rules}} will be this:<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="[username]"<br />
<br />
Also reload udev rules:<br />
# udevadm control --reload<br />
<br />
=== gvfs-mtp ===<br />
<br />
{{Merge|udev}}<br />
<br />
The {{Pkg|gvfs-mtp}} is available in the official repositories.<br />
<br />
With {{ic|lsusb}} you can get information about your device where Bus and Device numbers can be used with {{ic|gvfs-mtp}} and device ID for creating of an [[udev]] rule.<br />
Bus '''001''' Device '''007''': ID '''0421:0661''' Nokia Mobile Phones Lumia 920<br />
(...)<br />
<br />
To see detected device with enabled MTP<br />
<br />
Use ''gvfs-mount'':<br />
<br />
{{hc|<NOWIKI>gvfs-mount -li | grep -e ^Volume -e activation_root</NOWIKI>|2=<br />
Volume(0): MT65xx Android Phone<br />
activation_root=mtp://[usb:002,018]/<br />
}}<br />
<br />
Use ''lsusb'':<br />
<br />
{{hc|<NOWIKI>lsusb -v 2> /dev/null | grep -e Bus -e iInterface -e bInterfaceProtocol</NOWIKI>|<br />
(......<br />
......)<br />
Bus 002 Device 018: ID 04b7:88a9 Compal Electronics, Inc. <br />
bInterfaceProtocol 0 <br />
iInterface 5 MTP<br />
(......<br />
......)<br />
}}<br />
<br />
To mount all available connected MTP devices use inline script<br />
<br />
gvfs-mount -li | awk -F= '{if(index($2,"mtp") == 1)system("gvfs-mount "$2)}'<br />
<br />
To mount or dismount from a command with gvfs-mtp use Bus and Device numbers, e.g. to mount {{ic|gvfs-mount mtp://[usb:001,007]/}} and to unmount {{ic|gvfs-mount -u mtp://[usb:001,007]/}}. The mounted device will be available in a directory that begins with ''mtp:host='' and is located under ''/run/user/$UID/gvfs/''.<br />
<br />
Disable automount of MTP devises with gvfs you will need to change value ''true'' to ''false'' for variable ''AutoMount'' that is located in {{ic|/usr/share/gvfs/mounts/mtp.mount}}.<br />
<br />
{{Note|The file managers can have own options for automount. On start they checking for all available mountable devices.}}<br />
<br />
If your device isn't showing up in the file manager then the {{Pkg|libmtp}} is missing a native support and is not currently available in the list of the [https://sourceforge.net/p/libmtp/code/ci/HEAD/tree/src/music-players.h supported devices]. If you will try to mount by using command line you may also get an error<br />
<br />
{{bc|1=Device 0 (VID=''XXXX'' and PID=''XXXX'') is UNKNOWN.<br />
Please report this VID/PID and the device model to the libmtp development team}}<br />
<br />
The workaround to make it shown in the file manager is to write an [[udev]] rule for the device but it is no guaranty that you will be able to mount it with by using MTP connection.<br />
<br />
Use ID number that represents by pattern ''vendorId'':''productID'',e.g. ''0421'':''0661'', and make an udev rule by creating a configuration file<br />
<br />
{{hc|/etc/udev/rules.d/51-android.rules|<NOWIKI><br />
ATTR{idVendor}=="0421", ATTR{idProduct}=="0661", SYMLINK+="libmtp", MODE="660", ENV{ID_MTP_DEVICE}="1"<br />
</NOWIKI>}}<br />
Reload the udev rules.<br />
<br />
# udevadm control --reload<br />
<br />
The file managers with support for [[gvfs]] will be able to show MTP devices and mount them if supported by {{Pkg|libmtp}} but if has no support and cannot be opened then change settings in the phone to PTP and install {{Pkg|gvfs-gphoto2}} for having access at least to the photos, command line mounting of PTP is a little similar to mounting of the MTP devices: {{ic|gvfs-mount gphoto2://[usb:002,019]/}}.<br />
<br />
{{Note|If you getting limited access to the device and cannot use standard commands from command line such as e.g. {{ic|cp}},{{ic|ls}} then look for [[gvfs]] own alternatives, {{ic|ls -1 /usr/bin/gvfs-*}}.}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== libmtp ===<br />
<br />
==== Unknown device ====<br />
<br />
If you see a message like:<br />
<br />
Device 0 (VID=XXXX and PID=XXXX) is UNKNOWN.<br />
Please report this VID/PID and the device model to the libmtp development team<br />
<br />
You should check whether your device is listed in the [http://sourceforge.net/p/libmtp/code/ci/HEAD/tree/src/music-players.h supported devices list]. If it is not, you should report it to the developers team. If it is, your {{ic|libmtp}} might be slightly outdated. To allow it to be properly used by {{ic|libmtp}}, you can add your device to:<br />
<br />
/etc/udev/rules.d/69-libmtp.rules<br />
<br />
==== Unable to enumerate USB device ====<br />
{{Deletion|This should be an old kernel bug, and should have been fixed already. There is no bug report to confirm though.}}<br />
{{Merge||Unrelated to MTP, perhaps suited for [[USB storage devices]]}}<br />
<br />
If you see a message like this in system log ({{ic|journalctl}})<br />
<br />
usb usb4-port2: unable to enumerate USB device<br />
<br />
You can try following temporary [https://bbs.archlinux.org/viewtopic.php?pid=1087323#p1087323 workaround]<br />
<br />
# modprobe -vr uhci_hcd<br />
# modprobe -va ohci_hcd<br />
# modprobe -va uhci_hcd<br />
<br />
If it works you should create {{ic|/etc/modprobe.d/usb_hci_order.conf}} with following content<br />
<br />
# create a dependency on ohci for uhci, which fixes problems<br />
# with external usb devices not showing up<br />
#<br />
softdep uhci_hcd pre: ohci_hcd<br />
<br />
=== jmtpfs ===<br />
<br />
==== Input/output error upon first access ====<br />
<br />
Symptoms: jmtpfs successfully mounts, but as soon as one attempts to access files on the device (e.g. via {{ic|ls}}), an error is reported:<br />
<br />
cannot access <mount-point>: Input/output error<br />
<br />
This appears to be a security feature: MTP does not work when the phone is locked by the lockscreen. Unlock the phone and it should work again as long as the cord remains connected.<br />
<br />
=== kio-mtp ===<br />
<br />
If you are not able to use the action "Open with File Manager", you may work around this problem by editing the file {{ic|/usr/share/apps/solid/actions/solid_mtp.desktop}}.<br />
<br />
Change the line<br />
<br />
Exec=kioclient exec mtp:udi=%i/<br />
<br />
To<br />
<br />
Exec=dolphin "mtp:/"</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Media_Transfer_Protocol&diff=447161Media Transfer Protocol2016-08-20T20:48:21Z<p>Andy Crowd: /* gvfs-mtp */ added link to supported devices as part of the updated description.</p>
<hr />
<div>[[Category:Storage]]<br />
[[Category:Mobile devices]]<br />
[[fa:MTP]]<br />
[[ja:MTP]]<br />
[[ru:MTP]]<br />
[[zh-CN:MTP]]<br />
{{Related articles start}}<br />
{{Related|USB storage devices}}<br />
{{Related articles end}}<br />
[[Wikipedia:Media_Transfer_Protocol|MTP]], or the ''Media Transfer Protocol'', is a USB device class which is used by many mobile phones (e.g. Samsung Galaxy S4) and media players (e.g. Creative Zen).<br />
<br />
== Installation ==<br />
<br />
=== Functionality ===<br />
<br />
Linux MTP support is provided by [[installing]] the {{Pkg|libmtp}} package. It can be installed on its own and used to access devices. However, a number of packages are available that use it as a dependency and add additional convenience (e.g. filemanager) functionalities and compatibility with particular device types - which includes improving transfer access speeds. <br />
<br />
These packages to choose from all implement a [[Wikipedia:Filesystem in Userspace]]: <br />
<br />
* {{Pkg|mtpfs}}<br />
* {{AUR|jmtpfs}} - is reported to work well for newer Android 4+ devices <br />
* {{AUR|go-mtpfs-git}} - is reported to work well for newer Android 3+ devices <br />
* {{AUR|simple-mtpfs}}<br />
* {{Pkg|android-file-transfer}} - MTP client with minimalistic UI<br />
<br />
All of them aim at better functionality and performance over {{ic|libmtp}}. Since there are a lot of different USB devices, you might want to research first which one looks most suitable for yours. <br />
<br />
{{Tip|It is recommended to reboot your computer after installing MTP related packages.}}<br />
<br />
=== Integration with file managers ===<br />
<br />
To view the contents of your Android device's storage via MTP in your file manager, install the corresponding plugin:<br />
<br />
* For file managers that use [[GVFS]] (GNOME Files), install {{Pkg|gvfs-mtp}} for MTP or {{Pkg|gvfs-gphoto2}} for PTP support.<br />
* For file managers that use KIO (KDE's Dolphin), MTP support is included in {{Pkg|kio-extras}} (dependency of dolphin).<br />
<br />
After installing the required package, the device should show up in the file manager automatically and be accessible via an URL, for example {{ic|mtp://[usb:002,013]/}}.<br />
<br />
== Usage ==<br />
<br />
It might be required to create a mount-point directory first. The directory {{ic|~/mnt}} is used as an example below. Also do not forget to unlock your phone's screen before connecting it to the computer.<br />
<br />
=== libmtp ===<br />
<br />
Detect your device:<br />
<br />
# mtp-detect<br />
<br />
If an error is returned, see [[#libmtp 2|troubleshooting libmtp]]. <br />
<br />
{{Note|Your regular user must be in the {{ic|uucp}} [[users_and_groups#Example_adding_a_user|group]].}}<br />
<br />
Connect to your device:<br />
# mtp-connect<br />
<br />
If connection is successful, there are several switch options to use in conjunction with ''mtp-connect'' to access data on the device. You might want to use some stand alone commands:<br />
mtp-albumart mtp-emptyfolders mtp-getplaylist mtp-reset mtp-trexist<br />
mtp-albums mtp-files mtp-hotplug mtp-sendfile<br />
mtp-connect mtp-folders mtp-newfolder mtp-sendtr<br />
mtp-delfile mtp-format mtp-newplaylist mtp-thumb<br />
mtp-detect mtp-getfile mtp-playlists mtp-tracks<br />
<br />
=== mtpfs ===<br />
<br />
{{Note | The following is likely to not work and you might have to resort to [[Digital_Cameras#libgphoto2|gphoto2]] or a file manager with gvfs support like [[PCManFM]]. }}<br />
<br />
First edit your {{ic|/etc/fuse.conf}} and uncomment the following line:<br />
user_allow_other<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
$ mtpfs -o allow_other ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== jmtpfs ===<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ jmtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
Make this cohere to the rest of Linux (use regular mount/umount commands) by doing two steps<br />
<br />
$# ln -s <actual mount command's path/name> <a name consistent with Linux's mount convention><br />
$ ln -s /sbin/jmtpfs /sbin/mount.jmtpfs<br />
<br />
add this line to /etc/fstab; <br />
<br />
#jmtpfs <mount path> fuse nodev,allow_other,<other options> 0 0<br />
jmtpfs /home/sam/run/motog fuse nodev,allow_other,rw,user,noauto,noatime,uid=1000,gid=1000 0 0<br />
<br />
Now mount the device and see if the options "took"<br />
<br />
$ mount /home/sam/run/motog<br />
Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).<br />
Android device detected, assigning default bug flags<br />
$ mount <br />
...<br />
jmtpfs on /home/sam/run/motog type fuse.jmtpfs (rw,nosuid,nodev,noexec,noatime,user_id=1000,group_id=1000,allow_other,user=sam)<br />
<br />
=== go-mtpfs ===<br />
<br />
{{Note|Mounting with {{ic|go-mtpfs}} might fail if an external SD Card is present. If you try to access your device while having an SD card and go-mtpfs complains, try removing the SD card and mounting again.}}<br />
<br />
Install {{Pkg|android-udev}}, which will allow you to edit {{ic|/etc/udev/rules.d/51-android.rules}} and apply to your {{ic|idVendor}} and {{ic|idProduct}}, which you can see after running ''mtp-detect''. To the end of the line, add your user {{ic|<nowiki>OWNER="<user>"</nowiki>}}.<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ go-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== simple-mtpfs ===<br />
<br />
List MTP devices:<br />
<br />
$ simple-mtpfs --list-devices<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
<br />
$ simple-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== Android File Transfer ===<br />
<br />
;FUSE interface<br />
<br />
Mount your device on {{ic|~/my-device}}:<br />
$ mkdir ~/my-device<br />
$ aft-mtp-mount ~/my-device<br />
<br />
If you want album art to be displayed, it must be named {{ic|albumart.xxx}} and placed first in the destination folder. Then copy other files. Also, note that fuse could be 7-8 times slower than ui/cli file transfer.<br />
<br />
Unmount device mounted on {{ic|~/my-device}}:<br />
<br />
$ fusermount -u ~/my-device<br />
<br />
;Qt user interface<br />
<br />
Start the application, choose a destination folder and click any button on the toolbar. Available options are: ''Upload Album'', ''Upload Directory'' and ''Upload Files''. The latter two are self-explanatory. ''Upload album'' searches the source directory for album covers, and sets the best available cover.<br />
<br />
=== Media players ===<br />
<br />
You can also use your MTP device in music players such as Amarok. To achieve this, you might have to edit {{ic|/etc/udev/rules.d/51-android.rules}} (the MTP device used in the following example is a Galaxy Nexus). <br />
Run:<br />
<br />
$ lsusb<br />
<br />
Search for your device. It should be something like that:<br />
Bus 003 Device 011: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-P7500 [Galaxy Tab 10.1]<br />
<br />
And entry to {{ic|/etc/udev/rules.d/51-android.rules}} will be this:<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="[username]"<br />
<br />
Also reload udev rules:<br />
# udevadm control --reload<br />
<br />
=== gvfs-mtp ===<br />
<br />
{{Merge|udev}}<br />
<br />
The {{Pkg|gvfs-mtp}} is available in the official repositories.<br />
<br />
With {{ic|lsusb}} you can get information about your device where Bus and Device numbers can be used with {{ic|gvfs-mtp}} and device ID for creating of an [[udev]] rule.<br />
Bus '''001''' Device '''007''': ID '''0421:0661''' Nokia Mobile Phones Lumia 920<br />
(...)<br />
<br />
To see detected device with enabled MTP<br />
<br />
Use ''gvfs-mount'':<br />
<br />
{{hc|<NOWIKI>gvfs-mount -li | grep -e ^Volume -e activation_root</NOWIKI>|2=<br />
Volume(0): MT65xx Android Phone<br />
activation_root=mtp://[usb:002,018]/<br />
}}<br />
<br />
Use ''lsusb'':<br />
<br />
{{hc|<NOWIKI>lsusb -v 2> /dev/null | grep -e Bus -e iInterface -e bInterfaceProtocol</NOWIKI>|<br />
(......<br />
......)<br />
Bus 002 Device 018: ID 04b7:88a9 Compal Electronics, Inc. <br />
bInterfaceProtocol 0 <br />
iInterface 5 MTP<br />
(......<br />
......)<br />
}}<br />
<br />
To mount all available connected MTP devices use inline script<br />
<br />
gvfs-mount -li | awk -F= '{if(index($2,"mtp") == 1)system("gvfs-mount "$2)}'<br />
<br />
To mount or dismount from a command with gvfs-mtp use Bus and Device numbers, e.g. to mount {{ic|gvfs-mount mtp://[usb:001,007]/}} and to unmount {{ic|gvfs-mount -u mtp://[usb:001,007]/}}. The mounted device will be available in a directory that begins with ''mtp:host='' and is located under ''/run/user/$UID/gvfs/''.<br />
<br />
Disable automount of MTP devises with gvfs you will need to change value ''true'' to ''false'' for variable ''AutoMount'' that is located in {{ic|/usr/share/gvfs/mounts/mtp.mount}}.<br />
<br />
{{Note|The file managers can have own options for automount. On start they checking for all available mountable devices.}}<br />
<br />
If your device isn't showing up in the file manager then the {{Pkg|libmtp}} is missing a native support and is not currently available in the the list of the [https://sourceforge.net/p/libmtp/code/ci/HEAD/tree/src/music-players.h supported devices]. The workaround is to write an [[udev]] rule for the device.<br />
<br />
Use ID number that represents by pattern ''vendorId'':''productID'',e.g. ''0421'':''0661'', and make an udev rule by creating a configuration file<br />
<br />
{{hc|/etc/udev/rules.d/51-android.rules|<NOWIKI><br />
ATTR{idVendor}=="0421", ATTR{idProduct}=="0661", SYMLINK+="libmtp", MODE="660", ENV{ID_MTP_DEVICE}="1"<br />
</NOWIKI>}}<br />
Reload the udev rules.<br />
<br />
# udevadm control --reload<br />
<br />
The file managers with support for [[gvfs]] will be able to show MTP devices and mount them if supported by {{Pkg|libmtp}} but if has no support and cannot be opened then change settings in the phone to PTP and install {{Pkg|gvfs-gphoto2}} for having access at least to the photos, command line mounting of PTP is a little similar to mounting of the MTP devices: {{ic|gvfs-mount gphoto2://[usb:002,019]/}}.<br />
<br />
{{Note|If you getting limited access to the device and cannot use standard commands from command line such as e.g. {{ic|cp}},{{ic|ls}} then look for [[gvfs]] own alternatives, {{ic|ls -1 /usr/bin/gvfs-*}}.}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== libmtp ===<br />
<br />
==== Unknown device ====<br />
<br />
If you see a message like:<br />
<br />
Device 0 (VID=XXXX and PID=XXXX) is UNKNOWN.<br />
Please report this VID/PID and the device model to the libmtp development team<br />
<br />
You should check whether your device is listed in the [http://sourceforge.net/p/libmtp/code/ci/HEAD/tree/src/music-players.h supported devices list]. If it is not, you should report it to the developers team. If it is, your {{ic|libmtp}} might be slightly outdated. To allow it to be properly used by {{ic|libmtp}}, you can add your device to:<br />
<br />
/etc/udev/rules.d/69-libmtp.rules<br />
<br />
==== Unable to enumerate USB device ====<br />
{{Deletion|This should be an old kernel bug, and should have been fixed already. There is no bug report to confirm though.}}<br />
{{Merge||Unrelated to MTP, perhaps suited for [[USB storage devices]]}}<br />
<br />
If you see a message like this in system log ({{ic|journalctl}})<br />
<br />
usb usb4-port2: unable to enumerate USB device<br />
<br />
You can try following temporary [https://bbs.archlinux.org/viewtopic.php?pid=1087323#p1087323 workaround]<br />
<br />
# modprobe -vr uhci_hcd<br />
# modprobe -va ohci_hcd<br />
# modprobe -va uhci_hcd<br />
<br />
If it works you should create {{ic|/etc/modprobe.d/usb_hci_order.conf}} with following content<br />
<br />
# create a dependency on ohci for uhci, which fixes problems<br />
# with external usb devices not showing up<br />
#<br />
softdep uhci_hcd pre: ohci_hcd<br />
<br />
=== jmtpfs ===<br />
<br />
==== Input/output error upon first access ====<br />
<br />
Symptoms: jmtpfs successfully mounts, but as soon as one attempts to access files on the device (e.g. via {{ic|ls}}), an error is reported:<br />
<br />
cannot access <mount-point>: Input/output error<br />
<br />
This appears to be a security feature: MTP does not work when the phone is locked by the lockscreen. Unlock the phone and it should work again as long as the cord remains connected.<br />
<br />
=== kio-mtp ===<br />
<br />
If you are not able to use the action "Open with File Manager", you may work around this problem by editing the file {{ic|/usr/share/apps/solid/actions/solid_mtp.desktop}}.<br />
<br />
Change the line<br />
<br />
Exec=kioclient exec mtp:udi=%i/<br />
<br />
To<br />
<br />
Exec=dolphin "mtp:/"</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Talk:Media_Transfer_Protocol&diff=447059Talk:Media Transfer Protocol2016-08-19T22:59:30Z<p>Andy Crowd: merge "MTP#Media_players" and "MTP#gvfs-mtp" because of udev rules?</p>
<hr />
<div>== Custom udev rules and rebooting ==<br />
<br />
In a couple of places {{ic|/usr/lib/udev/rules.d/}} is used as location for custom {{ic|udev}} rules. Isn't the {{ic|/etc/udev/rules.d/}} a better place for them? If so I propose to change {{ic|/usr/lib/udev/rules.d/}} to {{ic|/etc/udev/rules.d/}}.<br />
<br />
Also, there's no need for rebooting the system, as suggested in [[MTP#gvfs-mtp troubleshooting]]. What is that? A Windows? ;} I think this should be removed or changed to some other means like “relogging”.<br />
<br />
--thebodzio 22:34, 29 December 2014 (UTC)<br />
<br />
:Yes to both, [[Udev#About udev rules]] and [[Udev#Loading new rules]]. -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 01:39, 31 December 2014 (UTC)<br />
<br />
:: May be it must be removed "This article or section is a candidate for merging with udev."? I have added more related info to gvfs-mtp but not related to udev, I think that it is good if will stay here as it is. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:28, 17 August 2016 (UTC)).<br />
<br />
::I am not sure about two probably similar [[udev]] rules [[MTP#Media_players]] and [[MTP#gvfs-mtp]], may be to have only one is enough and merge both?(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 22:58, 19 August 2016 (UTC)).</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Media_Transfer_Protocol&diff=447031Media Transfer Protocol2016-08-19T18:18:22Z<p>Andy Crowd: Moved gvfs-mtp from "Troubleshooting" to usage, I think it is a better place after last edits because of description mix gvfs-mount and udev in the same section.</p>
<hr />
<div>[[Category:Storage]]<br />
[[Category:Mobile devices]]<br />
[[fa:MTP]]<br />
[[ja:MTP]]<br />
[[ru:MTP]]<br />
[[zh-CN:MTP]]<br />
{{Related articles start}}<br />
{{Related|USB storage devices}}<br />
{{Related articles end}}<br />
[[Wikipedia:Media_Transfer_Protocol|MTP]], or the ''Media Transfer Protocol'', is a USB device class which is used by many mobile phones (e.g. Samsung Galaxy S4) and media players (e.g. Creative Zen).<br />
<br />
== Installation ==<br />
<br />
=== Functionality ===<br />
<br />
Linux MTP support is provided by [[installing]] the {{Pkg|libmtp}} package. It can be installed on its own and used to access devices. However, a number of packages are available that use it as a dependency and add additional convenience (e.g. filemanager) functionalities and compatibility with particular device types - which includes improving transfer access speeds. <br />
<br />
These packages to choose from all implement a [[Wikipedia:Filesystem in Userspace]]: <br />
<br />
* {{Pkg|mtpfs}}<br />
* {{AUR|jmtpfs}} - is reported to work well for newer Android 4+ devices <br />
* {{AUR|go-mtpfs-git}} - is reported to work well for newer Android 3+ devices <br />
* {{AUR|simple-mtpfs}}<br />
* {{Pkg|android-file-transfer}} - MTP client with minimalistic UI<br />
<br />
All of them aim at better functionality and performance over {{ic|libmtp}}. Since there are a lot of different USB devices, you might want to research first which one looks most suitable for yours. <br />
<br />
{{Tip|It is recommended to reboot your computer after installing MTP related packages.}}<br />
<br />
=== Integration with file managers ===<br />
<br />
To view the contents of your Android device's storage via MTP in your file manager, install the corresponding plugin:<br />
<br />
* For file managers that use [[GVFS]] (GNOME Files), install {{Pkg|gvfs-mtp}} for MTP or {{Pkg|gvfs-gphoto2}} for PTP support.<br />
* For file managers that use KIO (KDE's Dolphin), MTP support is included in {{Pkg|kio-extras}} (dependency of dolphin).<br />
<br />
After installing the required package, the device should show up in the file manager automatically and be accessible via an URL, for example {{ic|mtp://[usb:002,013]/}}.<br />
<br />
== Usage ==<br />
<br />
It might be required to create a mount-point directory first. The directory {{ic|~/mnt}} is used as an example below. Also do not forget to unlock your phone's screen before connecting it to the computer.<br />
<br />
=== libmtp ===<br />
<br />
Detect your device:<br />
<br />
# mtp-detect<br />
<br />
If an error is returned, see [[#libmtp 2|troubleshooting libmtp]]. <br />
<br />
{{Note|Your regular user must be in the {{ic|uucp}} [[users_and_groups#Example_adding_a_user|group]].}}<br />
<br />
Connect to your device:<br />
# mtp-connect<br />
<br />
If connection is successful, there are several switch options to use in conjunction with ''mtp-connect'' to access data on the device. You might want to use some stand alone commands:<br />
mtp-albumart mtp-emptyfolders mtp-getplaylist mtp-reset mtp-trexist<br />
mtp-albums mtp-files mtp-hotplug mtp-sendfile<br />
mtp-connect mtp-folders mtp-newfolder mtp-sendtr<br />
mtp-delfile mtp-format mtp-newplaylist mtp-thumb<br />
mtp-detect mtp-getfile mtp-playlists mtp-tracks<br />
<br />
=== mtpfs ===<br />
<br />
{{Note | The following is likely to not work and you might have to resort to [[Digital_Cameras#libgphoto2|gphoto2]] or a file manager with gvfs support like [[PCManFM]]. }}<br />
<br />
First edit your {{ic|/etc/fuse.conf}} and uncomment the following line:<br />
user_allow_other<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
$ mtpfs -o allow_other ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== jmtpfs ===<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ jmtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
Make this cohere to the rest of Linux (use regular mount/umount commands) by doing two steps<br />
<br />
$# ln -s <actual mount command's path/name> <a name consistent with Linux's mount convention><br />
$ ln -s /sbin/jmtpfs /sbin/mount.jmtpfs<br />
<br />
add this line to /etc/fstab; <br />
<br />
#jmtpfs <mount path> fuse nodev,allow_other,<other options> 0 0<br />
jmtpfs /home/sam/run/motog fuse nodev,allow_other,rw,user,noauto,noatime,uid=1000,gid=1000 0 0<br />
<br />
Now mount the device and see if the options "took"<br />
<br />
$ mount /home/sam/run/motog<br />
Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).<br />
Android device detected, assigning default bug flags<br />
$ mount <br />
...<br />
jmtpfs on /home/sam/run/motog type fuse.jmtpfs (rw,nosuid,nodev,noexec,noatime,user_id=1000,group_id=1000,allow_other,user=sam)<br />
<br />
=== go-mtpfs ===<br />
<br />
{{Note|Mounting with {{ic|go-mtpfs}} might fail if an external SD Card is present. If you try to access your device while having an SD card and go-mtpfs complains, try removing the SD card and mounting again.}}<br />
<br />
Install {{Pkg|android-udev}}, which will allow you to edit {{ic|/etc/udev/rules.d/51-android.rules}} and apply to your {{ic|idVendor}} and {{ic|idProduct}}, which you can see after running ''mtp-detect''. To the end of the line, add your user {{ic|<nowiki>OWNER="<user>"</nowiki>}}.<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ go-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== simple-mtpfs ===<br />
<br />
List MTP devices:<br />
<br />
$ simple-mtpfs --list-devices<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
<br />
$ simple-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== Android File Transfer ===<br />
<br />
;FUSE interface<br />
<br />
Mount your device on {{ic|~/my-device}}:<br />
$ mkdir ~/my-device<br />
$ aft-mtp-mount ~/my-device<br />
<br />
If you want album art to be displayed, it must be named {{ic|albumart.xxx}} and placed first in the destination folder. Then copy other files. Also, note that fuse could be 7-8 times slower than ui/cli file transfer.<br />
<br />
Unmount device mounted on {{ic|~/my-device}}:<br />
<br />
$ fusermount -u ~/my-device<br />
<br />
;Qt user interface<br />
<br />
Start the application, choose a destination folder and click any button on the toolbar. Available options are: ''Upload Album'', ''Upload Directory'' and ''Upload Files''. The latter two are self-explanatory. ''Upload album'' searches the source directory for album covers, and sets the best available cover.<br />
<br />
=== Media players ===<br />
<br />
You can also use your MTP device in music players such as Amarok. To achieve this, you might have to edit {{ic|/etc/udev/rules.d/51-android.rules}} (the MTP device used in the following example is a Galaxy Nexus). <br />
Run:<br />
<br />
$ lsusb<br />
<br />
Search for your device. It should be something like that:<br />
Bus 003 Device 011: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-P7500 [Galaxy Tab 10.1]<br />
<br />
And entry to {{ic|/etc/udev/rules.d/51-android.rules}} will be this:<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="[username]"<br />
<br />
Also reload udev rules:<br />
# udevadm control --reload<br />
<br />
=== gvfs-mtp ===<br />
<br />
{{Merge|udev}}<br />
<br />
The {{Pkg|gvfs-mtp}} is available in the official repositories.<br />
<br />
With {{ic|lsusb}} you can get information about your device where Bus and Device numbers can be used with {{ic|gvfs-mtp}} and device ID for creating of an [[udev]] rule.<br />
Bus '''001''' Device '''007''': ID '''0421:0661''' Nokia Mobile Phones Lumia 920<br />
(...)<br />
<br />
To see detected device with enabled MTP<br />
<br />
Use ''gvfs-mount'':<br />
<br />
{{hc|<NOWIKI>gvfs-mount -li | grep -e ^Volume -e activation_root</NOWIKI>|2=<br />
Volume(0): MT65xx Android Phone<br />
activation_root=mtp://[usb:002,018]/<br />
}}<br />
<br />
Use ''lsusb'':<br />
<br />
{{hc|<NOWIKI>lsusb -v 2> /dev/null | grep -e Bus -e iInterface -e bInterfaceProtocol</NOWIKI>|<br />
(......<br />
......)<br />
Bus 002 Device 018: ID 04b7:88a9 Compal Electronics, Inc. <br />
bInterfaceProtocol 0 <br />
iInterface 5 MTP<br />
(......<br />
......)<br />
}}<br />
<br />
To mount all available connected MTP devices use inline script<br />
<br />
gvfs-mount -li | awk -F= '{if(index($2,"mtp") == 1)system("gvfs-mount "$2)}'<br />
<br />
To mount or dismount from a command with gvfs-mtp use Bus and Device numbers, e.g. to mount {{ic|gvfs-mount mtp://[usb:001,007]/}} and to unmount {{ic|gvfs-mount -u mtp://[usb:001,007]/}}. The mounted device will be available in a directory that begins with ''mtp:host='' and is located under ''/run/user/$UID/gvfs/''.<br />
<br />
Disable automount of MTP devises with gvfs you will need to change value ''true'' to ''false'' for variable ''AutoMount'' that is located in {{ic|/usr/share/gvfs/mounts/mtp.mount}}.<br />
<br />
{{Note|The file managers can have own options for automount. On start they checking for all available mountable devices.}}<br />
<br />
If your device isn't show up in the file manager then the {{Pkg|libmtp}} is missing a native support for it, the workaround is to write an [[udev]] rule for the device.<br />
<br />
Use ID number that represents by pattern ''vendorId'':''productID'',e.g. ''0421'':''0661'', and make an udev rule by creating a configuration file<br />
<br />
{{hc|/etc/udev/rules.d/51-android.rules|<NOWIKI><br />
ATTR{idVendor}=="0421", ATTR{idProduct}=="0661", SYMLINK+="libmtp", MODE="660", ENV{ID_MTP_DEVICE}="1"<br />
</NOWIKI>}}<br />
Reload the udev rules.<br />
<br />
# udevadm control --reload<br />
<br />
The file managers with support for [[gvfs]] will be able to show MTP devices and mount them if supported by {{Pkg|libmtp}} but if has no support and cannot be opened then change settings in the phone to PTP and install {{Pkg|gvfs-gphoto2}} for having access at least to the photos, command line mounting of PTP is a little similar to mounting of the MTP devices: {{ic|gvfs-mount gphoto2://[usb:002,019]/}}.<br />
<br />
{{Note|If you getting limited access to the device and cannot use standard commands from command line such as e.g. {{ic|cp}},{{ic|ls}} then look for [[gvfs]] own alternatives, {{ic|ls -1 /usr/bin/gvfs-*}}.}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== libmtp ===<br />
<br />
==== Unknown device ====<br />
<br />
If you see a message like:<br />
<br />
Device 0 (VID=XXXX and PID=XXXX) is UNKNOWN.<br />
Please report this VID/PID and the device model to the libmtp development team<br />
<br />
You should check whether your device is listed in the [http://sourceforge.net/p/libmtp/code/ci/HEAD/tree/src/music-players.h supported devices list]. If it is not, you should report it to the developers team. If it is, your {{ic|libmtp}} might be slightly outdated. To allow it to be properly used by {{ic|libmtp}}, you can add your device to:<br />
<br />
/etc/udev/rules.d/69-libmtp.rules<br />
<br />
==== Unable to enumerate USB device ====<br />
{{Deletion|This should be an old kernel bug, and should have been fixed already. There is no bug report to confirm though.}}<br />
{{Merge||Unrelated to MTP, perhaps suited for [[USB storage devices]]}}<br />
<br />
If you see a message like this in system log ({{ic|journalctl}})<br />
<br />
usb usb4-port2: unable to enumerate USB device<br />
<br />
You can try following temporary [https://bbs.archlinux.org/viewtopic.php?pid=1087323#p1087323 workaround]<br />
<br />
# modprobe -vr uhci_hcd<br />
# modprobe -va ohci_hcd<br />
# modprobe -va uhci_hcd<br />
<br />
If it works you should create {{ic|/etc/modprobe.d/usb_hci_order.conf}} with following content<br />
<br />
# create a dependency on ohci for uhci, which fixes problems<br />
# with external usb devices not showing up<br />
#<br />
softdep uhci_hcd pre: ohci_hcd<br />
<br />
=== jmtpfs ===<br />
<br />
==== Input/output error upon first access ====<br />
<br />
Symptoms: jmtpfs successfully mounts, but as soon as one attempts to access files on the device (e.g. via {{ic|ls}}), an error is reported:<br />
<br />
cannot access <mount-point>: Input/output error<br />
<br />
This appears to be a security feature: MTP does not work when the phone is locked by the lockscreen. Unlock the phone and it should work again as long as the cord remains connected.<br />
<br />
=== kio-mtp ===<br />
<br />
If you are not able to use the action "Open with File Manager", you may work around this problem by editing the file {{ic|/usr/share/apps/solid/actions/solid_mtp.desktop}}.<br />
<br />
Change the line<br />
<br />
Exec=kioclient exec mtp:udi=%i/<br />
<br />
To<br />
<br />
Exec=dolphin "mtp:/"</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Media_Transfer_Protocol&diff=447029Media Transfer Protocol2016-08-19T18:12:52Z<p>Andy Crowd: /* gvfs-mtp */ rewrote the udev part and removed link to the forum: "https://bbs.archlinux.org/viewtopic.php?id=180719" because it is many other results in search engines.</p>
<hr />
<div>[[Category:Storage]]<br />
[[Category:Mobile devices]]<br />
[[fa:MTP]]<br />
[[ja:MTP]]<br />
[[ru:MTP]]<br />
[[zh-CN:MTP]]<br />
{{Related articles start}}<br />
{{Related|USB storage devices}}<br />
{{Related articles end}}<br />
[[Wikipedia:Media_Transfer_Protocol|MTP]], or the ''Media Transfer Protocol'', is a USB device class which is used by many mobile phones (e.g. Samsung Galaxy S4) and media players (e.g. Creative Zen).<br />
<br />
== Installation ==<br />
<br />
=== Functionality ===<br />
<br />
Linux MTP support is provided by [[installing]] the {{Pkg|libmtp}} package. It can be installed on its own and used to access devices. However, a number of packages are available that use it as a dependency and add additional convenience (e.g. filemanager) functionalities and compatibility with particular device types - which includes improving transfer access speeds. <br />
<br />
These packages to choose from all implement a [[Wikipedia:Filesystem in Userspace]]: <br />
<br />
* {{Pkg|mtpfs}}<br />
* {{AUR|jmtpfs}} - is reported to work well for newer Android 4+ devices <br />
* {{AUR|go-mtpfs-git}} - is reported to work well for newer Android 3+ devices <br />
* {{AUR|simple-mtpfs}}<br />
* {{Pkg|android-file-transfer}} - MTP client with minimalistic UI<br />
<br />
All of them aim at better functionality and performance over {{ic|libmtp}}. Since there are a lot of different USB devices, you might want to research first which one looks most suitable for yours. <br />
<br />
{{Tip|It is recommended to reboot your computer after installing MTP related packages.}}<br />
<br />
=== Integration with file managers ===<br />
<br />
To view the contents of your Android device's storage via MTP in your file manager, install the corresponding plugin:<br />
<br />
* For file managers that use [[GVFS]] (GNOME Files), install {{Pkg|gvfs-mtp}} for MTP or {{Pkg|gvfs-gphoto2}} for PTP support.<br />
* For file managers that use KIO (KDE's Dolphin), MTP support is included in {{Pkg|kio-extras}} (dependency of dolphin).<br />
<br />
After installing the required package, the device should show up in the file manager automatically and be accessible via an URL, for example {{ic|mtp://[usb:002,013]/}}.<br />
<br />
== Usage ==<br />
<br />
It might be required to create a mount-point directory first. The directory {{ic|~/mnt}} is used as an example below. Also do not forget to unlock your phone's screen before connecting it to the computer.<br />
<br />
=== libmtp ===<br />
<br />
Detect your device:<br />
<br />
# mtp-detect<br />
<br />
If an error is returned, see [[#libmtp 2|troubleshooting libmtp]]. <br />
<br />
{{Note|Your regular user must be in the {{ic|uucp}} [[users_and_groups#Example_adding_a_user|group]].}}<br />
<br />
Connect to your device:<br />
# mtp-connect<br />
<br />
If connection is successful, there are several switch options to use in conjunction with ''mtp-connect'' to access data on the device. You might want to use some stand alone commands:<br />
mtp-albumart mtp-emptyfolders mtp-getplaylist mtp-reset mtp-trexist<br />
mtp-albums mtp-files mtp-hotplug mtp-sendfile<br />
mtp-connect mtp-folders mtp-newfolder mtp-sendtr<br />
mtp-delfile mtp-format mtp-newplaylist mtp-thumb<br />
mtp-detect mtp-getfile mtp-playlists mtp-tracks<br />
<br />
=== mtpfs ===<br />
<br />
{{Note | The following is likely to not work and you might have to resort to [[Digital_Cameras#libgphoto2|gphoto2]] or a file manager with gvfs support like [[PCManFM]]. }}<br />
<br />
First edit your {{ic|/etc/fuse.conf}} and uncomment the following line:<br />
user_allow_other<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
$ mtpfs -o allow_other ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== jmtpfs ===<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ jmtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
Make this cohere to the rest of Linux (use regular mount/umount commands) by doing two steps<br />
<br />
$# ln -s <actual mount command's path/name> <a name consistent with Linux's mount convention><br />
$ ln -s /sbin/jmtpfs /sbin/mount.jmtpfs<br />
<br />
add this line to /etc/fstab; <br />
<br />
#jmtpfs <mount path> fuse nodev,allow_other,<other options> 0 0<br />
jmtpfs /home/sam/run/motog fuse nodev,allow_other,rw,user,noauto,noatime,uid=1000,gid=1000 0 0<br />
<br />
Now mount the device and see if the options "took"<br />
<br />
$ mount /home/sam/run/motog<br />
Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).<br />
Android device detected, assigning default bug flags<br />
$ mount <br />
...<br />
jmtpfs on /home/sam/run/motog type fuse.jmtpfs (rw,nosuid,nodev,noexec,noatime,user_id=1000,group_id=1000,allow_other,user=sam)<br />
<br />
=== go-mtpfs ===<br />
<br />
{{Note|Mounting with {{ic|go-mtpfs}} might fail if an external SD Card is present. If you try to access your device while having an SD card and go-mtpfs complains, try removing the SD card and mounting again.}}<br />
<br />
Install {{Pkg|android-udev}}, which will allow you to edit {{ic|/etc/udev/rules.d/51-android.rules}} and apply to your {{ic|idVendor}} and {{ic|idProduct}}, which you can see after running ''mtp-detect''. To the end of the line, add your user {{ic|<nowiki>OWNER="<user>"</nowiki>}}.<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ go-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== simple-mtpfs ===<br />
<br />
List MTP devices:<br />
<br />
$ simple-mtpfs --list-devices<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
<br />
$ simple-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== Android File Transfer ===<br />
<br />
;FUSE interface<br />
<br />
Mount your device on {{ic|~/my-device}}:<br />
$ mkdir ~/my-device<br />
$ aft-mtp-mount ~/my-device<br />
<br />
If you want album art to be displayed, it must be named {{ic|albumart.xxx}} and placed first in the destination folder. Then copy other files. Also, note that fuse could be 7-8 times slower than ui/cli file transfer.<br />
<br />
Unmount device mounted on {{ic|~/my-device}}:<br />
<br />
$ fusermount -u ~/my-device<br />
<br />
;Qt user interface<br />
<br />
Start the application, choose a destination folder and click any button on the toolbar. Available options are: ''Upload Album'', ''Upload Directory'' and ''Upload Files''. The latter two are self-explanatory. ''Upload album'' searches the source directory for album covers, and sets the best available cover.<br />
<br />
=== Media players ===<br />
<br />
You can also use your MTP device in music players such as Amarok. To achieve this, you might have to edit {{ic|/etc/udev/rules.d/51-android.rules}} (the MTP device used in the following example is a Galaxy Nexus). <br />
Run:<br />
<br />
$ lsusb<br />
<br />
Search for your device. It should be something like that:<br />
Bus 003 Device 011: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-P7500 [Galaxy Tab 10.1]<br />
<br />
And entry to {{ic|/etc/udev/rules.d/51-android.rules}} will be this:<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="[username]"<br />
<br />
Also reload udev rules:<br />
# udevadm control --reload<br />
<br />
== Troubleshooting ==<br />
<br />
=== libmtp ===<br />
<br />
==== Unknown device ====<br />
<br />
If you see a message like:<br />
<br />
Device 0 (VID=XXXX and PID=XXXX) is UNKNOWN.<br />
Please report this VID/PID and the device model to the libmtp development team<br />
<br />
You should check whether your device is listed in the [http://sourceforge.net/p/libmtp/code/ci/HEAD/tree/src/music-players.h supported devices list]. If it is not, you should report it to the developers team. If it is, your {{ic|libmtp}} might be slightly outdated. To allow it to be properly used by {{ic|libmtp}}, you can add your device to:<br />
<br />
/etc/udev/rules.d/69-libmtp.rules<br />
<br />
==== Unable to enumerate USB device ====<br />
{{Deletion|This should be an old kernel bug, and should have been fixed already. There is no bug report to confirm though.}}<br />
{{Merge||Unrelated to MTP, perhaps suited for [[USB storage devices]]}}<br />
<br />
If you see a message like this in system log ({{ic|journalctl}})<br />
<br />
usb usb4-port2: unable to enumerate USB device<br />
<br />
You can try following temporary [https://bbs.archlinux.org/viewtopic.php?pid=1087323#p1087323 workaround]<br />
<br />
# modprobe -vr uhci_hcd<br />
# modprobe -va ohci_hcd<br />
# modprobe -va uhci_hcd<br />
<br />
If it works you should create {{ic|/etc/modprobe.d/usb_hci_order.conf}} with following content<br />
<br />
# create a dependency on ohci for uhci, which fixes problems<br />
# with external usb devices not showing up<br />
#<br />
softdep uhci_hcd pre: ohci_hcd<br />
<br />
=== jmtpfs ===<br />
<br />
==== Input/output error upon first access ====<br />
<br />
Symptoms: jmtpfs successfully mounts, but as soon as one attempts to access files on the device (e.g. via {{ic|ls}}), an error is reported:<br />
<br />
cannot access <mount-point>: Input/output error<br />
<br />
This appears to be a security feature: MTP does not work when the phone is locked by the lockscreen. Unlock the phone and it should work again as long as the cord remains connected.<br />
<br />
=== gvfs-mtp ===<br />
<br />
{{Merge|udev}}<br />
<br />
The {{Pkg|gvfs-mtp}} is available in the official repositories.<br />
<br />
With {{ic|lsusb}} you can get information about your device where Bus and Device numbers can be used with {{ic|gvfs-mtp}} and device ID for creating of an [[udev]] rule.<br />
Bus '''001''' Device '''007''': ID '''0421:0661''' Nokia Mobile Phones Lumia 920<br />
(...)<br />
<br />
To see detected device with enabled MTP<br />
<br />
Use ''gvfs-mount'':<br />
<br />
{{hc|<NOWIKI>gvfs-mount -li | grep -e ^Volume -e activation_root</NOWIKI>|2=<br />
Volume(0): MT65xx Android Phone<br />
activation_root=mtp://[usb:002,018]/<br />
}}<br />
<br />
Use ''lsusb'':<br />
<br />
{{hc|<NOWIKI>lsusb -v 2> /dev/null | grep -e Bus -e iInterface -e bInterfaceProtocol</NOWIKI>|<br />
(......<br />
......)<br />
Bus 002 Device 018: ID 04b7:88a9 Compal Electronics, Inc. <br />
bInterfaceProtocol 0 <br />
iInterface 5 MTP<br />
(......<br />
......)<br />
}}<br />
<br />
To mount all available connected MTP devices use inline script<br />
<br />
gvfs-mount -li | awk -F= '{if(index($2,"mtp") == 1)system("gvfs-mount "$2)}'<br />
<br />
To mount or dismount from a command with gvfs-mtp use Bus and Device numbers, e.g. to mount {{ic|gvfs-mount mtp://[usb:001,007]/}} and to unmount {{ic|gvfs-mount -u mtp://[usb:001,007]/}}. The mounted device will be available in a directory that begins with ''mtp:host='' and is located under ''/run/user/$UID/gvfs/''.<br />
<br />
Disable automount of MTP devises with gvfs you will need to change value ''true'' to ''false'' for variable ''AutoMount'' that is located in {{ic|/usr/share/gvfs/mounts/mtp.mount}}.<br />
<br />
{{Note|The file managers can have own options for automount. On start they checking for all available mountable devices.}}<br />
<br />
If your device isn't show up in the file manager then the {{Pkg|libmtp}} is missing a native support for it, the workaround is to write an [[udev]] rule for the device.<br />
<br />
Use ID number that represents by pattern ''vendorId'':''productID'',e.g. ''0421'':''0661'', and make an udev rule by creating a configuration file<br />
<br />
{{hc|/etc/udev/rules.d/51-android.rules|<NOWIKI><br />
ATTR{idVendor}=="0421", ATTR{idProduct}=="0661", SYMLINK+="libmtp", MODE="660", ENV{ID_MTP_DEVICE}="1"<br />
</NOWIKI>}}<br />
Reload the udev rules.<br />
<br />
# udevadm control --reload<br />
<br />
The file managers with support for [[gvfs]] will be able to show MTP devices and mount them if supported by {{Pkg|libmtp}} but if has no support and cannot be opened then change settings in the phone to PTP and install {{Pkg|gvfs-gphoto2}} for having access at least to the photos, command line mounting of PTP is a little similar to mounting of the MTP devices: {{ic|gvfs-mount gphoto2://[usb:002,019]/}}.<br />
<br />
{{Note|If you getting limited access to the device and cannot use standard commands from command line such as e.g. {{ic|cp}},{{ic|ls}} then look for [[gvfs]] own alternatives, {{ic|ls -1 /usr/bin/gvfs-*}}.}}<br />
<br />
=== kio-mtp ===<br />
<br />
If you are not able to use the action "Open with File Manager", you may work around this problem by editing the file {{ic|/usr/share/apps/solid/actions/solid_mtp.desktop}}.<br />
<br />
Change the line<br />
<br />
Exec=kioclient exec mtp:udi=%i/<br />
<br />
To<br />
<br />
Exec=dolphin "mtp:/"</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Media_Transfer_Protocol&diff=447025Media Transfer Protocol2016-08-19T16:51:29Z<p>Andy Crowd: /* gvfs-mtp */ rewrote example about detection of MTP with "gvfs-mount -li" and added lsusb example to detect MTP as an alternative to gvfs-mount -li</p>
<hr />
<div>[[Category:Storage]]<br />
[[Category:Mobile devices]]<br />
[[fa:MTP]]<br />
[[ja:MTP]]<br />
[[ru:MTP]]<br />
[[zh-CN:MTP]]<br />
{{Related articles start}}<br />
{{Related|USB storage devices}}<br />
{{Related articles end}}<br />
[[Wikipedia:Media_Transfer_Protocol|MTP]], or the ''Media Transfer Protocol'', is a USB device class which is used by many mobile phones (e.g. Samsung Galaxy S4) and media players (e.g. Creative Zen).<br />
<br />
== Installation ==<br />
<br />
=== Functionality ===<br />
<br />
Linux MTP support is provided by [[installing]] the {{Pkg|libmtp}} package. It can be installed on its own and used to access devices. However, a number of packages are available that use it as a dependency and add additional convenience (e.g. filemanager) functionalities and compatibility with particular device types - which includes improving transfer access speeds. <br />
<br />
These packages to choose from all implement a [[Wikipedia:Filesystem in Userspace]]: <br />
<br />
* {{Pkg|mtpfs}}<br />
* {{AUR|jmtpfs}} - is reported to work well for newer Android 4+ devices <br />
* {{AUR|go-mtpfs-git}} - is reported to work well for newer Android 3+ devices <br />
* {{AUR|simple-mtpfs}}<br />
* {{Pkg|android-file-transfer}} - MTP client with minimalistic UI<br />
<br />
All of them aim at better functionality and performance over {{ic|libmtp}}. Since there are a lot of different USB devices, you might want to research first which one looks most suitable for yours. <br />
<br />
{{Tip|It is recommended to reboot your computer after installing MTP related packages.}}<br />
<br />
=== Integration with file managers ===<br />
<br />
To view the contents of your Android device's storage via MTP in your file manager, install the corresponding plugin:<br />
<br />
* For file managers that use [[GVFS]] (GNOME Files), install {{Pkg|gvfs-mtp}} for MTP or {{Pkg|gvfs-gphoto2}} for PTP support.<br />
* For file managers that use KIO (KDE's Dolphin), MTP support is included in {{Pkg|kio-extras}} (dependency of dolphin).<br />
<br />
After installing the required package, the device should show up in the file manager automatically and be accessible via an URL, for example {{ic|mtp://[usb:002,013]/}}.<br />
<br />
== Usage ==<br />
<br />
It might be required to create a mount-point directory first. The directory {{ic|~/mnt}} is used as an example below. Also do not forget to unlock your phone's screen before connecting it to the computer.<br />
<br />
=== libmtp ===<br />
<br />
Detect your device:<br />
<br />
# mtp-detect<br />
<br />
If an error is returned, see [[#libmtp 2|troubleshooting libmtp]]. <br />
<br />
{{Note|Your regular user must be in the {{ic|uucp}} [[users_and_groups#Example_adding_a_user|group]].}}<br />
<br />
Connect to your device:<br />
# mtp-connect<br />
<br />
If connection is successful, there are several switch options to use in conjunction with ''mtp-connect'' to access data on the device. You might want to use some stand alone commands:<br />
mtp-albumart mtp-emptyfolders mtp-getplaylist mtp-reset mtp-trexist<br />
mtp-albums mtp-files mtp-hotplug mtp-sendfile<br />
mtp-connect mtp-folders mtp-newfolder mtp-sendtr<br />
mtp-delfile mtp-format mtp-newplaylist mtp-thumb<br />
mtp-detect mtp-getfile mtp-playlists mtp-tracks<br />
<br />
=== mtpfs ===<br />
<br />
{{Note | The following is likely to not work and you might have to resort to [[Digital_Cameras#libgphoto2|gphoto2]] or a file manager with gvfs support like [[PCManFM]]. }}<br />
<br />
First edit your {{ic|/etc/fuse.conf}} and uncomment the following line:<br />
user_allow_other<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
$ mtpfs -o allow_other ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== jmtpfs ===<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ jmtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
Make this cohere to the rest of Linux (use regular mount/umount commands) by doing two steps<br />
<br />
$# ln -s <actual mount command's path/name> <a name consistent with Linux's mount convention><br />
$ ln -s /sbin/jmtpfs /sbin/mount.jmtpfs<br />
<br />
add this line to /etc/fstab; <br />
<br />
#jmtpfs <mount path> fuse nodev,allow_other,<other options> 0 0<br />
jmtpfs /home/sam/run/motog fuse nodev,allow_other,rw,user,noauto,noatime,uid=1000,gid=1000 0 0<br />
<br />
Now mount the device and see if the options "took"<br />
<br />
$ mount /home/sam/run/motog<br />
Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).<br />
Android device detected, assigning default bug flags<br />
$ mount <br />
...<br />
jmtpfs on /home/sam/run/motog type fuse.jmtpfs (rw,nosuid,nodev,noexec,noatime,user_id=1000,group_id=1000,allow_other,user=sam)<br />
<br />
=== go-mtpfs ===<br />
<br />
{{Note|Mounting with {{ic|go-mtpfs}} might fail if an external SD Card is present. If you try to access your device while having an SD card and go-mtpfs complains, try removing the SD card and mounting again.}}<br />
<br />
Install {{Pkg|android-udev}}, which will allow you to edit {{ic|/etc/udev/rules.d/51-android.rules}} and apply to your {{ic|idVendor}} and {{ic|idProduct}}, which you can see after running ''mtp-detect''. To the end of the line, add your user {{ic|<nowiki>OWNER="<user>"</nowiki>}}.<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ go-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== simple-mtpfs ===<br />
<br />
List MTP devices:<br />
<br />
$ simple-mtpfs --list-devices<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
<br />
$ simple-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== Android File Transfer ===<br />
<br />
;FUSE interface<br />
<br />
Mount your device on {{ic|~/my-device}}:<br />
$ mkdir ~/my-device<br />
$ aft-mtp-mount ~/my-device<br />
<br />
If you want album art to be displayed, it must be named {{ic|albumart.xxx}} and placed first in the destination folder. Then copy other files. Also, note that fuse could be 7-8 times slower than ui/cli file transfer.<br />
<br />
Unmount device mounted on {{ic|~/my-device}}:<br />
<br />
$ fusermount -u ~/my-device<br />
<br />
;Qt user interface<br />
<br />
Start the application, choose a destination folder and click any button on the toolbar. Available options are: ''Upload Album'', ''Upload Directory'' and ''Upload Files''. The latter two are self-explanatory. ''Upload album'' searches the source directory for album covers, and sets the best available cover.<br />
<br />
=== Media players ===<br />
<br />
You can also use your MTP device in music players such as Amarok. To achieve this, you might have to edit {{ic|/etc/udev/rules.d/51-android.rules}} (the MTP device used in the following example is a Galaxy Nexus). <br />
Run:<br />
<br />
$ lsusb<br />
<br />
Search for your device. It should be something like that:<br />
Bus 003 Device 011: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-P7500 [Galaxy Tab 10.1]<br />
<br />
And entry to {{ic|/etc/udev/rules.d/51-android.rules}} will be this:<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="[username]"<br />
<br />
Also reload udev rules:<br />
# udevadm control --reload<br />
<br />
== Troubleshooting ==<br />
<br />
=== libmtp ===<br />
<br />
==== Unknown device ====<br />
<br />
If you see a message like:<br />
<br />
Device 0 (VID=XXXX and PID=XXXX) is UNKNOWN.<br />
Please report this VID/PID and the device model to the libmtp development team<br />
<br />
You should check whether your device is listed in the [http://sourceforge.net/p/libmtp/code/ci/HEAD/tree/src/music-players.h supported devices list]. If it is not, you should report it to the developers team. If it is, your {{ic|libmtp}} might be slightly outdated. To allow it to be properly used by {{ic|libmtp}}, you can add your device to:<br />
<br />
/etc/udev/rules.d/69-libmtp.rules<br />
<br />
==== Unable to enumerate USB device ====<br />
{{Deletion|This should be an old kernel bug, and should have been fixed already. There is no bug report to confirm though.}}<br />
{{Merge||Unrelated to MTP, perhaps suited for [[USB storage devices]]}}<br />
<br />
If you see a message like this in system log ({{ic|journalctl}})<br />
<br />
usb usb4-port2: unable to enumerate USB device<br />
<br />
You can try following temporary [https://bbs.archlinux.org/viewtopic.php?pid=1087323#p1087323 workaround]<br />
<br />
# modprobe -vr uhci_hcd<br />
# modprobe -va ohci_hcd<br />
# modprobe -va uhci_hcd<br />
<br />
If it works you should create {{ic|/etc/modprobe.d/usb_hci_order.conf}} with following content<br />
<br />
# create a dependency on ohci for uhci, which fixes problems<br />
# with external usb devices not showing up<br />
#<br />
softdep uhci_hcd pre: ohci_hcd<br />
<br />
=== jmtpfs ===<br />
<br />
==== Input/output error upon first access ====<br />
<br />
Symptoms: jmtpfs successfully mounts, but as soon as one attempts to access files on the device (e.g. via {{ic|ls}}), an error is reported:<br />
<br />
cannot access <mount-point>: Input/output error<br />
<br />
This appears to be a security feature: MTP does not work when the phone is locked by the lockscreen. Unlock the phone and it should work again as long as the cord remains connected.<br />
<br />
=== gvfs-mtp ===<br />
<br />
{{Merge|udev}}<br />
<br />
The {{Pkg|gvfs-mtp}} is available in the official repositories.<br />
<br />
With {{ic|lsusb}} you can get information about your device where Bus and Device numbers can be used with {{ic|gvfs-mtp}} and device ID for creating of an [[udev]] rule.<br />
Bus '''001''' Device '''007''': ID '''0421:0661''' Nokia Mobile Phones Lumia 920<br />
(...)<br />
<br />
To see detected device with enabled MTP<br />
<br />
Use ''gvfs-mount'':<br />
<br />
{{hc|<NOWIKI>gvfs-mount -li | grep -e ^Volume -e activation_root</NOWIKI>|2=<br />
Volume(0): MT65xx Android Phone<br />
activation_root=mtp://[usb:002,018]/<br />
}}<br />
<br />
Use ''lsusb'':<br />
<br />
{{hc|<NOWIKI>lsusb -v 2> /dev/null | grep -e Bus -e iInterface -e bInterfaceProtocol</NOWIKI>|<br />
(......<br />
......)<br />
Bus 002 Device 018: ID 04b7:88a9 Compal Electronics, Inc. <br />
bInterfaceProtocol 0 <br />
iInterface 5 MTP<br />
(......<br />
......)<br />
}}<br />
<br />
To mount all available connected MTP devices use inline script<br />
<br />
gvfs-mount -li | awk -F= '{if(index($2,"mtp") == 1)system("gvfs-mount "$2)}'<br />
<br />
To mount or dismount from a command with gvfs-mtp use Bus and Device numbers, e.g. to mount {{ic|gvfs-mount mtp://[usb:001,007]/}} and to unmount {{ic|gvfs-mount -u mtp://[usb:001,007]/}}. The mounted device will be available in a directory that begins with ''mtp:host='' and is located under ''/run/user/$UID/gvfs/''.<br />
<br />
Disable automount of MTP devises with gvfs you will need to change value ''true'' to ''false'' for variable ''AutoMount'' that is located in {{ic|/usr/share/gvfs/mounts/mtp.mount}}.<br />
<br />
{{Note|The file managers can have own options for automount. On start they checking for all available mountable devices.}}<br />
<br />
If your device does not show up in the file manager, you might need to reboot or write a udev rule in order to auto-mount the device.<br />
<br />
Plug your device and get the vendor-id and product-id,respectively:<br />
<br />
Use ID number that represents by pattern ''vendorId'':''productID'' and make an udev rule by creating a configuration file<br />
<br />
{{hc|/etc/udev/rules.d/51-android.rules|<NOWIKI><br />
ATTR{idVendor}=="YOUR VENDOR ID HERE", ATTR{idProduct}=="YOUR PRODUCT ID HERE", SYMLINK+="libmtp", MODE="660", ENV{ID_MTP_DEVICE}="1"<br />
</NOWIKI>}}<br />
Reload the udev rules.<br />
<br />
# udevadm control --reload<br />
<br />
And reboot the system. Now file managers (like Thunar) should be able to automount the MTP Device. [https://bbs.archlinux.org/viewtopic.php?id=180719]<br />
<br />
=== kio-mtp ===<br />
<br />
If you are not able to use the action "Open with File Manager", you may work around this problem by editing the file {{ic|/usr/share/apps/solid/actions/solid_mtp.desktop}}.<br />
<br />
Change the line<br />
<br />
Exec=kioclient exec mtp:udi=%i/<br />
<br />
To<br />
<br />
Exec=dolphin "mtp:/"</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Media_Transfer_Protocol&diff=446918Media Transfer Protocol2016-08-17T19:05:58Z<p>Andy Crowd: /* gvfs-mtp */ updated description, moved gvfs-mtp from bottom up, rewrote about lsusb and moved it to the top.</p>
<hr />
<div>[[Category:Storage]]<br />
[[Category:Mobile devices]]<br />
[[fa:MTP]]<br />
[[ja:MTP]]<br />
[[ru:MTP]]<br />
[[zh-CN:MTP]]<br />
{{Related articles start}}<br />
{{Related|USB storage devices}}<br />
{{Related articles end}}<br />
[[Wikipedia:Media_Transfer_Protocol|MTP]], or the ''Media Transfer Protocol'', is a USB device class which is used by many mobile phones (e.g. Samsung Galaxy S4) and media players (e.g. Creative Zen).<br />
<br />
== Installation ==<br />
<br />
=== Functionality ===<br />
<br />
Linux MTP support is provided by [[installing]] the {{Pkg|libmtp}} package. It can be installed on its own and used to access devices. However, a number of packages are available that use it as a dependency and add additional convenience (e.g. filemanager) functionalities and compatibility with particular device types - which includes improving transfer access speeds. <br />
<br />
These packages to choose from all implement a [[Wikipedia:Filesystem in Userspace]]: <br />
<br />
* {{Pkg|mtpfs}}<br />
* {{AUR|jmtpfs}} - is reported to work well for newer Android 4+ devices <br />
* {{AUR|go-mtpfs-git}} - is reported to work well for newer Android 3+ devices <br />
* {{AUR|simple-mtpfs}}<br />
* {{Pkg|android-file-transfer}} - MTP client with minimalistic UI<br />
<br />
All of them aim at better functionality and performance over {{ic|libmtp}}. Since there are a lot of different USB devices, you might want to research first which one looks most suitable for yours. <br />
<br />
{{Tip|It is recommended to reboot your computer after installing MTP related packages.}}<br />
<br />
=== Integration with file managers ===<br />
<br />
To view the contents of your Android device's storage via MTP in your file manager, install the corresponding plugin:<br />
<br />
* For file managers that use [[GVFS]] (GNOME Files), install {{Pkg|gvfs-mtp}} for MTP or {{Pkg|gvfs-gphoto2}} for PTP support.<br />
* For file managers that use KIO (KDE's Dolphin), MTP support is included in {{Pkg|kio-extras}} (dependency of dolphin).<br />
<br />
After installing the required package, the device should show up in the file manager automatically and be accessible via an URL, for example {{ic|mtp://[usb:002,013]/}}.<br />
<br />
== Usage ==<br />
<br />
It might be required to create a mount-point directory first. The directory {{ic|~/mnt}} is used as an example below. Also do not forget to unlock your phone's screen before connecting it to the computer.<br />
<br />
=== libmtp ===<br />
<br />
Detect your device:<br />
<br />
# mtp-detect<br />
<br />
If an error is returned, see [[#libmtp 2|troubleshooting libmtp]]. <br />
<br />
{{Note|Your regular user must be in the {{ic|uucp}} [[users_and_groups#Example_adding_a_user|group]].}}<br />
<br />
Connect to your device:<br />
# mtp-connect<br />
<br />
If connection is successful, there are several switch options to use in conjunction with ''mtp-connect'' to access data on the device. You might want to use some stand alone commands:<br />
mtp-albumart mtp-emptyfolders mtp-getplaylist mtp-reset mtp-trexist<br />
mtp-albums mtp-files mtp-hotplug mtp-sendfile<br />
mtp-connect mtp-folders mtp-newfolder mtp-sendtr<br />
mtp-delfile mtp-format mtp-newplaylist mtp-thumb<br />
mtp-detect mtp-getfile mtp-playlists mtp-tracks<br />
<br />
=== mtpfs ===<br />
<br />
{{Note | The following is likely to not work and you might have to resort to [[Digital_Cameras#libgphoto2|gphoto2]] or a file manager with gvfs support like [[PCManFM]]. }}<br />
<br />
First edit your {{ic|/etc/fuse.conf}} and uncomment the following line:<br />
user_allow_other<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
$ mtpfs -o allow_other ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== jmtpfs ===<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ jmtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
Make this cohere to the rest of Linux (use regular mount/umount commands) by doing two steps<br />
<br />
$# ln -s <actual mount command's path/name> <a name consistent with Linux's mount convention><br />
$ ln -s /sbin/jmtpfs /sbin/mount.jmtpfs<br />
<br />
add this line to /etc/fstab; <br />
<br />
#jmtpfs <mount path> fuse nodev,allow_other,<other options> 0 0<br />
jmtpfs /home/sam/run/motog fuse nodev,allow_other,rw,user,noauto,noatime,uid=1000,gid=1000 0 0<br />
<br />
Now mount the device and see if the options "took"<br />
<br />
$ mount /home/sam/run/motog<br />
Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).<br />
Android device detected, assigning default bug flags<br />
$ mount <br />
...<br />
jmtpfs on /home/sam/run/motog type fuse.jmtpfs (rw,nosuid,nodev,noexec,noatime,user_id=1000,group_id=1000,allow_other,user=sam)<br />
<br />
=== go-mtpfs ===<br />
<br />
{{Note|Mounting with {{ic|go-mtpfs}} might fail if an external SD Card is present. If you try to access your device while having an SD card and go-mtpfs complains, try removing the SD card and mounting again.}}<br />
<br />
Install {{Pkg|android-udev}}, which will allow you to edit {{ic|/etc/udev/rules.d/51-android.rules}} and apply to your {{ic|idVendor}} and {{ic|idProduct}}, which you can see after running ''mtp-detect''. To the end of the line, add your user {{ic|<nowiki>OWNER="<user>"</nowiki>}}.<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ go-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== simple-mtpfs ===<br />
<br />
List MTP devices:<br />
<br />
$ simple-mtpfs --list-devices<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
<br />
$ simple-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== Android File Transfer ===<br />
<br />
;FUSE interface<br />
<br />
Mount your device on {{ic|~/my-device}}:<br />
$ mkdir ~/my-device<br />
$ aft-mtp-mount ~/my-device<br />
<br />
If you want album art to be displayed, it must be named {{ic|albumart.xxx}} and placed first in the destination folder. Then copy other files. Also, note that fuse could be 7-8 times slower than ui/cli file transfer.<br />
<br />
Unmount device mounted on {{ic|~/my-device}}:<br />
<br />
$ fusermount -u ~/my-device<br />
<br />
;Qt user interface<br />
<br />
Start the application, choose a destination folder and click any button on the toolbar. Available options are: ''Upload Album'', ''Upload Directory'' and ''Upload Files''. The latter two are self-explanatory. ''Upload album'' searches the source directory for album covers, and sets the best available cover.<br />
<br />
=== Media players ===<br />
<br />
You can also use your MTP device in music players such as Amarok. To achieve this, you might have to edit {{ic|/etc/udev/rules.d/51-android.rules}} (the MTP device used in the following example is a Galaxy Nexus). <br />
Run:<br />
<br />
$ lsusb<br />
<br />
Search for your device. It should be something like that:<br />
Bus 003 Device 011: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-P7500 [Galaxy Tab 10.1]<br />
<br />
And entry to {{ic|/etc/udev/rules.d/51-android.rules}} will be this:<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="[username]"<br />
<br />
Also reload udev rules:<br />
# udevadm control --reload<br />
<br />
== Troubleshooting ==<br />
<br />
=== libmtp ===<br />
<br />
==== Unknown device ====<br />
<br />
If you see a message like:<br />
<br />
Device 0 (VID=XXXX and PID=XXXX) is UNKNOWN.<br />
Please report this VID/PID and the device model to the libmtp development team<br />
<br />
You should check whether your device is listed in the [http://sourceforge.net/p/libmtp/code/ci/HEAD/tree/src/music-players.h supported devices list]. If it is not, you should report it to the developers team. If it is, your {{ic|libmtp}} might be slightly outdated. To allow it to be properly used by {{ic|libmtp}}, you can add your device to:<br />
<br />
/etc/udev/rules.d/69-libmtp.rules<br />
<br />
==== Unable to enumerate USB device ====<br />
{{Deletion|This should be an old kernel bug, and should have been fixed already. There is no bug report to confirm though.}}<br />
{{Merge||Unrelated to MTP, perhaps suited for [[USB storage devices]]}}<br />
<br />
If you see a message like this in system log ({{ic|journalctl}})<br />
<br />
usb usb4-port2: unable to enumerate USB device<br />
<br />
You can try following temporary [https://bbs.archlinux.org/viewtopic.php?pid=1087323#p1087323 workaround]<br />
<br />
# modprobe -vr uhci_hcd<br />
# modprobe -va ohci_hcd<br />
# modprobe -va uhci_hcd<br />
<br />
If it works you should create {{ic|/etc/modprobe.d/usb_hci_order.conf}} with following content<br />
<br />
# create a dependency on ohci for uhci, which fixes problems<br />
# with external usb devices not showing up<br />
#<br />
softdep uhci_hcd pre: ohci_hcd<br />
<br />
=== jmtpfs ===<br />
<br />
==== Input/output error upon first access ====<br />
<br />
Symptoms: jmtpfs successfully mounts, but as soon as one attempts to access files on the device (e.g. via {{ic|ls}}), an error is reported:<br />
<br />
cannot access <mount-point>: Input/output error<br />
<br />
This appears to be a security feature: MTP does not work when the phone is locked by the lockscreen. Unlock the phone and it should work again as long as the cord remains connected.<br />
<br />
=== gvfs-mtp ===<br />
<br />
{{Merge|udev}}<br />
<br />
The {{Pkg|gvfs-mtp}} is available in the official repositories.<br />
<br />
With {{ic|lsusb}} you can get information about your device where Bus and Device numbers can be used with {{ic|gvfs-mtp}} and device ID for creating of an [[udev]] rule.<br />
Bus '''001''' Device '''007''': ID '''0421:0661''' Nokia Mobile Phones Lumia 920<br />
(...)<br />
<br />
To see if gvfs can detect your connected device with enabled MTP<br />
<br />
{{ic|<NOWIKI>gvfs-mount -l | grep -e Phone -e MTP</NOWIKI>}}.<br />
<br />
To mount all available connected MTP devices use inline script<br />
<br />
gvfs-mount -li | awk -F= '{if(index($2,"mtp") == 1)system("gvfs-mount "$2)}'<br />
<br />
To mount or dismount from a command with gvfs-mtp use Bus and Device numbers, e.g. to mount {{ic|gvfs-mount mtp://[usb:001,007]/}} and to unmount {{ic|gvfs-mount -u mtp://[usb:001,007]/}}. The mounted device will be available in a directory that begins with ''mtp:host='' and is located under ''/run/user/$UID/gvfs/''.<br />
<br />
Disable automount of MTP devises with gvfs you will need to change value ''true'' to ''false'' for variable ''AutoMount'' that is located in {{ic|/usr/share/gvfs/mounts/mtp.mount}}.<br />
<br />
{{Note|The file managers can have own options for automount. On start they checking for all available mountable devices.}}<br />
<br />
If your device does not show up in the file manager, you might need to reboot or write a udev rule in order to auto-mount the device.<br />
<br />
Plug your device and get the vendor-id and product-id,respectively:<br />
<br />
Use ID number that represents by pattern ''vendorId'':''productID'' and make an udev rule by creating a configuration file<br />
<br />
{{hc|/etc/udev/rules.d/51-android.rules|<NOWIKI><br />
ATTR{idVendor}=="YOUR VENDOR ID HERE", ATTR{idProduct}=="YOUR PRODUCT ID HERE", SYMLINK+="libmtp", MODE="660", ENV{ID_MTP_DEVICE}="1"<br />
</NOWIKI>}}<br />
Reload the udev rules.<br />
<br />
# udevadm control --reload<br />
<br />
And reboot the system. Now file managers (like Thunar) should be able to automount the MTP Device. [https://bbs.archlinux.org/viewtopic.php?id=180719]<br />
<br />
=== kio-mtp ===<br />
<br />
If you are not able to use the action "Open with File Manager", you may work around this problem by editing the file {{ic|/usr/share/apps/solid/actions/solid_mtp.desktop}}.<br />
<br />
Change the line<br />
<br />
Exec=kioclient exec mtp:udi=%i/<br />
<br />
To<br />
<br />
Exec=dolphin "mtp:/"</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Media_Transfer_Protocol&diff=446915Media Transfer Protocol2016-08-17T18:51:19Z<p>Andy Crowd: /* gvfs-mtp */ removed about "alias", not working well</p>
<hr />
<div>[[Category:Storage]]<br />
[[Category:Mobile devices]]<br />
[[fa:MTP]]<br />
[[ja:MTP]]<br />
[[ru:MTP]]<br />
[[zh-CN:MTP]]<br />
{{Related articles start}}<br />
{{Related|USB storage devices}}<br />
{{Related articles end}}<br />
[[Wikipedia:Media_Transfer_Protocol|MTP]], or the ''Media Transfer Protocol'', is a USB device class which is used by many mobile phones (e.g. Samsung Galaxy S4) and media players (e.g. Creative Zen).<br />
<br />
== Installation ==<br />
<br />
=== Functionality ===<br />
<br />
Linux MTP support is provided by [[installing]] the {{Pkg|libmtp}} package. It can be installed on its own and used to access devices. However, a number of packages are available that use it as a dependency and add additional convenience (e.g. filemanager) functionalities and compatibility with particular device types - which includes improving transfer access speeds. <br />
<br />
These packages to choose from all implement a [[Wikipedia:Filesystem in Userspace]]: <br />
<br />
* {{Pkg|mtpfs}}<br />
* {{AUR|jmtpfs}} - is reported to work well for newer Android 4+ devices <br />
* {{AUR|go-mtpfs-git}} - is reported to work well for newer Android 3+ devices <br />
* {{AUR|simple-mtpfs}}<br />
* {{Pkg|android-file-transfer}} - MTP client with minimalistic UI<br />
<br />
All of them aim at better functionality and performance over {{ic|libmtp}}. Since there are a lot of different USB devices, you might want to research first which one looks most suitable for yours. <br />
<br />
{{Tip|It is recommended to reboot your computer after installing MTP related packages.}}<br />
<br />
=== Integration with file managers ===<br />
<br />
To view the contents of your Android device's storage via MTP in your file manager, install the corresponding plugin:<br />
<br />
* For file managers that use [[GVFS]] (GNOME Files), install {{Pkg|gvfs-mtp}} for MTP or {{Pkg|gvfs-gphoto2}} for PTP support.<br />
* For file managers that use KIO (KDE's Dolphin), MTP support is included in {{Pkg|kio-extras}} (dependency of dolphin).<br />
<br />
After installing the required package, the device should show up in the file manager automatically and be accessible via an URL, for example {{ic|mtp://[usb:002,013]/}}.<br />
<br />
== Usage ==<br />
<br />
It might be required to create a mount-point directory first. The directory {{ic|~/mnt}} is used as an example below. Also do not forget to unlock your phone's screen before connecting it to the computer.<br />
<br />
=== libmtp ===<br />
<br />
Detect your device:<br />
<br />
# mtp-detect<br />
<br />
If an error is returned, see [[#libmtp 2|troubleshooting libmtp]]. <br />
<br />
{{Note|Your regular user must be in the {{ic|uucp}} [[users_and_groups#Example_adding_a_user|group]].}}<br />
<br />
Connect to your device:<br />
# mtp-connect<br />
<br />
If connection is successful, there are several switch options to use in conjunction with ''mtp-connect'' to access data on the device. You might want to use some stand alone commands:<br />
mtp-albumart mtp-emptyfolders mtp-getplaylist mtp-reset mtp-trexist<br />
mtp-albums mtp-files mtp-hotplug mtp-sendfile<br />
mtp-connect mtp-folders mtp-newfolder mtp-sendtr<br />
mtp-delfile mtp-format mtp-newplaylist mtp-thumb<br />
mtp-detect mtp-getfile mtp-playlists mtp-tracks<br />
<br />
=== mtpfs ===<br />
<br />
{{Note | The following is likely to not work and you might have to resort to [[Digital_Cameras#libgphoto2|gphoto2]] or a file manager with gvfs support like [[PCManFM]]. }}<br />
<br />
First edit your {{ic|/etc/fuse.conf}} and uncomment the following line:<br />
user_allow_other<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
$ mtpfs -o allow_other ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== jmtpfs ===<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ jmtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
Make this cohere to the rest of Linux (use regular mount/umount commands) by doing two steps<br />
<br />
$# ln -s <actual mount command's path/name> <a name consistent with Linux's mount convention><br />
$ ln -s /sbin/jmtpfs /sbin/mount.jmtpfs<br />
<br />
add this line to /etc/fstab; <br />
<br />
#jmtpfs <mount path> fuse nodev,allow_other,<other options> 0 0<br />
jmtpfs /home/sam/run/motog fuse nodev,allow_other,rw,user,noauto,noatime,uid=1000,gid=1000 0 0<br />
<br />
Now mount the device and see if the options "took"<br />
<br />
$ mount /home/sam/run/motog<br />
Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).<br />
Android device detected, assigning default bug flags<br />
$ mount <br />
...<br />
jmtpfs on /home/sam/run/motog type fuse.jmtpfs (rw,nosuid,nodev,noexec,noatime,user_id=1000,group_id=1000,allow_other,user=sam)<br />
<br />
=== go-mtpfs ===<br />
<br />
{{Note|Mounting with {{ic|go-mtpfs}} might fail if an external SD Card is present. If you try to access your device while having an SD card and go-mtpfs complains, try removing the SD card and mounting again.}}<br />
<br />
Install {{Pkg|android-udev}}, which will allow you to edit {{ic|/etc/udev/rules.d/51-android.rules}} and apply to your {{ic|idVendor}} and {{ic|idProduct}}, which you can see after running ''mtp-detect''. To the end of the line, add your user {{ic|<nowiki>OWNER="<user>"</nowiki>}}.<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ go-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== simple-mtpfs ===<br />
<br />
List MTP devices:<br />
<br />
$ simple-mtpfs --list-devices<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
<br />
$ simple-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== Android File Transfer ===<br />
<br />
;FUSE interface<br />
<br />
Mount your device on {{ic|~/my-device}}:<br />
$ mkdir ~/my-device<br />
$ aft-mtp-mount ~/my-device<br />
<br />
If you want album art to be displayed, it must be named {{ic|albumart.xxx}} and placed first in the destination folder. Then copy other files. Also, note that fuse could be 7-8 times slower than ui/cli file transfer.<br />
<br />
Unmount device mounted on {{ic|~/my-device}}:<br />
<br />
$ fusermount -u ~/my-device<br />
<br />
;Qt user interface<br />
<br />
Start the application, choose a destination folder and click any button on the toolbar. Available options are: ''Upload Album'', ''Upload Directory'' and ''Upload Files''. The latter two are self-explanatory. ''Upload album'' searches the source directory for album covers, and sets the best available cover.<br />
<br />
=== Media players ===<br />
<br />
You can also use your MTP device in music players such as Amarok. To achieve this, you might have to edit {{ic|/etc/udev/rules.d/51-android.rules}} (the MTP device used in the following example is a Galaxy Nexus). <br />
Run:<br />
<br />
$ lsusb<br />
<br />
Search for your device. It should be something like that:<br />
Bus 003 Device 011: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-P7500 [Galaxy Tab 10.1]<br />
<br />
And entry to {{ic|/etc/udev/rules.d/51-android.rules}} will be this:<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="[username]"<br />
<br />
Also reload udev rules:<br />
# udevadm control --reload<br />
<br />
== Troubleshooting ==<br />
<br />
=== libmtp ===<br />
<br />
==== Unknown device ====<br />
<br />
If you see a message like:<br />
<br />
Device 0 (VID=XXXX and PID=XXXX) is UNKNOWN.<br />
Please report this VID/PID and the device model to the libmtp development team<br />
<br />
You should check whether your device is listed in the [http://sourceforge.net/p/libmtp/code/ci/HEAD/tree/src/music-players.h supported devices list]. If it is not, you should report it to the developers team. If it is, your {{ic|libmtp}} might be slightly outdated. To allow it to be properly used by {{ic|libmtp}}, you can add your device to:<br />
<br />
/etc/udev/rules.d/69-libmtp.rules<br />
<br />
==== Unable to enumerate USB device ====<br />
{{Deletion|This should be an old kernel bug, and should have been fixed already. There is no bug report to confirm though.}}<br />
{{Merge||Unrelated to MTP, perhaps suited for [[USB storage devices]]}}<br />
<br />
If you see a message like this in system log ({{ic|journalctl}})<br />
<br />
usb usb4-port2: unable to enumerate USB device<br />
<br />
You can try following temporary [https://bbs.archlinux.org/viewtopic.php?pid=1087323#p1087323 workaround]<br />
<br />
# modprobe -vr uhci_hcd<br />
# modprobe -va ohci_hcd<br />
# modprobe -va uhci_hcd<br />
<br />
If it works you should create {{ic|/etc/modprobe.d/usb_hci_order.conf}} with following content<br />
<br />
# create a dependency on ohci for uhci, which fixes problems<br />
# with external usb devices not showing up<br />
#<br />
softdep uhci_hcd pre: ohci_hcd<br />
<br />
=== jmtpfs ===<br />
<br />
==== Input/output error upon first access ====<br />
<br />
Symptoms: jmtpfs successfully mounts, but as soon as one attempts to access files on the device (e.g. via {{ic|ls}}), an error is reported:<br />
<br />
cannot access <mount-point>: Input/output error<br />
<br />
This appears to be a security feature: MTP does not work when the phone is locked by the lockscreen. Unlock the phone and it should work again as long as the cord remains connected.<br />
<br />
=== gvfs-mtp ===<br />
<br />
{{Merge|udev}}<br />
<br />
To see if gvfs can detect your connected device with enabled MTP<br />
<br />
{{ic|<NOWIKI>gvfs-mount -l | grep -e Phone -e MTP</NOWIKI>}}.<br />
<br />
To mount all available connected MTP devices use inline script<br />
<br />
gvfs-mount -li | awk -F= '{if(index($2,"mtp") == 1)system("gvfs-mount "$2)}'<br />
<br />
If you have installed the {{Pkg|gvfs-mtp}} package, and your device does not show up in the file manager, you might need to reboot or write a udev rule in order to auto-mount the device.<br />
<br />
Plug your device and get the vendor-id and product-id,respectively:<br />
<br />
$ lsusb<br />
Bus 001 Device 007: ID 0421:0661 Nokia Mobile Phones Lumia 920<br />
(...)<br />
<br />
Use ID number that represents by pattern ''vendorId'':''productID'' and make an udev rule by creating a configuration file<br />
<br />
{{hc|/etc/udev/rules.d/51-android.rules|<NOWIKI><br />
ATTR{idVendor}=="YOUR VENDOR ID HERE", ATTR{idProduct}=="YOUR PRODUCT ID HERE", SYMLINK+="libmtp", MODE="660", ENV{ID_MTP_DEVICE}="1"<br />
</NOWIKI>}}<br />
Reload the udev rules.<br />
<br />
# udevadm control --reload<br />
<br />
And reboot the system. Now file managers (like Thunar) should be able to automount the MTP Device. [https://bbs.archlinux.org/viewtopic.php?id=180719]<br />
<br />
To mount or dismount from a command with gvfs-mtp use Bus and Device numbers, e.g. to mount {{ic|gvfs-mount mtp://[usb:001,007]/}} and to unmount {{ic|gvfs-mount -u mtp://[usb:001,007]/}}. The mounted device will be available in a directory that begins with ''mtp:host='' and is located under ''/run/user/$UID/gvfs/''.<br />
<br />
Disable automount of MTP devises with gvfs you will need to change value ''true'' to ''false'' for variable ''AutoMount'' that is located in {{ic|/usr/share/gvfs/mounts/mtp.mount}}.<br />
<br />
{{Note|The file managers can have own options for automount. On start they checking for all available mountable devices.}}<br />
<br />
=== kio-mtp ===<br />
<br />
If you are not able to use the action "Open with File Manager", you may work around this problem by editing the file {{ic|/usr/share/apps/solid/actions/solid_mtp.desktop}}.<br />
<br />
Change the line<br />
<br />
Exec=kioclient exec mtp:udi=%i/<br />
<br />
To<br />
<br />
Exec=dolphin "mtp:/"</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Talk:Media_Transfer_Protocol&diff=446912Talk:Media Transfer Protocol2016-08-17T18:29:42Z<p>Andy Crowd: re:</p>
<hr />
<div>== Custom udev rules and rebooting ==<br />
<br />
In a couple of places {{ic|/usr/lib/udev/rules.d/}} is used as location for custom {{ic|udev}} rules. Isn't the {{ic|/etc/udev/rules.d/}} a better place for them? If so I propose to change {{ic|/usr/lib/udev/rules.d/}} to {{ic|/etc/udev/rules.d/}}.<br />
<br />
Also, there's no need for rebooting the system, as suggested in [[MTP#gvfs-mtp troubleshooting]]. What is that? A Windows? ;} I think this should be removed or changed to some other means like “relogging”.<br />
<br />
--thebodzio 22:34, 29 December 2014 (UTC)<br />
<br />
:Yes to both, [[Udev#About udev rules]] and [[Udev#Loading new rules]]. -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 01:39, 31 December 2014 (UTC)<br />
<br />
:: May be it must be removed "This article or section is a candidate for merging with udev."? I have added more related info to gvfs-mtp but not related to udev, I think that it is good if will stay here as it is. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:28, 17 August 2016 (UTC)).</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Media_Transfer_Protocol&diff=446908Media Transfer Protocol2016-08-17T18:22:35Z<p>Andy Crowd: /* gvfs-mtp */ added info about how to mount all connected MTP devices with inline script that can also be used as e.g. alias</p>
<hr />
<div>[[Category:Storage]]<br />
[[Category:Mobile devices]]<br />
[[fa:MTP]]<br />
[[ja:MTP]]<br />
[[ru:MTP]]<br />
[[zh-CN:MTP]]<br />
{{Related articles start}}<br />
{{Related|USB storage devices}}<br />
{{Related articles end}}<br />
[[Wikipedia:Media_Transfer_Protocol|MTP]], or the ''Media Transfer Protocol'', is a USB device class which is used by many mobile phones (e.g. Samsung Galaxy S4) and media players (e.g. Creative Zen).<br />
<br />
== Installation ==<br />
<br />
=== Functionality ===<br />
<br />
Linux MTP support is provided by [[installing]] the {{Pkg|libmtp}} package. It can be installed on its own and used to access devices. However, a number of packages are available that use it as a dependency and add additional convenience (e.g. filemanager) functionalities and compatibility with particular device types - which includes improving transfer access speeds. <br />
<br />
These packages to choose from all implement a [[Wikipedia:Filesystem in Userspace]]: <br />
<br />
* {{Pkg|mtpfs}}<br />
* {{AUR|jmtpfs}} - is reported to work well for newer Android 4+ devices <br />
* {{AUR|go-mtpfs-git}} - is reported to work well for newer Android 3+ devices <br />
* {{AUR|simple-mtpfs}}<br />
* {{Pkg|android-file-transfer}} - MTP client with minimalistic UI<br />
<br />
All of them aim at better functionality and performance over {{ic|libmtp}}. Since there are a lot of different USB devices, you might want to research first which one looks most suitable for yours. <br />
<br />
{{Tip|It is recommended to reboot your computer after installing MTP related packages.}}<br />
<br />
=== Integration with file managers ===<br />
<br />
To view the contents of your Android device's storage via MTP in your file manager, install the corresponding plugin:<br />
<br />
* For file managers that use [[GVFS]] (GNOME Files), install {{Pkg|gvfs-mtp}} for MTP or {{Pkg|gvfs-gphoto2}} for PTP support.<br />
* For file managers that use KIO (KDE's Dolphin), MTP support is included in {{Pkg|kio-extras}} (dependency of dolphin).<br />
<br />
After installing the required package, the device should show up in the file manager automatically and be accessible via an URL, for example {{ic|mtp://[usb:002,013]/}}.<br />
<br />
== Usage ==<br />
<br />
It might be required to create a mount-point directory first. The directory {{ic|~/mnt}} is used as an example below. Also do not forget to unlock your phone's screen before connecting it to the computer.<br />
<br />
=== libmtp ===<br />
<br />
Detect your device:<br />
<br />
# mtp-detect<br />
<br />
If an error is returned, see [[#libmtp 2|troubleshooting libmtp]]. <br />
<br />
{{Note|Your regular user must be in the {{ic|uucp}} [[users_and_groups#Example_adding_a_user|group]].}}<br />
<br />
Connect to your device:<br />
# mtp-connect<br />
<br />
If connection is successful, there are several switch options to use in conjunction with ''mtp-connect'' to access data on the device. You might want to use some stand alone commands:<br />
mtp-albumart mtp-emptyfolders mtp-getplaylist mtp-reset mtp-trexist<br />
mtp-albums mtp-files mtp-hotplug mtp-sendfile<br />
mtp-connect mtp-folders mtp-newfolder mtp-sendtr<br />
mtp-delfile mtp-format mtp-newplaylist mtp-thumb<br />
mtp-detect mtp-getfile mtp-playlists mtp-tracks<br />
<br />
=== mtpfs ===<br />
<br />
{{Note | The following is likely to not work and you might have to resort to [[Digital_Cameras#libgphoto2|gphoto2]] or a file manager with gvfs support like [[PCManFM]]. }}<br />
<br />
First edit your {{ic|/etc/fuse.conf}} and uncomment the following line:<br />
user_allow_other<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
$ mtpfs -o allow_other ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== jmtpfs ===<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ jmtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
Make this cohere to the rest of Linux (use regular mount/umount commands) by doing two steps<br />
<br />
$# ln -s <actual mount command's path/name> <a name consistent with Linux's mount convention><br />
$ ln -s /sbin/jmtpfs /sbin/mount.jmtpfs<br />
<br />
add this line to /etc/fstab; <br />
<br />
#jmtpfs <mount path> fuse nodev,allow_other,<other options> 0 0<br />
jmtpfs /home/sam/run/motog fuse nodev,allow_other,rw,user,noauto,noatime,uid=1000,gid=1000 0 0<br />
<br />
Now mount the device and see if the options "took"<br />
<br />
$ mount /home/sam/run/motog<br />
Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).<br />
Android device detected, assigning default bug flags<br />
$ mount <br />
...<br />
jmtpfs on /home/sam/run/motog type fuse.jmtpfs (rw,nosuid,nodev,noexec,noatime,user_id=1000,group_id=1000,allow_other,user=sam)<br />
<br />
=== go-mtpfs ===<br />
<br />
{{Note|Mounting with {{ic|go-mtpfs}} might fail if an external SD Card is present. If you try to access your device while having an SD card and go-mtpfs complains, try removing the SD card and mounting again.}}<br />
<br />
Install {{Pkg|android-udev}}, which will allow you to edit {{ic|/etc/udev/rules.d/51-android.rules}} and apply to your {{ic|idVendor}} and {{ic|idProduct}}, which you can see after running ''mtp-detect''. To the end of the line, add your user {{ic|<nowiki>OWNER="<user>"</nowiki>}}.<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ go-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== simple-mtpfs ===<br />
<br />
List MTP devices:<br />
<br />
$ simple-mtpfs --list-devices<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
<br />
$ simple-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== Android File Transfer ===<br />
<br />
;FUSE interface<br />
<br />
Mount your device on {{ic|~/my-device}}:<br />
$ mkdir ~/my-device<br />
$ aft-mtp-mount ~/my-device<br />
<br />
If you want album art to be displayed, it must be named {{ic|albumart.xxx}} and placed first in the destination folder. Then copy other files. Also, note that fuse could be 7-8 times slower than ui/cli file transfer.<br />
<br />
Unmount device mounted on {{ic|~/my-device}}:<br />
<br />
$ fusermount -u ~/my-device<br />
<br />
;Qt user interface<br />
<br />
Start the application, choose a destination folder and click any button on the toolbar. Available options are: ''Upload Album'', ''Upload Directory'' and ''Upload Files''. The latter two are self-explanatory. ''Upload album'' searches the source directory for album covers, and sets the best available cover.<br />
<br />
=== Media players ===<br />
<br />
You can also use your MTP device in music players such as Amarok. To achieve this, you might have to edit {{ic|/etc/udev/rules.d/51-android.rules}} (the MTP device used in the following example is a Galaxy Nexus). <br />
Run:<br />
<br />
$ lsusb<br />
<br />
Search for your device. It should be something like that:<br />
Bus 003 Device 011: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-P7500 [Galaxy Tab 10.1]<br />
<br />
And entry to {{ic|/etc/udev/rules.d/51-android.rules}} will be this:<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="[username]"<br />
<br />
Also reload udev rules:<br />
# udevadm control --reload<br />
<br />
== Troubleshooting ==<br />
<br />
=== libmtp ===<br />
<br />
==== Unknown device ====<br />
<br />
If you see a message like:<br />
<br />
Device 0 (VID=XXXX and PID=XXXX) is UNKNOWN.<br />
Please report this VID/PID and the device model to the libmtp development team<br />
<br />
You should check whether your device is listed in the [http://sourceforge.net/p/libmtp/code/ci/HEAD/tree/src/music-players.h supported devices list]. If it is not, you should report it to the developers team. If it is, your {{ic|libmtp}} might be slightly outdated. To allow it to be properly used by {{ic|libmtp}}, you can add your device to:<br />
<br />
/etc/udev/rules.d/69-libmtp.rules<br />
<br />
==== Unable to enumerate USB device ====<br />
{{Deletion|This should be an old kernel bug, and should have been fixed already. There is no bug report to confirm though.}}<br />
{{Merge||Unrelated to MTP, perhaps suited for [[USB storage devices]]}}<br />
<br />
If you see a message like this in system log ({{ic|journalctl}})<br />
<br />
usb usb4-port2: unable to enumerate USB device<br />
<br />
You can try following temporary [https://bbs.archlinux.org/viewtopic.php?pid=1087323#p1087323 workaround]<br />
<br />
# modprobe -vr uhci_hcd<br />
# modprobe -va ohci_hcd<br />
# modprobe -va uhci_hcd<br />
<br />
If it works you should create {{ic|/etc/modprobe.d/usb_hci_order.conf}} with following content<br />
<br />
# create a dependency on ohci for uhci, which fixes problems<br />
# with external usb devices not showing up<br />
#<br />
softdep uhci_hcd pre: ohci_hcd<br />
<br />
=== jmtpfs ===<br />
<br />
==== Input/output error upon first access ====<br />
<br />
Symptoms: jmtpfs successfully mounts, but as soon as one attempts to access files on the device (e.g. via {{ic|ls}}), an error is reported:<br />
<br />
cannot access <mount-point>: Input/output error<br />
<br />
This appears to be a security feature: MTP does not work when the phone is locked by the lockscreen. Unlock the phone and it should work again as long as the cord remains connected.<br />
<br />
=== gvfs-mtp ===<br />
<br />
{{Merge|udev}}<br />
<br />
To see if gvfs can detect your connected device with enabled MTP<br />
<br />
{{ic|<NOWIKI>gvfs-mount -l | grep -e Phone -e MTP</NOWIKI>}}.<br />
<br />
To mount all available connected MTP devices you can create an [http://ss64.com/bash/alias.html alias] for inline script<br />
<br />
gvfs-mount -li | awk -F= '{if(index($2,"mtp") == 1)system("gvfs-mount "$2)}'<br />
<br />
If you have installed the {{Pkg|gvfs-mtp}} package, and your device does not show up in the file manager, you might need to reboot or write a udev rule in order to auto-mount the device.<br />
<br />
Plug your device and get the vendor-id and product-id,respectively:<br />
<br />
$ lsusb<br />
Bus 001 Device 007: ID 0421:0661 Nokia Mobile Phones Lumia 920<br />
(...)<br />
<br />
Use ID number that represents by pattern ''vendorId'':''productID'' and make an udev rule by creating a configuration file<br />
<br />
{{hc|/etc/udev/rules.d/51-android.rules|<NOWIKI><br />
ATTR{idVendor}=="YOUR VENDOR ID HERE", ATTR{idProduct}=="YOUR PRODUCT ID HERE", SYMLINK+="libmtp", MODE="660", ENV{ID_MTP_DEVICE}="1"<br />
</NOWIKI>}}<br />
Reload the udev rules.<br />
<br />
# udevadm control --reload<br />
<br />
And reboot the system. Now file managers (like Thunar) should be able to automount the MTP Device. [https://bbs.archlinux.org/viewtopic.php?id=180719]<br />
<br />
To mount or dismount from a command with gvfs-mtp use Bus and Device numbers, e.g. to mount {{ic|gvfs-mount mtp://[usb:001,007]/}} and to unmount {{ic|gvfs-mount -u mtp://[usb:001,007]/}}. The mounted device will be available in a directory that begins with ''mtp:host='' and is located under ''/run/user/$UID/gvfs/''.<br />
<br />
Disable automount of MTP devises with gvfs you will need to change value ''true'' to ''false'' for variable ''AutoMount'' that is located in {{ic|/usr/share/gvfs/mounts/mtp.mount}}.<br />
<br />
{{Note|The file managers can have own options for automount. On start they checking for all available mountable devices.}}<br />
<br />
=== kio-mtp ===<br />
<br />
If you are not able to use the action "Open with File Manager", you may work around this problem by editing the file {{ic|/usr/share/apps/solid/actions/solid_mtp.desktop}}.<br />
<br />
Change the line<br />
<br />
Exec=kioclient exec mtp:udi=%i/<br />
<br />
To<br />
<br />
Exec=dolphin "mtp:/"</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Media_Transfer_Protocol&diff=446907Media Transfer Protocol2016-08-17T18:06:48Z<p>Andy Crowd: /* gvfs-mtp */ added description how to list connected MTP devices</p>
<hr />
<div>[[Category:Storage]]<br />
[[Category:Mobile devices]]<br />
[[fa:MTP]]<br />
[[ja:MTP]]<br />
[[ru:MTP]]<br />
[[zh-CN:MTP]]<br />
{{Related articles start}}<br />
{{Related|USB storage devices}}<br />
{{Related articles end}}<br />
[[Wikipedia:Media_Transfer_Protocol|MTP]], or the ''Media Transfer Protocol'', is a USB device class which is used by many mobile phones (e.g. Samsung Galaxy S4) and media players (e.g. Creative Zen).<br />
<br />
== Installation ==<br />
<br />
=== Functionality ===<br />
<br />
Linux MTP support is provided by [[installing]] the {{Pkg|libmtp}} package. It can be installed on its own and used to access devices. However, a number of packages are available that use it as a dependency and add additional convenience (e.g. filemanager) functionalities and compatibility with particular device types - which includes improving transfer access speeds. <br />
<br />
These packages to choose from all implement a [[Wikipedia:Filesystem in Userspace]]: <br />
<br />
* {{Pkg|mtpfs}}<br />
* {{AUR|jmtpfs}} - is reported to work well for newer Android 4+ devices <br />
* {{AUR|go-mtpfs-git}} - is reported to work well for newer Android 3+ devices <br />
* {{AUR|simple-mtpfs}}<br />
* {{Pkg|android-file-transfer}} - MTP client with minimalistic UI<br />
<br />
All of them aim at better functionality and performance over {{ic|libmtp}}. Since there are a lot of different USB devices, you might want to research first which one looks most suitable for yours. <br />
<br />
{{Tip|It is recommended to reboot your computer after installing MTP related packages.}}<br />
<br />
=== Integration with file managers ===<br />
<br />
To view the contents of your Android device's storage via MTP in your file manager, install the corresponding plugin:<br />
<br />
* For file managers that use [[GVFS]] (GNOME Files), install {{Pkg|gvfs-mtp}} for MTP or {{Pkg|gvfs-gphoto2}} for PTP support.<br />
* For file managers that use KIO (KDE's Dolphin), MTP support is included in {{Pkg|kio-extras}} (dependency of dolphin).<br />
<br />
After installing the required package, the device should show up in the file manager automatically and be accessible via an URL, for example {{ic|mtp://[usb:002,013]/}}.<br />
<br />
== Usage ==<br />
<br />
It might be required to create a mount-point directory first. The directory {{ic|~/mnt}} is used as an example below. Also do not forget to unlock your phone's screen before connecting it to the computer.<br />
<br />
=== libmtp ===<br />
<br />
Detect your device:<br />
<br />
# mtp-detect<br />
<br />
If an error is returned, see [[#libmtp 2|troubleshooting libmtp]]. <br />
<br />
{{Note|Your regular user must be in the {{ic|uucp}} [[users_and_groups#Example_adding_a_user|group]].}}<br />
<br />
Connect to your device:<br />
# mtp-connect<br />
<br />
If connection is successful, there are several switch options to use in conjunction with ''mtp-connect'' to access data on the device. You might want to use some stand alone commands:<br />
mtp-albumart mtp-emptyfolders mtp-getplaylist mtp-reset mtp-trexist<br />
mtp-albums mtp-files mtp-hotplug mtp-sendfile<br />
mtp-connect mtp-folders mtp-newfolder mtp-sendtr<br />
mtp-delfile mtp-format mtp-newplaylist mtp-thumb<br />
mtp-detect mtp-getfile mtp-playlists mtp-tracks<br />
<br />
=== mtpfs ===<br />
<br />
{{Note | The following is likely to not work and you might have to resort to [[Digital_Cameras#libgphoto2|gphoto2]] or a file manager with gvfs support like [[PCManFM]]. }}<br />
<br />
First edit your {{ic|/etc/fuse.conf}} and uncomment the following line:<br />
user_allow_other<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
$ mtpfs -o allow_other ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== jmtpfs ===<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ jmtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
Make this cohere to the rest of Linux (use regular mount/umount commands) by doing two steps<br />
<br />
$# ln -s <actual mount command's path/name> <a name consistent with Linux's mount convention><br />
$ ln -s /sbin/jmtpfs /sbin/mount.jmtpfs<br />
<br />
add this line to /etc/fstab; <br />
<br />
#jmtpfs <mount path> fuse nodev,allow_other,<other options> 0 0<br />
jmtpfs /home/sam/run/motog fuse nodev,allow_other,rw,user,noauto,noatime,uid=1000,gid=1000 0 0<br />
<br />
Now mount the device and see if the options "took"<br />
<br />
$ mount /home/sam/run/motog<br />
Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).<br />
Android device detected, assigning default bug flags<br />
$ mount <br />
...<br />
jmtpfs on /home/sam/run/motog type fuse.jmtpfs (rw,nosuid,nodev,noexec,noatime,user_id=1000,group_id=1000,allow_other,user=sam)<br />
<br />
=== go-mtpfs ===<br />
<br />
{{Note|Mounting with {{ic|go-mtpfs}} might fail if an external SD Card is present. If you try to access your device while having an SD card and go-mtpfs complains, try removing the SD card and mounting again.}}<br />
<br />
Install {{Pkg|android-udev}}, which will allow you to edit {{ic|/etc/udev/rules.d/51-android.rules}} and apply to your {{ic|idVendor}} and {{ic|idProduct}}, which you can see after running ''mtp-detect''. To the end of the line, add your user {{ic|<nowiki>OWNER="<user>"</nowiki>}}.<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ go-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== simple-mtpfs ===<br />
<br />
List MTP devices:<br />
<br />
$ simple-mtpfs --list-devices<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
<br />
$ simple-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== Android File Transfer ===<br />
<br />
;FUSE interface<br />
<br />
Mount your device on {{ic|~/my-device}}:<br />
$ mkdir ~/my-device<br />
$ aft-mtp-mount ~/my-device<br />
<br />
If you want album art to be displayed, it must be named {{ic|albumart.xxx}} and placed first in the destination folder. Then copy other files. Also, note that fuse could be 7-8 times slower than ui/cli file transfer.<br />
<br />
Unmount device mounted on {{ic|~/my-device}}:<br />
<br />
$ fusermount -u ~/my-device<br />
<br />
;Qt user interface<br />
<br />
Start the application, choose a destination folder and click any button on the toolbar. Available options are: ''Upload Album'', ''Upload Directory'' and ''Upload Files''. The latter two are self-explanatory. ''Upload album'' searches the source directory for album covers, and sets the best available cover.<br />
<br />
=== Media players ===<br />
<br />
You can also use your MTP device in music players such as Amarok. To achieve this, you might have to edit {{ic|/etc/udev/rules.d/51-android.rules}} (the MTP device used in the following example is a Galaxy Nexus). <br />
Run:<br />
<br />
$ lsusb<br />
<br />
Search for your device. It should be something like that:<br />
Bus 003 Device 011: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-P7500 [Galaxy Tab 10.1]<br />
<br />
And entry to {{ic|/etc/udev/rules.d/51-android.rules}} will be this:<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="[username]"<br />
<br />
Also reload udev rules:<br />
# udevadm control --reload<br />
<br />
== Troubleshooting ==<br />
<br />
=== libmtp ===<br />
<br />
==== Unknown device ====<br />
<br />
If you see a message like:<br />
<br />
Device 0 (VID=XXXX and PID=XXXX) is UNKNOWN.<br />
Please report this VID/PID and the device model to the libmtp development team<br />
<br />
You should check whether your device is listed in the [http://sourceforge.net/p/libmtp/code/ci/HEAD/tree/src/music-players.h supported devices list]. If it is not, you should report it to the developers team. If it is, your {{ic|libmtp}} might be slightly outdated. To allow it to be properly used by {{ic|libmtp}}, you can add your device to:<br />
<br />
/etc/udev/rules.d/69-libmtp.rules<br />
<br />
==== Unable to enumerate USB device ====<br />
{{Deletion|This should be an old kernel bug, and should have been fixed already. There is no bug report to confirm though.}}<br />
{{Merge||Unrelated to MTP, perhaps suited for [[USB storage devices]]}}<br />
<br />
If you see a message like this in system log ({{ic|journalctl}})<br />
<br />
usb usb4-port2: unable to enumerate USB device<br />
<br />
You can try following temporary [https://bbs.archlinux.org/viewtopic.php?pid=1087323#p1087323 workaround]<br />
<br />
# modprobe -vr uhci_hcd<br />
# modprobe -va ohci_hcd<br />
# modprobe -va uhci_hcd<br />
<br />
If it works you should create {{ic|/etc/modprobe.d/usb_hci_order.conf}} with following content<br />
<br />
# create a dependency on ohci for uhci, which fixes problems<br />
# with external usb devices not showing up<br />
#<br />
softdep uhci_hcd pre: ohci_hcd<br />
<br />
=== jmtpfs ===<br />
<br />
==== Input/output error upon first access ====<br />
<br />
Symptoms: jmtpfs successfully mounts, but as soon as one attempts to access files on the device (e.g. via {{ic|ls}}), an error is reported:<br />
<br />
cannot access <mount-point>: Input/output error<br />
<br />
This appears to be a security feature: MTP does not work when the phone is locked by the lockscreen. Unlock the phone and it should work again as long as the cord remains connected.<br />
<br />
=== gvfs-mtp ===<br />
<br />
{{Merge|udev}}<br />
<br />
To see if gvfs can detect your connected device with enabled MTP, e.g. for phone use {{ic|<NOWIKI>gvfs-mount -l | grep -e Phone -e MTP</NOWIKI>}}.<br />
If you have installed the {{Pkg|gvfs-mtp}} package, and your device does not show up in the file manager, you might need to reboot or write a udev rule in order to auto-mount the device.<br />
<br />
Plug your device and get the vendor-id and product-id,respectively:<br />
<br />
$ lsusb<br />
Bus 001 Device 007: ID 0421:0661 Nokia Mobile Phones Lumia 920<br />
(...)<br />
<br />
Use ID number that represents by pattern ''vendorId'':''productID'' and make an udev rule by creating a configuration file<br />
<br />
{{hc|/etc/udev/rules.d/51-android.rules|<NOWIKI><br />
ATTR{idVendor}=="YOUR VENDOR ID HERE", ATTR{idProduct}=="YOUR PRODUCT ID HERE", SYMLINK+="libmtp", MODE="660", ENV{ID_MTP_DEVICE}="1"<br />
</NOWIKI>}}<br />
Reload the udev rules.<br />
<br />
# udevadm control --reload<br />
<br />
And reboot the system. Now file managers (like Thunar) should be able to automount the MTP Device. [https://bbs.archlinux.org/viewtopic.php?id=180719]<br />
<br />
To mount or dismount from a command with gvfs-mtp use Bus and Device numbers, e.g. to mount {{ic|gvfs-mount mtp://[usb:001,007]/}} and to unmount {{ic|gvfs-mount -u mtp://[usb:001,007]/}}. The mounted device will be available in a directory that begins with ''mtp:host='' and is located under ''/run/user/$UID/gvfs/''.<br />
<br />
Disable automount of MTP devises with gvfs you will need to change value ''true'' to ''false'' for variable ''AutoMount'' that is located in {{ic|/usr/share/gvfs/mounts/mtp.mount}}.<br />
<br />
{{Note|The file managers can have own options for automount. On start they checking for all available mountable devices.}}<br />
<br />
=== kio-mtp ===<br />
<br />
If you are not able to use the action "Open with File Manager", you may work around this problem by editing the file {{ic|/usr/share/apps/solid/actions/solid_mtp.desktop}}.<br />
<br />
Change the line<br />
<br />
Exec=kioclient exec mtp:udi=%i/<br />
<br />
To<br />
<br />
Exec=dolphin "mtp:/"</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Media_Transfer_Protocol&diff=446906Media Transfer Protocol2016-08-17T17:53:43Z<p>Andy Crowd: /* gvfs-mtp */ simplify description of creation an udev rule</p>
<hr />
<div>[[Category:Storage]]<br />
[[Category:Mobile devices]]<br />
[[fa:MTP]]<br />
[[ja:MTP]]<br />
[[ru:MTP]]<br />
[[zh-CN:MTP]]<br />
{{Related articles start}}<br />
{{Related|USB storage devices}}<br />
{{Related articles end}}<br />
[[Wikipedia:Media_Transfer_Protocol|MTP]], or the ''Media Transfer Protocol'', is a USB device class which is used by many mobile phones (e.g. Samsung Galaxy S4) and media players (e.g. Creative Zen).<br />
<br />
== Installation ==<br />
<br />
=== Functionality ===<br />
<br />
Linux MTP support is provided by [[installing]] the {{Pkg|libmtp}} package. It can be installed on its own and used to access devices. However, a number of packages are available that use it as a dependency and add additional convenience (e.g. filemanager) functionalities and compatibility with particular device types - which includes improving transfer access speeds. <br />
<br />
These packages to choose from all implement a [[Wikipedia:Filesystem in Userspace]]: <br />
<br />
* {{Pkg|mtpfs}}<br />
* {{AUR|jmtpfs}} - is reported to work well for newer Android 4+ devices <br />
* {{AUR|go-mtpfs-git}} - is reported to work well for newer Android 3+ devices <br />
* {{AUR|simple-mtpfs}}<br />
* {{Pkg|android-file-transfer}} - MTP client with minimalistic UI<br />
<br />
All of them aim at better functionality and performance over {{ic|libmtp}}. Since there are a lot of different USB devices, you might want to research first which one looks most suitable for yours. <br />
<br />
{{Tip|It is recommended to reboot your computer after installing MTP related packages.}}<br />
<br />
=== Integration with file managers ===<br />
<br />
To view the contents of your Android device's storage via MTP in your file manager, install the corresponding plugin:<br />
<br />
* For file managers that use [[GVFS]] (GNOME Files), install {{Pkg|gvfs-mtp}} for MTP or {{Pkg|gvfs-gphoto2}} for PTP support.<br />
* For file managers that use KIO (KDE's Dolphin), MTP support is included in {{Pkg|kio-extras}} (dependency of dolphin).<br />
<br />
After installing the required package, the device should show up in the file manager automatically and be accessible via an URL, for example {{ic|mtp://[usb:002,013]/}}.<br />
<br />
== Usage ==<br />
<br />
It might be required to create a mount-point directory first. The directory {{ic|~/mnt}} is used as an example below. Also do not forget to unlock your phone's screen before connecting it to the computer.<br />
<br />
=== libmtp ===<br />
<br />
Detect your device:<br />
<br />
# mtp-detect<br />
<br />
If an error is returned, see [[#libmtp 2|troubleshooting libmtp]]. <br />
<br />
{{Note|Your regular user must be in the {{ic|uucp}} [[users_and_groups#Example_adding_a_user|group]].}}<br />
<br />
Connect to your device:<br />
# mtp-connect<br />
<br />
If connection is successful, there are several switch options to use in conjunction with ''mtp-connect'' to access data on the device. You might want to use some stand alone commands:<br />
mtp-albumart mtp-emptyfolders mtp-getplaylist mtp-reset mtp-trexist<br />
mtp-albums mtp-files mtp-hotplug mtp-sendfile<br />
mtp-connect mtp-folders mtp-newfolder mtp-sendtr<br />
mtp-delfile mtp-format mtp-newplaylist mtp-thumb<br />
mtp-detect mtp-getfile mtp-playlists mtp-tracks<br />
<br />
=== mtpfs ===<br />
<br />
{{Note | The following is likely to not work and you might have to resort to [[Digital_Cameras#libgphoto2|gphoto2]] or a file manager with gvfs support like [[PCManFM]]. }}<br />
<br />
First edit your {{ic|/etc/fuse.conf}} and uncomment the following line:<br />
user_allow_other<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
$ mtpfs -o allow_other ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== jmtpfs ===<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ jmtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
Make this cohere to the rest of Linux (use regular mount/umount commands) by doing two steps<br />
<br />
$# ln -s <actual mount command's path/name> <a name consistent with Linux's mount convention><br />
$ ln -s /sbin/jmtpfs /sbin/mount.jmtpfs<br />
<br />
add this line to /etc/fstab; <br />
<br />
#jmtpfs <mount path> fuse nodev,allow_other,<other options> 0 0<br />
jmtpfs /home/sam/run/motog fuse nodev,allow_other,rw,user,noauto,noatime,uid=1000,gid=1000 0 0<br />
<br />
Now mount the device and see if the options "took"<br />
<br />
$ mount /home/sam/run/motog<br />
Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).<br />
Android device detected, assigning default bug flags<br />
$ mount <br />
...<br />
jmtpfs on /home/sam/run/motog type fuse.jmtpfs (rw,nosuid,nodev,noexec,noatime,user_id=1000,group_id=1000,allow_other,user=sam)<br />
<br />
=== go-mtpfs ===<br />
<br />
{{Note|Mounting with {{ic|go-mtpfs}} might fail if an external SD Card is present. If you try to access your device while having an SD card and go-mtpfs complains, try removing the SD card and mounting again.}}<br />
<br />
Install {{Pkg|android-udev}}, which will allow you to edit {{ic|/etc/udev/rules.d/51-android.rules}} and apply to your {{ic|idVendor}} and {{ic|idProduct}}, which you can see after running ''mtp-detect''. To the end of the line, add your user {{ic|<nowiki>OWNER="<user>"</nowiki>}}.<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ go-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== simple-mtpfs ===<br />
<br />
List MTP devices:<br />
<br />
$ simple-mtpfs --list-devices<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
<br />
$ simple-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== Android File Transfer ===<br />
<br />
;FUSE interface<br />
<br />
Mount your device on {{ic|~/my-device}}:<br />
$ mkdir ~/my-device<br />
$ aft-mtp-mount ~/my-device<br />
<br />
If you want album art to be displayed, it must be named {{ic|albumart.xxx}} and placed first in the destination folder. Then copy other files. Also, note that fuse could be 7-8 times slower than ui/cli file transfer.<br />
<br />
Unmount device mounted on {{ic|~/my-device}}:<br />
<br />
$ fusermount -u ~/my-device<br />
<br />
;Qt user interface<br />
<br />
Start the application, choose a destination folder and click any button on the toolbar. Available options are: ''Upload Album'', ''Upload Directory'' and ''Upload Files''. The latter two are self-explanatory. ''Upload album'' searches the source directory for album covers, and sets the best available cover.<br />
<br />
=== Media players ===<br />
<br />
You can also use your MTP device in music players such as Amarok. To achieve this, you might have to edit {{ic|/etc/udev/rules.d/51-android.rules}} (the MTP device used in the following example is a Galaxy Nexus). <br />
Run:<br />
<br />
$ lsusb<br />
<br />
Search for your device. It should be something like that:<br />
Bus 003 Device 011: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-P7500 [Galaxy Tab 10.1]<br />
<br />
And entry to {{ic|/etc/udev/rules.d/51-android.rules}} will be this:<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="[username]"<br />
<br />
Also reload udev rules:<br />
# udevadm control --reload<br />
<br />
== Troubleshooting ==<br />
<br />
=== libmtp ===<br />
<br />
==== Unknown device ====<br />
<br />
If you see a message like:<br />
<br />
Device 0 (VID=XXXX and PID=XXXX) is UNKNOWN.<br />
Please report this VID/PID and the device model to the libmtp development team<br />
<br />
You should check whether your device is listed in the [http://sourceforge.net/p/libmtp/code/ci/HEAD/tree/src/music-players.h supported devices list]. If it is not, you should report it to the developers team. If it is, your {{ic|libmtp}} might be slightly outdated. To allow it to be properly used by {{ic|libmtp}}, you can add your device to:<br />
<br />
/etc/udev/rules.d/69-libmtp.rules<br />
<br />
==== Unable to enumerate USB device ====<br />
{{Deletion|This should be an old kernel bug, and should have been fixed already. There is no bug report to confirm though.}}<br />
{{Merge||Unrelated to MTP, perhaps suited for [[USB storage devices]]}}<br />
<br />
If you see a message like this in system log ({{ic|journalctl}})<br />
<br />
usb usb4-port2: unable to enumerate USB device<br />
<br />
You can try following temporary [https://bbs.archlinux.org/viewtopic.php?pid=1087323#p1087323 workaround]<br />
<br />
# modprobe -vr uhci_hcd<br />
# modprobe -va ohci_hcd<br />
# modprobe -va uhci_hcd<br />
<br />
If it works you should create {{ic|/etc/modprobe.d/usb_hci_order.conf}} with following content<br />
<br />
# create a dependency on ohci for uhci, which fixes problems<br />
# with external usb devices not showing up<br />
#<br />
softdep uhci_hcd pre: ohci_hcd<br />
<br />
=== jmtpfs ===<br />
<br />
==== Input/output error upon first access ====<br />
<br />
Symptoms: jmtpfs successfully mounts, but as soon as one attempts to access files on the device (e.g. via {{ic|ls}}), an error is reported:<br />
<br />
cannot access <mount-point>: Input/output error<br />
<br />
This appears to be a security feature: MTP does not work when the phone is locked by the lockscreen. Unlock the phone and it should work again as long as the cord remains connected.<br />
<br />
=== gvfs-mtp ===<br />
<br />
{{Merge|udev}}<br />
<br />
If you have installed the {{Pkg|gvfs-mtp}} package, and your device does not show up in the file manager, you might need to reboot or write a udev rule in order to auto-mount the device.<br />
<br />
Plug your device and get the vendor-id and product-id,respectively:<br />
<br />
$ lsusb<br />
Bus 001 Device 007: ID 0421:0661 Nokia Mobile Phones Lumia 920<br />
(...)<br />
<br />
Use ID number that represents by pattern ''vendorId'':''productID'' and make an udev rule by creating a configuration file<br />
<br />
{{hc|/etc/udev/rules.d/51-android.rules|<NOWIKI><br />
ATTR{idVendor}=="YOUR VENDOR ID HERE", ATTR{idProduct}=="YOUR PRODUCT ID HERE", SYMLINK+="libmtp", MODE="660", ENV{ID_MTP_DEVICE}="1"<br />
</NOWIKI>}}<br />
Reload the udev rules.<br />
<br />
# udevadm control --reload<br />
<br />
And reboot the system. Now file managers (like Thunar) should be able to automount the MTP Device. [https://bbs.archlinux.org/viewtopic.php?id=180719]<br />
<br />
To mount or dismount from a command with gvfs-mtp use Bus and Device numbers, e.g. to mount {{ic|gvfs-mount mtp://[usb:001,007]/}} and to unmount {{ic|gvfs-mount -u mtp://[usb:001,007]/}}. The mounted device will be available in a directory that begins with ''mtp:host='' and is located under ''/run/user/$UID/gvfs/''.<br />
<br />
Disable automount of MTP devises with gvfs you will need to change value ''true'' to ''false'' for variable ''AutoMount'' that is located in {{ic|/usr/share/gvfs/mounts/mtp.mount}}.<br />
<br />
{{Note|The file managers can have own options for automount. On start they checking for all available mountable devices.}}<br />
<br />
=== kio-mtp ===<br />
<br />
If you are not able to use the action "Open with File Manager", you may work around this problem by editing the file {{ic|/usr/share/apps/solid/actions/solid_mtp.desktop}}.<br />
<br />
Change the line<br />
<br />
Exec=kioclient exec mtp:udi=%i/<br />
<br />
To<br />
<br />
Exec=dolphin "mtp:/"</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Media_Transfer_Protocol&diff=446905Media Transfer Protocol2016-08-17T17:36:20Z<p>Andy Crowd: /* gvfs-mtp */ added info about disabling autmount by editing /usr/share/gvfs/mounts/mtp.mount</p>
<hr />
<div>[[Category:Storage]]<br />
[[Category:Mobile devices]]<br />
[[fa:MTP]]<br />
[[ja:MTP]]<br />
[[ru:MTP]]<br />
[[zh-CN:MTP]]<br />
{{Related articles start}}<br />
{{Related|USB storage devices}}<br />
{{Related articles end}}<br />
[[Wikipedia:Media_Transfer_Protocol|MTP]], or the ''Media Transfer Protocol'', is a USB device class which is used by many mobile phones (e.g. Samsung Galaxy S4) and media players (e.g. Creative Zen).<br />
<br />
== Installation ==<br />
<br />
=== Functionality ===<br />
<br />
Linux MTP support is provided by [[installing]] the {{Pkg|libmtp}} package. It can be installed on its own and used to access devices. However, a number of packages are available that use it as a dependency and add additional convenience (e.g. filemanager) functionalities and compatibility with particular device types - which includes improving transfer access speeds. <br />
<br />
These packages to choose from all implement a [[Wikipedia:Filesystem in Userspace]]: <br />
<br />
* {{Pkg|mtpfs}}<br />
* {{AUR|jmtpfs}} - is reported to work well for newer Android 4+ devices <br />
* {{AUR|go-mtpfs-git}} - is reported to work well for newer Android 3+ devices <br />
* {{AUR|simple-mtpfs}}<br />
* {{Pkg|android-file-transfer}} - MTP client with minimalistic UI<br />
<br />
All of them aim at better functionality and performance over {{ic|libmtp}}. Since there are a lot of different USB devices, you might want to research first which one looks most suitable for yours. <br />
<br />
{{Tip|It is recommended to reboot your computer after installing MTP related packages.}}<br />
<br />
=== Integration with file managers ===<br />
<br />
To view the contents of your Android device's storage via MTP in your file manager, install the corresponding plugin:<br />
<br />
* For file managers that use [[GVFS]] (GNOME Files), install {{Pkg|gvfs-mtp}} for MTP or {{Pkg|gvfs-gphoto2}} for PTP support.<br />
* For file managers that use KIO (KDE's Dolphin), MTP support is included in {{Pkg|kio-extras}} (dependency of dolphin).<br />
<br />
After installing the required package, the device should show up in the file manager automatically and be accessible via an URL, for example {{ic|mtp://[usb:002,013]/}}.<br />
<br />
== Usage ==<br />
<br />
It might be required to create a mount-point directory first. The directory {{ic|~/mnt}} is used as an example below. Also do not forget to unlock your phone's screen before connecting it to the computer.<br />
<br />
=== libmtp ===<br />
<br />
Detect your device:<br />
<br />
# mtp-detect<br />
<br />
If an error is returned, see [[#libmtp 2|troubleshooting libmtp]]. <br />
<br />
{{Note|Your regular user must be in the {{ic|uucp}} [[users_and_groups#Example_adding_a_user|group]].}}<br />
<br />
Connect to your device:<br />
# mtp-connect<br />
<br />
If connection is successful, there are several switch options to use in conjunction with ''mtp-connect'' to access data on the device. You might want to use some stand alone commands:<br />
mtp-albumart mtp-emptyfolders mtp-getplaylist mtp-reset mtp-trexist<br />
mtp-albums mtp-files mtp-hotplug mtp-sendfile<br />
mtp-connect mtp-folders mtp-newfolder mtp-sendtr<br />
mtp-delfile mtp-format mtp-newplaylist mtp-thumb<br />
mtp-detect mtp-getfile mtp-playlists mtp-tracks<br />
<br />
=== mtpfs ===<br />
<br />
{{Note | The following is likely to not work and you might have to resort to [[Digital_Cameras#libgphoto2|gphoto2]] or a file manager with gvfs support like [[PCManFM]]. }}<br />
<br />
First edit your {{ic|/etc/fuse.conf}} and uncomment the following line:<br />
user_allow_other<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
$ mtpfs -o allow_other ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== jmtpfs ===<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ jmtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
Make this cohere to the rest of Linux (use regular mount/umount commands) by doing two steps<br />
<br />
$# ln -s <actual mount command's path/name> <a name consistent with Linux's mount convention><br />
$ ln -s /sbin/jmtpfs /sbin/mount.jmtpfs<br />
<br />
add this line to /etc/fstab; <br />
<br />
#jmtpfs <mount path> fuse nodev,allow_other,<other options> 0 0<br />
jmtpfs /home/sam/run/motog fuse nodev,allow_other,rw,user,noauto,noatime,uid=1000,gid=1000 0 0<br />
<br />
Now mount the device and see if the options "took"<br />
<br />
$ mount /home/sam/run/motog<br />
Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).<br />
Android device detected, assigning default bug flags<br />
$ mount <br />
...<br />
jmtpfs on /home/sam/run/motog type fuse.jmtpfs (rw,nosuid,nodev,noexec,noatime,user_id=1000,group_id=1000,allow_other,user=sam)<br />
<br />
=== go-mtpfs ===<br />
<br />
{{Note|Mounting with {{ic|go-mtpfs}} might fail if an external SD Card is present. If you try to access your device while having an SD card and go-mtpfs complains, try removing the SD card and mounting again.}}<br />
<br />
Install {{Pkg|android-udev}}, which will allow you to edit {{ic|/etc/udev/rules.d/51-android.rules}} and apply to your {{ic|idVendor}} and {{ic|idProduct}}, which you can see after running ''mtp-detect''. To the end of the line, add your user {{ic|<nowiki>OWNER="<user>"</nowiki>}}.<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ go-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== simple-mtpfs ===<br />
<br />
List MTP devices:<br />
<br />
$ simple-mtpfs --list-devices<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
<br />
$ simple-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== Android File Transfer ===<br />
<br />
;FUSE interface<br />
<br />
Mount your device on {{ic|~/my-device}}:<br />
$ mkdir ~/my-device<br />
$ aft-mtp-mount ~/my-device<br />
<br />
If you want album art to be displayed, it must be named {{ic|albumart.xxx}} and placed first in the destination folder. Then copy other files. Also, note that fuse could be 7-8 times slower than ui/cli file transfer.<br />
<br />
Unmount device mounted on {{ic|~/my-device}}:<br />
<br />
$ fusermount -u ~/my-device<br />
<br />
;Qt user interface<br />
<br />
Start the application, choose a destination folder and click any button on the toolbar. Available options are: ''Upload Album'', ''Upload Directory'' and ''Upload Files''. The latter two are self-explanatory. ''Upload album'' searches the source directory for album covers, and sets the best available cover.<br />
<br />
=== Media players ===<br />
<br />
You can also use your MTP device in music players such as Amarok. To achieve this, you might have to edit {{ic|/etc/udev/rules.d/51-android.rules}} (the MTP device used in the following example is a Galaxy Nexus). <br />
Run:<br />
<br />
$ lsusb<br />
<br />
Search for your device. It should be something like that:<br />
Bus 003 Device 011: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-P7500 [Galaxy Tab 10.1]<br />
<br />
And entry to {{ic|/etc/udev/rules.d/51-android.rules}} will be this:<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="[username]"<br />
<br />
Also reload udev rules:<br />
# udevadm control --reload<br />
<br />
== Troubleshooting ==<br />
<br />
=== libmtp ===<br />
<br />
==== Unknown device ====<br />
<br />
If you see a message like:<br />
<br />
Device 0 (VID=XXXX and PID=XXXX) is UNKNOWN.<br />
Please report this VID/PID and the device model to the libmtp development team<br />
<br />
You should check whether your device is listed in the [http://sourceforge.net/p/libmtp/code/ci/HEAD/tree/src/music-players.h supported devices list]. If it is not, you should report it to the developers team. If it is, your {{ic|libmtp}} might be slightly outdated. To allow it to be properly used by {{ic|libmtp}}, you can add your device to:<br />
<br />
/etc/udev/rules.d/69-libmtp.rules<br />
<br />
==== Unable to enumerate USB device ====<br />
{{Deletion|This should be an old kernel bug, and should have been fixed already. There is no bug report to confirm though.}}<br />
{{Merge||Unrelated to MTP, perhaps suited for [[USB storage devices]]}}<br />
<br />
If you see a message like this in system log ({{ic|journalctl}})<br />
<br />
usb usb4-port2: unable to enumerate USB device<br />
<br />
You can try following temporary [https://bbs.archlinux.org/viewtopic.php?pid=1087323#p1087323 workaround]<br />
<br />
# modprobe -vr uhci_hcd<br />
# modprobe -va ohci_hcd<br />
# modprobe -va uhci_hcd<br />
<br />
If it works you should create {{ic|/etc/modprobe.d/usb_hci_order.conf}} with following content<br />
<br />
# create a dependency on ohci for uhci, which fixes problems<br />
# with external usb devices not showing up<br />
#<br />
softdep uhci_hcd pre: ohci_hcd<br />
<br />
=== jmtpfs ===<br />
<br />
==== Input/output error upon first access ====<br />
<br />
Symptoms: jmtpfs successfully mounts, but as soon as one attempts to access files on the device (e.g. via {{ic|ls}}), an error is reported:<br />
<br />
cannot access <mount-point>: Input/output error<br />
<br />
This appears to be a security feature: MTP does not work when the phone is locked by the lockscreen. Unlock the phone and it should work again as long as the cord remains connected.<br />
<br />
=== gvfs-mtp ===<br />
<br />
{{Merge|udev}}<br />
<br />
If you have installed the {{Pkg|gvfs-mtp}} package, and your device does not show up in the file manager, you might need to reboot or write a udev rule in order to auto-mount the device.<br />
<br />
Plug your device and get the vendor-id and product-id,respectively:<br />
<br />
$ lsusb<br />
Bus 001 Device 007: ID 0421:0661 Nokia Mobile Phones Lumia 920<br />
(...)<br />
<br />
The two numbers after ID are ''vendorId'' : ''productID''<br />
<br />
Then make a udev rule, e.g.<br />
<br />
# nano /etc/udev/rules.d/51-android.rules<br />
<br />
and type this rule:<br />
<br />
ATTR{idVendor}=="YOUR VENDOR ID HERE", ATTR{idProduct}=="YOUR PRODUCT ID HERE", SYMLINK+="libmtp", MODE="660", ENV{ID_MTP_DEVICE}="1"<br />
<br />
Reload the udev rules.<br />
<br />
# udevadm control --reload<br />
<br />
And reboot the system. Now file managers (like Thunar) should be able to automount the MTP Device. [https://bbs.archlinux.org/viewtopic.php?id=180719]<br />
<br />
To mount or dismount from a command with gvfs-mtp use Bus and Device numbers, e.g. to mount {{ic|gvfs-mount mtp://[usb:001,007]/}} and to unmount {{ic|gvfs-mount -u mtp://[usb:001,007]/}}. The mounted device will be available in a directory that begins with ''mtp:host='' and is located under ''/run/user/$UID/gvfs/''.<br />
<br />
Disable automount of MTP devises with gvfs you will need to change value ''true'' to ''false'' for variable ''AutoMount'' that is located in {{ic|/usr/share/gvfs/mounts/mtp.mount}}.<br />
<br />
{{Note|The file managers can have own options for automount. On start they checking for all available mountable devices.}}<br />
<br />
=== kio-mtp ===<br />
<br />
If you are not able to use the action "Open with File Manager", you may work around this problem by editing the file {{ic|/usr/share/apps/solid/actions/solid_mtp.desktop}}.<br />
<br />
Change the line<br />
<br />
Exec=kioclient exec mtp:udi=%i/<br />
<br />
To<br />
<br />
Exec=dolphin "mtp:/"</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Media_Transfer_Protocol&diff=446900Media Transfer Protocol2016-08-17T17:11:10Z<p>Andy Crowd: /* gvfs-mtp */ added info about how to mount and dismount mtp devices from command line with gvfs-mtp</p>
<hr />
<div>[[Category:Storage]]<br />
[[Category:Mobile devices]]<br />
[[fa:MTP]]<br />
[[ja:MTP]]<br />
[[ru:MTP]]<br />
[[zh-CN:MTP]]<br />
{{Related articles start}}<br />
{{Related|USB storage devices}}<br />
{{Related articles end}}<br />
[[Wikipedia:Media_Transfer_Protocol|MTP]], or the ''Media Transfer Protocol'', is a USB device class which is used by many mobile phones (e.g. Samsung Galaxy S4) and media players (e.g. Creative Zen).<br />
<br />
== Installation ==<br />
<br />
=== Functionality ===<br />
<br />
Linux MTP support is provided by [[installing]] the {{Pkg|libmtp}} package. It can be installed on its own and used to access devices. However, a number of packages are available that use it as a dependency and add additional convenience (e.g. filemanager) functionalities and compatibility with particular device types - which includes improving transfer access speeds. <br />
<br />
These packages to choose from all implement a [[Wikipedia:Filesystem in Userspace]]: <br />
<br />
* {{Pkg|mtpfs}}<br />
* {{AUR|jmtpfs}} - is reported to work well for newer Android 4+ devices <br />
* {{AUR|go-mtpfs-git}} - is reported to work well for newer Android 3+ devices <br />
* {{AUR|simple-mtpfs}}<br />
* {{Pkg|android-file-transfer}} - MTP client with minimalistic UI<br />
<br />
All of them aim at better functionality and performance over {{ic|libmtp}}. Since there are a lot of different USB devices, you might want to research first which one looks most suitable for yours. <br />
<br />
{{Tip|It is recommended to reboot your computer after installing MTP related packages.}}<br />
<br />
=== Integration with file managers ===<br />
<br />
To view the contents of your Android device's storage via MTP in your file manager, install the corresponding plugin:<br />
<br />
* For file managers that use [[GVFS]] (GNOME Files), install {{Pkg|gvfs-mtp}} for MTP or {{Pkg|gvfs-gphoto2}} for PTP support.<br />
* For file managers that use KIO (KDE's Dolphin), MTP support is included in {{Pkg|kio-extras}} (dependency of dolphin).<br />
<br />
After installing the required package, the device should show up in the file manager automatically and be accessible via an URL, for example {{ic|mtp://[usb:002,013]/}}.<br />
<br />
== Usage ==<br />
<br />
It might be required to create a mount-point directory first. The directory {{ic|~/mnt}} is used as an example below. Also do not forget to unlock your phone's screen before connecting it to the computer.<br />
<br />
=== libmtp ===<br />
<br />
Detect your device:<br />
<br />
# mtp-detect<br />
<br />
If an error is returned, see [[#libmtp 2|troubleshooting libmtp]]. <br />
<br />
{{Note|Your regular user must be in the {{ic|uucp}} [[users_and_groups#Example_adding_a_user|group]].}}<br />
<br />
Connect to your device:<br />
# mtp-connect<br />
<br />
If connection is successful, there are several switch options to use in conjunction with ''mtp-connect'' to access data on the device. You might want to use some stand alone commands:<br />
mtp-albumart mtp-emptyfolders mtp-getplaylist mtp-reset mtp-trexist<br />
mtp-albums mtp-files mtp-hotplug mtp-sendfile<br />
mtp-connect mtp-folders mtp-newfolder mtp-sendtr<br />
mtp-delfile mtp-format mtp-newplaylist mtp-thumb<br />
mtp-detect mtp-getfile mtp-playlists mtp-tracks<br />
<br />
=== mtpfs ===<br />
<br />
{{Note | The following is likely to not work and you might have to resort to [[Digital_Cameras#libgphoto2|gphoto2]] or a file manager with gvfs support like [[PCManFM]]. }}<br />
<br />
First edit your {{ic|/etc/fuse.conf}} and uncomment the following line:<br />
user_allow_other<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
$ mtpfs -o allow_other ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== jmtpfs ===<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ jmtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
Make this cohere to the rest of Linux (use regular mount/umount commands) by doing two steps<br />
<br />
$# ln -s <actual mount command's path/name> <a name consistent with Linux's mount convention><br />
$ ln -s /sbin/jmtpfs /sbin/mount.jmtpfs<br />
<br />
add this line to /etc/fstab; <br />
<br />
#jmtpfs <mount path> fuse nodev,allow_other,<other options> 0 0<br />
jmtpfs /home/sam/run/motog fuse nodev,allow_other,rw,user,noauto,noatime,uid=1000,gid=1000 0 0<br />
<br />
Now mount the device and see if the options "took"<br />
<br />
$ mount /home/sam/run/motog<br />
Device 0 (VID=22b8 and PID=2e82) is a Motorola Moto G (ID2).<br />
Android device detected, assigning default bug flags<br />
$ mount <br />
...<br />
jmtpfs on /home/sam/run/motog type fuse.jmtpfs (rw,nosuid,nodev,noexec,noatime,user_id=1000,group_id=1000,allow_other,user=sam)<br />
<br />
=== go-mtpfs ===<br />
<br />
{{Note|Mounting with {{ic|go-mtpfs}} might fail if an external SD Card is present. If you try to access your device while having an SD card and go-mtpfs complains, try removing the SD card and mounting again.}}<br />
<br />
Install {{Pkg|android-udev}}, which will allow you to edit {{ic|/etc/udev/rules.d/51-android.rules}} and apply to your {{ic|idVendor}} and {{ic|idProduct}}, which you can see after running ''mtp-detect''. To the end of the line, add your user {{ic|<nowiki>OWNER="<user>"</nowiki>}}.<br />
<br />
Mount device on {{ic|~/mnt}}:<br />
<br />
$ go-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== simple-mtpfs ===<br />
<br />
List MTP devices:<br />
<br />
$ simple-mtpfs --list-devices<br />
<br />
Mount your device on {{ic|~/mnt}}:<br />
<br />
$ simple-mtpfs ~/mnt<br />
<br />
Unmount device mounted on {{ic|~/mnt}}:<br />
<br />
$ fusermount -u ~/mnt<br />
<br />
=== Android File Transfer ===<br />
<br />
;FUSE interface<br />
<br />
Mount your device on {{ic|~/my-device}}:<br />
$ mkdir ~/my-device<br />
$ aft-mtp-mount ~/my-device<br />
<br />
If you want album art to be displayed, it must be named {{ic|albumart.xxx}} and placed first in the destination folder. Then copy other files. Also, note that fuse could be 7-8 times slower than ui/cli file transfer.<br />
<br />
Unmount device mounted on {{ic|~/my-device}}:<br />
<br />
$ fusermount -u ~/my-device<br />
<br />
;Qt user interface<br />
<br />
Start the application, choose a destination folder and click any button on the toolbar. Available options are: ''Upload Album'', ''Upload Directory'' and ''Upload Files''. The latter two are self-explanatory. ''Upload album'' searches the source directory for album covers, and sets the best available cover.<br />
<br />
=== Media players ===<br />
<br />
You can also use your MTP device in music players such as Amarok. To achieve this, you might have to edit {{ic|/etc/udev/rules.d/51-android.rules}} (the MTP device used in the following example is a Galaxy Nexus). <br />
Run:<br />
<br />
$ lsusb<br />
<br />
Search for your device. It should be something like that:<br />
Bus 003 Device 011: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-P7500 [Galaxy Tab 10.1]<br />
<br />
And entry to {{ic|/etc/udev/rules.d/51-android.rules}} will be this:<br />
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="[username]"<br />
<br />
Also reload udev rules:<br />
# udevadm control --reload<br />
<br />
== Troubleshooting ==<br />
<br />
=== libmtp ===<br />
<br />
==== Unknown device ====<br />
<br />
If you see a message like:<br />
<br />
Device 0 (VID=XXXX and PID=XXXX) is UNKNOWN.<br />
Please report this VID/PID and the device model to the libmtp development team<br />
<br />
You should check whether your device is listed in the [http://sourceforge.net/p/libmtp/code/ci/HEAD/tree/src/music-players.h supported devices list]. If it is not, you should report it to the developers team. If it is, your {{ic|libmtp}} might be slightly outdated. To allow it to be properly used by {{ic|libmtp}}, you can add your device to:<br />
<br />
/etc/udev/rules.d/69-libmtp.rules<br />
<br />
==== Unable to enumerate USB device ====<br />
{{Deletion|This should be an old kernel bug, and should have been fixed already. There is no bug report to confirm though.}}<br />
{{Merge||Unrelated to MTP, perhaps suited for [[USB storage devices]]}}<br />
<br />
If you see a message like this in system log ({{ic|journalctl}})<br />
<br />
usb usb4-port2: unable to enumerate USB device<br />
<br />
You can try following temporary [https://bbs.archlinux.org/viewtopic.php?pid=1087323#p1087323 workaround]<br />
<br />
# modprobe -vr uhci_hcd<br />
# modprobe -va ohci_hcd<br />
# modprobe -va uhci_hcd<br />
<br />
If it works you should create {{ic|/etc/modprobe.d/usb_hci_order.conf}} with following content<br />
<br />
# create a dependency on ohci for uhci, which fixes problems<br />
# with external usb devices not showing up<br />
#<br />
softdep uhci_hcd pre: ohci_hcd<br />
<br />
=== jmtpfs ===<br />
<br />
==== Input/output error upon first access ====<br />
<br />
Symptoms: jmtpfs successfully mounts, but as soon as one attempts to access files on the device (e.g. via {{ic|ls}}), an error is reported:<br />
<br />
cannot access <mount-point>: Input/output error<br />
<br />
This appears to be a security feature: MTP does not work when the phone is locked by the lockscreen. Unlock the phone and it should work again as long as the cord remains connected.<br />
<br />
=== gvfs-mtp ===<br />
<br />
{{Merge|udev}}<br />
<br />
If you have installed the {{Pkg|gvfs-mtp}} package, and your device does not show up in the file manager, you might need to reboot or write a udev rule in order to auto-mount the device.<br />
<br />
Plug your device and get the vendor-id and product-id,respectively:<br />
<br />
$ lsusb<br />
Bus 001 Device 007: ID 0421:0661 Nokia Mobile Phones Lumia 920<br />
(...)<br />
<br />
The two numbers after ID are ''vendorId'' : ''productID''<br />
<br />
Then make a udev rule, e.g.<br />
<br />
# nano /etc/udev/rules.d/51-android.rules<br />
<br />
and type this rule:<br />
<br />
ATTR{idVendor}=="YOUR VENDOR ID HERE", ATTR{idProduct}=="YOUR PRODUCT ID HERE", SYMLINK+="libmtp", MODE="660", ENV{ID_MTP_DEVICE}="1"<br />
<br />
Reload the udev rules.<br />
<br />
# udevadm control --reload<br />
<br />
And reboot the system. Now file managers (like Thunar) should be able to automount the MTP Device. [https://bbs.archlinux.org/viewtopic.php?id=180719]<br />
<br />
To mount or dismount from a command with gvfs-mtp use Bus and Device numbers, e.g. to mount {{ic|gvfs-mount mtp://[usb:001,007]/}} and to unmount {{ic|gvfs-mount -u mtp://[usb:001,007]/}}. The mounted device will be available in a directory that begins with ''mtp:host='' and is located under ''/run/user/$UID/gvfs/''.<br />
<br />
=== kio-mtp ===<br />
<br />
If you are not able to use the action "Open with File Manager", you may work around this problem by editing the file {{ic|/usr/share/apps/solid/actions/solid_mtp.desktop}}.<br />
<br />
Change the line<br />
<br />
Exec=kioclient exec mtp:udi=%i/<br />
<br />
To<br />
<br />
Exec=dolphin "mtp:/"</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Talk:Browser_plugins&diff=446206Talk:Browser plugins2016-08-10T14:29:02Z<p>Andy Crowd: /* Opera 33 - no support for PPAPI */ I am closing it</p>
<hr />
<div>== <s>Opera 33 - no support for PPAPI </s>==<br />
<br />
I am not sure that description of that Opera 33 supports PPAPI is correct in head of the article. -- Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:50, 8 November 2015 (UTC)<br />
<br />
:This was implemented over a year ago: [http://blogs.opera.com/desktop/2014/06/opera-developer-23-pepper-flash-coming-opera/]. What makes you think otherwise? -- [[User:Alad|Alad]] ([[User talk:Alad|talk]]) 18:55, 8 November 2015 (UTC)<br />
<br />
:: Do you use Opera? I got problem after update to version 33, cannot play flash video, error that flash is not available. -- Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:10, 8 November 2015 (UTC)<br />
<br />
::: Yes, but I haven't upgraded from v32 yet. I'd suggest you to file a bug. -- [[User:Alad|Alad]] ([[User talk:Alad|talk]]) 19:16, 8 November 2015 (UTC)<br />
<br />
:::: Ok. Then just wait for a few more updates to opera and see if it will be the same "BUG". -- Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:26, 8 November 2015 (UTC)<br />
<br />
::::: SOLVED - my pepper flash update stuck on version 17 but no errors about flash version was on adobe website, now everything works after I updated it to the latest. May be add this type of bug: <br />
::::: {{Note|If flash videos doesn't work in opera then pepper flash must be updated to the newest version. <br>You can compare in "about:plugins" with listed on [http://www.adobe.com/software/flash/about/ adobe website].}}<br />
::::: 20:39, 14 November 2015 Andy Crowd<br />
<br />
:::::: Wouldn't you see the same in Chromium though, when the browser is updated but the plugin is not? The cause/symptom relation isn't too clear in the suggested note. -- [[User:Alad|Alad]] ([[User talk:Alad|talk]]) 21:01, 14 November 2015 (UTC)<br />
<br />
::::::: google-chrome-stable uses only: /opt/google/chrome/PepperFlash/libpepflashplayer.so (if path to file doesn't exist then it still shows plugin in the list but flash videos cannot be loaded)<br />
::::::: Opera uses: /usr/lib/PepperFlash/libpepflashplayer.so if path/file doesn't exist it using /usr/lib/chromium/PepperFlash/libpepflashplayer.so next it looking for /opt/google/chrome/PepperFlash/libpepflashplayer.so <br />
::::::: Chromium uses only: /usr/lib/PepperFlash/libpepflashplayer.so if path/file doesn't exist then no plugin is listed/used.<br />
::::::: The "manifest.json" file contains flash player version. Chromium/Chrome has no problems with old version but Opera not allowing to use older versions of it and shows no errors, flash videos just didn't play even on adobe website.<br />
::::::: Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:27, 16 November 2015 (UTC)<br />
<br />
::::::::Is this still a problem? -- [[User:Alad|Alad]] ([[User talk:Alad|talk]]) 19:43, 9 August 2016 (UTC)</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=User:Andy_Crowd&diff=442385User:Andy Crowd2016-07-22T10:58:25Z<p>Andy Crowd: /* Fast Notes & current problems that need to be solved */ download Chinese fonts: www.clearchinese.com</p>
<hr />
<div>__NOINDEX__<br />
<br />
== My achievements ==<br />
<br />
My packages in AUR: [https://aur.archlinux.org/packages/?SeB=m&K=Andy_Crowd list them].<br />
<br />
My sandbox pages: [[User:Andy_Crowd/sandbox|A list of other sub/fun]]<br />
<br />
== Fast Notes & current problems that need to be solved ==<br />
<br />
: '''Current links as tmp-memo I need to use'''<br />
<br />
* Download Chinese fonts <br />
A="$(curl http://www.clearchinese.com/resources/fonts.htm | grep -i ttf | sed 's/[^*]*href=\"//g' | cut -d\" -f1)"<br />
<br />
* Interesting link about [http://www.linuxtopia.org/online_books/linux_desktop_guides/gnome_2.14_admin_guide/mimetypes-database.html mimetypes-database].<br />
<br />
* Show list of unique category names. Could simplify and added as option --lc in lsdesktopf to search only in {{ic|/usr/share/applications/}} and {{ic|$HOME/.local/share/applications/}}.<br />
<br />
* [https://superuser.com/questions/459628/how-to-configure-linux-to-open-files-by-extension how-to-configure-linux-to-open-files-by-extension]<br />
<br />
* [http://www.freerepublic.com/focus/chat/3146816/posts reviewer and test linux Versions] one more [http://www.linuxquestions.org/questions/linux-newbie-8/newbie-alert-50-open-source-replacements-for-windows-xp-4175502495/ link] to same.<br />
<br />
* Now available new updated version in AUR4 {{AUR|lsdsk}}. Link to forum [http://www.linuxquestions.org/questions/programming-9/any-launcher-alternatives-to-this-script-4175548311/#post5393185 forum].<br />
** Preparing info to make an extended version of lsdsk script that will support command line. It will be named as ''lsdesktopfitems'', [http://www.linuxquestions.org/questions/programming-9/find-all-specific-words-in-a-sting-4175562125/ Link] to read multiple items from command line.<br />
<br />
* [http://www.linuxquestions.org/questions/linux-general-1/i%27m-an-idiot-moments-4175510176/ I'm an idiot moments] - nice and cool<br />
<br />
* Compare VOIP [http://progx.ch/home-voip-prixbetamax-3-1-1.html http://progx.ch]<br />
<br />
* [http://alternativeto.net/software/ftpuse/ Mount/map the ftp folder as a letter in Windows]<br />
<br />
* [https://www.suse.com/documentation/sles11/book_kvm/data/cha_qemu_running_devices.html QEMU] - examples to test<br />
<br />
* Future project: Live CD + auto-configuration of {{Pkg|pulseaudio}} + detect ''user-names'' in Windows {{ic|C:\users\}} folder and create them in Linux by using {{ic|C:\users\''user_name''}} as a home path.<br />
<br />
* Just some links from [[Talk:Securely_wipe_disk]] <br />
[http://stackoverflow.com/questions/3231804/in-bash-how-to-add-are-you-sure-y-n-to-any-command-or-alias], [http://unix.stackexchange.com/questions/72198/prompt-for-confirmation-for-every-command] or [http://unix.stackexchange.com/questions/36377/how-to-create-a-confirmation-question-in-linux]<br />
<br />
* To make DVD video work good [https://bbs.archlinux.org/viewtopic.php?pid=1123883 forum], libs need to be installed: libdvdnav libdvdread libdvdcss<br />
Fix for {{ic|MPEG: No audio stream found -> no sound.}}<br />
<br />
* A4 = 210x297 mm - command line for sane<br />
scanimage -x 120 -y 210 --resolution 300 --mode Color --format=tiff >image2.tiff<br />
<br />
* Sakis3g and QT bug fix: {{ic|1=export QT_X11_NO_MITSHM=1}} before X start<br />
<br />
* Keyboard key descriptions Accented Characters:<br />
** [http://www.angelfire.com/ak2/timothydrew/altkeys.html Alt key] <br />
** [http://www.corpbuscards.com/mackeycodesfortyping.htm mac keys],<br />
** [[wikipedia:AltGr_key|AltGr_key]]<br />
<br />
* Fix [http://www.linuxforums.org/forum/arch-linux/204421-unable-install-lxqt.html pacman] keys link<br />
<br />
'''URL extraction new version''' {{AUR|2gis}}<br />
$ curl <nowiki>"http://info.2gis.ru/moscow/products/download#skachat-kartu-na-komputer&linux"</nowiki> | awk -Fzip '{if(match($0,"2GISShell") != 0){AA=substr($2,index($2,"http"));if(match(AA,"http") != 0)print AA"zip"}}'<br />
<br />
== Convert media scripts ==<br />
<br />
My scripts for conversion of media files<br />
<br />
'''m4a''' to '''ogg'''<br />
<br />
{{hc|m4a_to_ogg.sh|<nowiki><br />
#!/bin/bash<br />
for I in "$HOME"/Media/Music/*.m4a;do PP=${I##*/};<br />
if [ -d "$HOME/Media/Music/OGG" ]; then<br />
####<br />
ffmpeg -i "$I" -acodec vorbis -strict -2 -ac 2 "$HOME/Media/Music/OGG/${PP/.m4a/.ogg}" ;<br />
####<br />
IR=$(du "$HOME/Media/Music/OGG/${PP/.m4a/.ogg}" | awk '{print $1}')<br />
if [ "$IR" != "0" ]; then <br />
if [ -d "$HOME/Media/Music/Converted" ]; then <br />
mv -vi "$I" "$HOME/Media/Music/Converted";<br />
else <br />
echo The '"$HOME/Media/Music/Converted"' folder is missing<br />
break<br />
fi<br />
else <br />
echo Something gone wrong size of converted "$PP" file is 0<br />
break;<br />
fi;<br />
else echo Path doesn"'"t exist: '"$HOME/Media/Music/OGG/"'<br />
break<br />
fi<br />
done<br />
</nowiki>}}<br />
<br />
== Auto-gen configuration files ==<br />
<br />
Perfect to use them on a Live CD<br />
<br />
=== Conky ===<br />
<br />
All moved to github<br />
<br />
=== HDDTemp ===<br />
<br />
Moved to github<br />
<br />
== TMP for before deletion ==<br />
<br />
{{bc|1=. <br />
************************************************<br />
**** Your system is too SLOW to play this! ****<br />
************************************************<br />
<br />
Possible reasons, problems, workarounds:<br />
- Most common: broken/buggy _audio_ driver<br />
- Try -ao sdl or use the OSS emulation of ALSA.<br />
- Experiment with different values for -autosync, 30 is a good start.<br />
- Slow video output<br />
- Try a different -vo driver (-vo help for a list) or try -framedrop!<br />
- Slow CPU<br />
- Don't try to play a big DVD/DivX on a slow CPU! Try some of the lavdopts,<br />
e.g. -vfm ffmpeg -lavdopts lowres=1:fast:skiploopfilter=all.<br />
- Broken file<br />
- Try various combinations of -nobps -ni -forceidx -mc 0.<br />
- Slow media (NFS/SMB mounts, DVD, VCD etc)<br />
- Try -cache 8192.<br />
- Are you using -cache to play a non-interleaved AVI file?<br />
- Try -nocache.<br />
Read DOCS/HTML/en/video.html for tuning/speedup tips.<br />
If none of this helps you, read DOCS/HTML/en/bugreports.html.<br />
}}<br />
<br />
Restore original file names by using backup file with checksums and comparing with [[Post_recovery_tasks#List_only_unique_files_by_checksum|List only unique files by checksum]] generated file.<br />
<br />
{{bc|<nowiki>awk -F"|" -v W="$(cat compmd5_new.tmp)" '//{split(W,Z," ");<br />
for(i in Z)if(index(i/2,".") != 0){if(Z[i] == $4){F=Z[i+1];gsub(/[^\/*]*\//,"",F);<br />
print $1"|"$2"|"$3"|"F};}}' compmd5_1.tmp<br />
</nowiki>}}<br />
<br />
This is the same as above but will also handle filenames with spaces correctly<br />
<br />
{{bc|<nowiki><br />
awk -F"|" -v W="$(cat compmd5_new.tmp|awk '{print "|"$1"|"substr($0,index($0," "))}')" '//{split(W,Z,"|");for(i in Z)if(index(i/2,".") == 0){if(Z[i] == $4){F=Z[i+1];gsub(/[^\/*]*\//,"",F);print $1"|"$2"|"$3"|"F};}}' checksums.list | grep -v ^$<br />
</nowiki>}}<br />
<br />
Link to forum where I was looking for help: [http://www.linuxforums.org/forum/programming-scripting/204771-compare-two-files-show-combined-output.html#post966741 linuxforum]<br />
<br />
Populate array by image extensions, may be not work correctly if some part of extension exist in the list, e.g. {{ic|h}} extension will be found in {{ic|html}}.<br />
<br />
{{bc|<nowiki>RR="jpg gif";<br />
QQ=($(awk -F'|' -v KK="$RR" '{SS=$3;gsub(/[^*\.]*\./,"",SS);if ( index(KK,SS) != 0 ) print $3}' checksums.list)) <br />
for (( i=0;i <= ${#QQ[@]};i++ ));do if [ ! -z ${QQ[i]} ];then echo ${QQ[i]};fi;done <br />
</nowiki>}}<br />
<br />
This will clean up special symbols, sort restored names, add a number to the duplicate names.<br />
{{bc|<nowiki><br />
#!/bin/bash<br />
if [ ! -z "$1" ];then<br />
awk -F"|" '{B=$2;<br />
gsub(/\(/,"",B);gsub(/\)/,"",B);<br />
gsub(/!/,"",B); gsub(/?/,"",B);<br />
gsub(/\[/,"",B);gsub(/\]/,"",B);<br />
gsub(/{/,"",B); gsub(/}/,"",B);<br />
gsub(/&/,"",B); gsub(/=/,"",B);<br />
gsub(/\^/,"",B);gsub(/~/,"",B);<br />
gsub(" ","",B) ;gsub(/#/,"",B);<br />
gsub(/\"/,"",B);gsub(/;/,"",B);<br />
gsub(/\\/,"",B);gsub(/\//,"",B);<br />
sub(/-*/,"",B); sub(/+*/,"",B);<br />
print $1" | "B" | "$3}' "$1" | \<br />
sort --field-separator=\| -s -d -k 2 | \<br />
awk -F'|' '{B=$2;Count[B]++;sub(/ */,"",B);if( Count[$2] == 1 ){print $1" | "B" | "$3}else{print $1" | "Count[$2]-1"¤"B" | "$3} }'<br />
else echo 'Path to file is missing!'<br />
fi<br />
</nowiki>}}<br />
I will probably rewrite my post_rec_scripts to use checksum file, already sorted file names.<br />
=== With ''grep'' and ''awk'' commands populate the array ===<br />
<br />
This way of populating an array is many times faster as with a ''while'' command but has limitations that might cause errors. A common way of populating an array as in this example causes problems due using space between words as a separator and a file names that contains them will not be restored and errors will be shown.<br />
A ''$SearchFor'' variable is more intuitive to edit then if all patters are in the same line with ''grep''.<br />
{{bc|<nowiki>SearchFor="-e compressed -e archive";<br />
ArrayOfFiles=($(grep -i $SearchFor info-mime-size-db.txt | awk -F'|' '{print $1 }'));</nowiki>}}<br />
<br />
Without grep you have to use {{ic|if}} inside of {{Pkg|gawk}} command and add patterns. Suitable if file with data is a really a very big and you can chose in which part of string you want search compared to ''grep'' that uses a whole string.<br />
{{bc|<nowiki>ArrayOfFiles=($( gawk -F '|' '{if ($3 ~ "image/jpeg" || $3 ~ "image/gif" || $3 ~ "image/png") print $1 }' info-mime-size-db.txt))</nowiki>}}<br />
<br />
You can find out which of recovered files contains spaces in their names and save information about them in a file for future use.<br />
$ find . -type f -name "* *" >> filenames-with-spaces.txt<br />
$ gawk -F'|' '{if ($1 ~ " ") print $1 }' info-mime-size-db.txt >> filenames-with-spaces.txt<br />
<br />
== Calculate duplicate files with awk ==<br />
<br />
Sort out duplicates, tests with any check summer<br />
<br />
md5sum f*.pdf | awk '// {Count[$1]++;CNames[I++]=$1}END{ for (i in Count) {if( Count[i] > 1 )print Count[i]" "CNames[A++];}}' <br />
<br />
=== Note about misc ===<br />
<br />
{{Note|Better to make a python script to speed up all of this... it has libs for management of images. Soon...month or more until I will be will be done with all my additional ideas as a command line support(srt,img,...) and much more in a single file, in a python3 version of p.rec.tsk. and related scripts, will be published on a git hub after that.}}<br />
<br />
[https://github.com/AndyCrowd/post-recovery-tasks/wiki github-wiki] - will be home of my python3 scripts.<br />
<br />
=== Original name only from photorec recovered path ===<br />
<br />
A lot of cuts but no need to use an external program/utility and can be used with loops(while/for):<br />
{{bc|<nowiki><br />
AA='./recup_dir.1/f864563104_wmcloc_kmon-0.1.0.tar.gz';<br />
ZZ=${AA/*\//};<br />
BB="${ZZ/_*/}_";<br />
echo ${ZZ/$BB/}</nowiki>}}<br />
<br />
Cuts away generated names by photorec from original, cannot be used with external loops:<br />
$ awk -F'|' '{AA=$1;sub(/^.*\//,"",AA);if ( AA ~ "_") {BB=index(AA,"_")+1; print substr(AA,BB )} }' info-mime-size-db.txt<br />
<br />
=== All in one ===<br />
<br />
Used [[User:Andy_Crowd#Folder_and_Files_-_auto_create_-_test_ground|folder and files auto create test ground]] section for {{ic|aa.txt}} in the example below.<br />
<br />
By using [https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html IFS] bash script special standard variable to change separator it is possible fill in an array with strings that contains spaces. Works perfect, will create test pattern <br />
./recup_dir.1010/f872681448_wmavgload-0.6.1.tar.gz | OName= wmavgload-0.6.1.tar.gz |<br />
./recup_dir.1010/f872688972.txt| FName= f872688972.txt |<br />
'''Full path with filename'''|'''Destination name, cut to orig if exist in it'''|<br />
<br />
In array it will use step by two with {{ic|'''<nowiki>|</nowiki>'''}} as a separator, e.g. <br />
IFS="|"<br />
C="0";<br />
A=ArrayItem[C]<br />
B=ArrayItem[C+1]<br />
C=$((C+2))<br />
<br />
{{bc|<nowiki><br />
#!/bin/bash<br />
<br />
awk -F'|' '//{AA=$1;<br />
sub(/^.*\//,"",AA);<br />
BB=AA;<br />
if ( AA ~ "_") {<br />
GUline=index(AA,"_")+1;<br />
OName=substr(AA,GUline );<br />
print $1 " | OName= " OName " |"<br />
}<br />
else {SIName=index(AA," ");<br />
if (SIName) { SWName=AA;<br />
print $1 "| SWName= " SWName " |"<br />
}<br />
print $1 "| FName= " BB " |"<br />
};<br />
}' info-mime-size-db.txt<br />
</nowiki>}}<br />
<br />
* Can cut path to show only base filename.<br />
* Can cut generated name by ''photorec'' from original.<br />
* If generated filename doesn't contain original as part of it then output generated into array.<br />
* Can fill in array with strings that contain spaces by setting up and use a new separator with help of [https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html IFS] special bash variable.<br />
<br />
See also: [http://tldp.org/LDP/abs/html/internalvariables.html internal bash variables].<br />
<br />
=== Base name only===<br />
<br />
Example base name only:<br />
$ awk -F'|' '{print $1}' info-mime-size-db.txt | sed 's/[^*/]*\///g'<br />
With {{ic|printf}} will show errors like ''not enough arguments to satisfy format string'' if variable contains some of symbols that it uses as expressions e.g {{ic|%}}:<br />
$ awk -F'|' '{AA=$1;sub(/^.*\//,"",AA);printf AA "\n"}' info-mime-size-db.txt<br />
With {{ic|print}} will show no errors because it doesn't use expressions:<br />
$ awk -F'|' '{AA=$1;sub(/^.*\//,"",AA);print AA }' info-mime-size-db.txt<br />
<br />
See also: <br />
[http://www.staff.science.uu.nl/~oostr102/docs/nawk/nawk_92.html awk manual]<br />
<br />
Two more alternatives to fill in an array with data without using of ''grep'':<br />
gawk -F '|' '{if ($1 ~ "bmp" || $1 ~ "zip") print $1 }' info-mime-size-db.txt<br />
gawk -F '|' '{AA=index($1,"png");if (AA) print $1 }' info-mime-size-db.txt<br />
<br />
=== Simple walk through folders ===<br />
This will copy files from one destination to another, based on the name or the file extension, it doesn't use or do checks for any other information about files as e.g. a mime-type or a pre-made file with the descriptions. You can modify the script depends on what kind of files you will need.<br />
This script is slow because is must go through each folder and search for files.<br />
You can download the example script «search-folder-by-folder.sh» from the [https://sourceforge.net/projects/postrecoverytasksphotorec/ SourceForge].<br><br />
<br />
== Config Alsa Note ==<br />
<br />
: ALSA advanced settings [http://www.sabi.co.uk/Notes/linuxSoundALSA.html linuxSoundALSA]<br />
<br />
== Make install - preparation ==<br />
<br />
automoc4 (req. for kde lang compile)<br />
<br />
libtoolize --force<br />
aclocal<br />
autoheader<br />
automake --force-missing --add-missing<br />
autoconf<br />
./configure<br />
make<br />
# make install<br />
<br />
One more '''make''' example for installation<br />
export LIBS=-lXext<br />
./configure --prefix=/usr --x-libraries=/usr/lib<br />
# make <br />
make prefix="$pkgdir/usr" "libexecdir=$pkgdir/usr/bin" install<br />
<br />
# make all-recursive<br />
<br />
See also<br />
xmkmf<br />
imake<br />
cmake<br />
<br />
== List installed from custom or official repositories ==<br />
<br />
RepoName="custom"<br />
<br />
List all installed that are not in custom repository<br />
<br />
$ pacman -Ss | grep -i 'installed' | grep '/' | grep -v -e ^"$RepoName" -e ^' ' | awk -F'[// ]' '{print $2}'<br />
<br />
List all that are in custom repository <br />
<br />
$ pacman -Ss | grep -i 'installed' | grep '/' | grep "$RepoName" | grep -v ^' ' | awk -F'[/\/ ]' '{print $2}'<br />
<br />
== Prepare a safe restoration/reset of the whole storage device ==<br />
<br />
Here will be described basic theoretical steps about how to make more easier restore of the default operation system (e.g. Arch Linux), just by using "Reset" function made by you that will be very useful for beginners/common users or if you will have plans to sell computers with a preferred Linux.<br />
<br />
* The initial factory set up must be stored on the write protected storage device such as e.g. [[Wikipedia:Secure Digital SD cards|Secure Digital SD cards]] that can be physically locked into the read only mode.<br />
* The latest updated factory set up must be stored on the writeable storage device or on a separate partition but with limited access such as write protected mount predefined in fstab and/or use in additional mount scripts mount.* with checks which device/partition is mounted and allow mount only in READ ONLY mode for a normal user.<br />
* It also good to have those destinations hidden in a file managers menu.<br />
* The BIOS will need to be configured to boot from SD Card. The SD card need to be permanent attached and sealed(glued).<br />
<br />
You can make your own custom Live CD with [[Archiso]] that must have functions:<br />
* Health monitoring tools such as {{Pkg|smartmontools}} to show errors and instructions what to do if destination storage device is damaged.<br />
* Restore whole storage device with tools as {{Pkg|fsarchiver}} from the back up image if the main partition is damaged or have it as an option<br />
* Retrieve updates from the internet if it is available.<br />
* Use latest created "ISO" if it is available to install updates<br />
<br />
The additional ISO on a separate partition can be created after a certain amount of updates predefined by you or manually by user.<br />
<br />
On the first login user must get an opportunity to choose a cloud server where was stored the list of all installed applications and updated configuration files.<br />
<br />
On PC the restoration media can be stored inside the box by connecting to USB card with adaptor. Laptops are missing the ability of storing extra storage devices inside that can be used for repair purposes, but some of them can have place for the addition storage that can be connected to them such as [[Wikipedia:Secure Digital SD cards|Secure Digital SD cards]] where can be stored only initial "factory" ISO and optionally also the internal storage device back up image.<br />
<br />
== Virtual Box ==<br />
<br />
The information about path to harddisks and the snapshots is stored between {{ic|<HardDisks> .... </HardDisks>}} tags in the file with the '''.vbox''' extension. You can edit them manually or use this script where you will need only change the path or use defaults, assumed that '''.vbox''' is in the same directory. It will print out new configuration to stdout.<br />
<br />
{{bc|1=<br />
#!/bin/bash<br />
NewPath="${PWD}/"<br />
Snapshots="${NewPath}/"<br />
Filename="$1"<br />
<br />
awk -v SetPath="$NewPath" -v SnapPath="$Snapshots" '{if(index($0,"vdi") != 0){A=$3;split(A,B,"=");<br />
L=B[2];<br />
gsub(/\"/,"",L);<br />
sub(/^.*\//,"",L);<br />
sub(/^.*\\/,"",L);<br />
if(index($3,"{") != 0){SnapS=SnapPath}else{SnapS=""};<br />
print $1" "$2" location=\""SetPath SnapS L"\" "$4" "$5}<br />
else print $0}' $Filename}}<br />
<br />
{{Note|If you will move/clone to virtualbox in Windows then in the path name end you should use backslash \ instead of / .}}<br />
<br />
== Thanks ==<br />
<br />
To [https://bbs.archlinux.org/viewtopic.php?pid=1440259#p1440259 Trible] for showing some of advanced awk functionality, find duplicate x/y in a text file.<br />
awk -F '|' '// { Count[$3 "|" $5]++; } END { for (i in Count) { printf "%s|%s\n", i, Count[i]; }}' /path/to/file<br />
<br />
To [http://www.linuxforums.org/forum/programming-scripting/202882-duplicates-python3-array.html#post958148 gregm] for help about how to count a duplicate strings in an array due population of it in a {{Pkg|python}} script.<br />
<br />
To [http://www.linuxquestions.org/questions/programming-9/how-to-myarray%5Binterger%5D%3Dmyarray%5Binteger%5D-1-in-python3-4175520075/#post5244323 dugan] about how to search integer duplicates in an array and information about using of a default fill in array without actually predefining it with a data.{{bc|1=from collections import defaultdict<br />
DD = defaultdict(int)}}<br />
To [[User:Alad|Alad]] for info about a [http://www.shellcheck.net/ bash spell check]. I really needed it.<br />
<br />
To [[wikipedia:蔡依林|蔡依林]] for the unbelievable Great voice and always the best performance ever!<br />
<br />
----<br />
Crash > test > Ouch > solution > if empty > Wiki</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=User_talk:Indigo&diff=441557User talk:Indigo2016-07-15T17:12:20Z<p>Andy Crowd: /* wipe-safe-at */ forgot to sign.</p>
<hr />
<div>Feel free to leave comments about my wiki edits or other points of interest. Please note I have changed preferences so that the account does not automatically watch articles I edit. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 23:31, 1 August 2015 (UTC)<br />
<br />
== Comments ==<br />
<br />
== wipe-safe-at ==<br />
<br />
Hi! If you don't mind and have time then can you help with my second man page? I have cleaned up the code in the script with necessary comments and also wrote much about code in the man page, I don't know if it is a good idea but for them who want to edit and customize the script it might be useful.<br />
[https://github.com/AndyCrowd/safe-disk-wiper/blob/master/man-page.wipe,txt man-page]<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:33, 29 April 2016 (UTC)).<br />
<br />
:Hi, sure, I'll reply here when I had time to look at it. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 08:12, 30 April 2016 (UTC)<br />
<br />
:Hi, I had a look at your manpage for the tool. A number of the options don't make sense for me, i.e. I regard them as misleading. Examples of what I think is misleading: <br />
# --order mentions some command shortcuts (ddr, ddz, cprs,cpz) but these are explained nowhere. <br />
# With --show-me you require the user to use a "-e NO_DRY" .. well, have a look what [[w:Dry_run_(testing)]] usually means for a tool. Your usage of --no-dry-run (also "$NO_DRY" mentioned later in the example output) is - to my understanding - totally contrary to regular usage. <br />
# What does --safety=2/max (default) result in, if the tool "will stop if at least one partition is mounted"? Of course there is at least one partition mounted (/). <br />
<br />
:I think your tool is more a hack for yourself to perform wipe actions you frequently perform. I don't see really how a user can benefit from the wiping part, because if a user understands the bash methods output in the first place, it is simpler to perform to create a dd command than to figure the method you define. Overall, I don't think you should package the tool as is (personal opinion, do as you wish of course). It does not make things simpler for a user. <br />
:The main benefit of the tool is to provide a wrapper around dd, so that no mounted partitions can be wiped by error. Ok, but that does not require such complicated scripting, you have already contributed [[Securely wipe disk/Tips and tricks#Prevent wiping mounted partitions]] for that, which users can [[Alias]] around dd, if they so prefer. <br />
<br />
:I can improve the english of the manpage, but with misleading options that does not mean users get help. So, I'd rather not do that. Have a think about it how to proceed. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 20:19, 1 May 2016 (UTC)<br />
<br />
:: I will remove many options from {{AUR|wipe-safe-at}} many options and will leave only '''dd''' command. I made another one that may be is much better for beginners, it doesn't wipe anything but only shows preconfigured commands that can be used to wipe a destination. To use for wiping is only need to copy/paste output or combine with commands xargs,cut,grep [[https://github.com/AndyCrowd/genwipe.sh/blob/master/genwipe.sh genwipe.sh]], take a look when you have time. I don't think that man page is necessary for genwipe.sh.(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 15:50, 14 July 2016 (UTC)).<br />
<br />
::: Yes, good choice to drop the options. Three suggestions: (1) You should add a short sentence about what it does at the beginning of help (e.g. "This script helps to calculate parameters to '''wipe''' a device/partition with dd.") (2) At [https://github.com/AndyCrowd/genwipe.sh/blob/master/genwipe.sh#L47] you should say what "execute" means. (3) the commands at Line48 and 50 need to be swapped. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 20:56, 14 July 2016 (UTC)<br />
<br />
:::: Is it OK if I will add something like "Thanks to: Indigo" into the "ShowHelp" in the [[https://github.com/AndyCrowd/genwipe.sh/blob/master/genwipe.sh genwipe.sh]]. It is finished now except grammar, all left to do is only to add more examples for different tools that need some of the device parameters. The "wipe-safe-at" will be removed from AUR. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:11, 15 July 2016 (UTC)).<br />
<br />
== <s>Question about style regarding snippets</s> ==<br />
<br />
Hi, I recently added the section about [[Etckeeper#Using_etckeeper_provided_hook|Using etckeeper provided hooks]] on the etckeeper page.<br />
I see that you are a wiki administrator. There is one thing about style and the wiki I don't really know, which is, whether we keep the<br />
comments in sample code ''as present in the original file'' or we edit them.<br />
<br />
The small snippet of configuration included in the page was using the [https://github.com/joeyh/etckeeper/blob/master/etckeeper.conf#L45|exact verbiage used in the original configuration file].<br />
<br />
The comments in the configuration snippet were put as they were in the configuration file to help finding the proper location and also give the context sensitive information they intend to give. What would be the proper etiquette about quoting partial configuration files? I don't think the [[Help:Style]] page touches that specific subject, except about the eliding of redundant lines.<br />
<br />
I will not myself revert the change, as I think it would be rude to basically go after a Wiki Administrator's changes.<br />
<br />
Thanks!<br />
<br />
(Once resolved, this can be deleted from your talk page, if you wish)<br />
<br />
[[User:Samueldr|Samueldr]] ([[User talk:Samueldr|talk]]) 14:40, 19 June 2016 (UTC)<br />
<br />
:Hi, thanks for your comment. I did not check and was unaware you quoted the original configuration file. You are right, we should not change wording in such cases - that can be confusing to the reader indeed. But since the comments are there anyway and upstream may change wording of comments, whereas naming of options is less likely to change as quick, hopefully:), my suggestion would be to leave out the comments from the code out in total and just make an example of it. <br />
:I did this with [https://wiki.archlinux.org/index.php?title=Etckeeper&type=revision&diff=438544&oldid=438543] now. <br />
:Relevant style part is [[Help:Style#Code formatting]] (keeping in mind the note about comments in [[Help:Style#Command line text]]). I close this. If you are unhappy with the result, just reply here or expand the example instructions of that section again a little. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 16:59, 19 June 2016 (UTC)</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=User_talk:Indigo&diff=441556User talk:Indigo2016-07-15T17:11:48Z<p>Andy Crowd: /* wipe-safe-at */ re:</p>
<hr />
<div>Feel free to leave comments about my wiki edits or other points of interest. Please note I have changed preferences so that the account does not automatically watch articles I edit. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 23:31, 1 August 2015 (UTC)<br />
<br />
== Comments ==<br />
<br />
== wipe-safe-at ==<br />
<br />
Hi! If you don't mind and have time then can you help with my second man page? I have cleaned up the code in the script with necessary comments and also wrote much about code in the man page, I don't know if it is a good idea but for them who want to edit and customize the script it might be useful.<br />
[https://github.com/AndyCrowd/safe-disk-wiper/blob/master/man-page.wipe,txt man-page]<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:33, 29 April 2016 (UTC)).<br />
<br />
:Hi, sure, I'll reply here when I had time to look at it. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 08:12, 30 April 2016 (UTC)<br />
<br />
:Hi, I had a look at your manpage for the tool. A number of the options don't make sense for me, i.e. I regard them as misleading. Examples of what I think is misleading: <br />
# --order mentions some command shortcuts (ddr, ddz, cprs,cpz) but these are explained nowhere. <br />
# With --show-me you require the user to use a "-e NO_DRY" .. well, have a look what [[w:Dry_run_(testing)]] usually means for a tool. Your usage of --no-dry-run (also "$NO_DRY" mentioned later in the example output) is - to my understanding - totally contrary to regular usage. <br />
# What does --safety=2/max (default) result in, if the tool "will stop if at least one partition is mounted"? Of course there is at least one partition mounted (/). <br />
<br />
:I think your tool is more a hack for yourself to perform wipe actions you frequently perform. I don't see really how a user can benefit from the wiping part, because if a user understands the bash methods output in the first place, it is simpler to perform to create a dd command than to figure the method you define. Overall, I don't think you should package the tool as is (personal opinion, do as you wish of course). It does not make things simpler for a user. <br />
:The main benefit of the tool is to provide a wrapper around dd, so that no mounted partitions can be wiped by error. Ok, but that does not require such complicated scripting, you have already contributed [[Securely wipe disk/Tips and tricks#Prevent wiping mounted partitions]] for that, which users can [[Alias]] around dd, if they so prefer. <br />
<br />
:I can improve the english of the manpage, but with misleading options that does not mean users get help. So, I'd rather not do that. Have a think about it how to proceed. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 20:19, 1 May 2016 (UTC)<br />
<br />
:: I will remove many options from {{AUR|wipe-safe-at}} many options and will leave only '''dd''' command. I made another one that may be is much better for beginners, it doesn't wipe anything but only shows preconfigured commands that can be used to wipe a destination. To use for wiping is only need to copy/paste output or combine with commands xargs,cut,grep [[https://github.com/AndyCrowd/genwipe.sh/blob/master/genwipe.sh genwipe.sh]], take a look when you have time. I don't think that man page is necessary for genwipe.sh.(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 15:50, 14 July 2016 (UTC)).<br />
<br />
::: Yes, good choice to drop the options. Three suggestions: (1) You should add a short sentence about what it does at the beginning of help (e.g. "This script helps to calculate parameters to '''wipe''' a device/partition with dd.") (2) At [https://github.com/AndyCrowd/genwipe.sh/blob/master/genwipe.sh#L47] you should say what "execute" means. (3) the commands at Line48 and 50 need to be swapped. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 20:56, 14 July 2016 (UTC)<br />
<br />
:::: Is it OK if I will add something like "Thanks to: Indigo" into the "ShowHelp" in the [[https://github.com/AndyCrowd/genwipe.sh/blob/master/genwipe.sh genwipe.sh]]. It is finished now except grammar, all left to do is only to add more examples for different tools that need some of the device parameters. The "wipe-safe-at" will be removed from AUR.<br />
<br />
== <s>Question about style regarding snippets</s> ==<br />
<br />
Hi, I recently added the section about [[Etckeeper#Using_etckeeper_provided_hook|Using etckeeper provided hooks]] on the etckeeper page.<br />
I see that you are a wiki administrator. There is one thing about style and the wiki I don't really know, which is, whether we keep the<br />
comments in sample code ''as present in the original file'' or we edit them.<br />
<br />
The small snippet of configuration included in the page was using the [https://github.com/joeyh/etckeeper/blob/master/etckeeper.conf#L45|exact verbiage used in the original configuration file].<br />
<br />
The comments in the configuration snippet were put as they were in the configuration file to help finding the proper location and also give the context sensitive information they intend to give. What would be the proper etiquette about quoting partial configuration files? I don't think the [[Help:Style]] page touches that specific subject, except about the eliding of redundant lines.<br />
<br />
I will not myself revert the change, as I think it would be rude to basically go after a Wiki Administrator's changes.<br />
<br />
Thanks!<br />
<br />
(Once resolved, this can be deleted from your talk page, if you wish)<br />
<br />
[[User:Samueldr|Samueldr]] ([[User talk:Samueldr|talk]]) 14:40, 19 June 2016 (UTC)<br />
<br />
:Hi, thanks for your comment. I did not check and was unaware you quoted the original configuration file. You are right, we should not change wording in such cases - that can be confusing to the reader indeed. But since the comments are there anyway and upstream may change wording of comments, whereas naming of options is less likely to change as quick, hopefully:), my suggestion would be to leave out the comments from the code out in total and just make an example of it. <br />
:I did this with [https://wiki.archlinux.org/index.php?title=Etckeeper&type=revision&diff=438544&oldid=438543] now. <br />
:Relevant style part is [[Help:Style#Code formatting]] (keeping in mind the note about comments in [[Help:Style#Command line text]]). I close this. If you are unhappy with the result, just reply here or expand the example instructions of that section again a little. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 16:59, 19 June 2016 (UTC)</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Securely_wipe_disk&diff=441535Securely wipe disk2016-07-15T14:07:18Z<p>Andy Crowd: /* Select a block size */ updated Tip description</p>
<hr />
<div>[[Category:Security]]<br />
[[Category:File systems]]<br />
[[ja:ディスクの完全消去]]<br />
{{Related articles start}}<br />
{{Related|Securely wipe disk/Tips and tricks}}<br />
{{Related|File recovery}}<br />
{{Related|Benchmarking/Data storage devices}}<br />
{{Related|Frandom}}<br />
{{Related|Disk encryption#Preparing the disk}}<br />
{{Related|dm-crypt}}<br />
{{Related articles end}}<br />
Wiping a disk is done by writing new data over every single bit.<br />
<br />
{{Note|References to "disks" in this article also apply to loopback devices.}}<br />
<br />
== Common use cases ==<br />
<br />
=== Wipe all data left on the device ===<br />
<br />
The most common usecase for completely and irrevocably wiping a device will be when the device is going to be given away or sold. There may be (unencrypted) data left on the device and you want to protect against simple forensic investigation that is mere child's play with for example [[File recovery]] software.<br />
<br />
If you want to quickly wipe everything from the disk, {{ic|/dev/zero}} or simple patterns allow maximum performance while adequate randomness can be advantageous in some cases that should be covered up in [[#Data remanence]].<br />
<br />
Every overwritten bit means to provide a level of data erasure not allowing recovery with normal system functions (like standard ATA/SCSI commands) and hardware interfaces. Any file recovery software mentioned above then would need to be specialized on proprietary storage-hardware features.<br />
<br />
In case of a HDD data recreation will not be possible without at least undocumented drive commands or fiddling about the device’s controller or firmware to make them read out for example reallocated sectors (bad blocks that [[S.M.A.R.T.]] retired from use).<br />
<br />
There are different wiping issues with different physical storage technologies, most notably all Flash memory based devices and older magnetic storage (old HDD's, floppy disks, tape).<br />
<br />
=== Preparations for block device encryption ===<br />
<br />
If you want to prepare your drive to securely set up [[Disk encryption#Block device encryption]] inside the wiped area afterwards you really should use [[#Random data]] generated by a trusted cryptographically strong random number generator (referred to as RNG in this article from now on).<br />
<br />
See also [[Wikipedia:Random number generation]].<br />
<br />
{{Warning|If Block device encryption is mapped on a partition that contains anything else than random/encrypted data, disclosure of usage patterns on the encrypted drive is possible and weakens the encryption being comparable with filesystem-level-encryption. Never use {{ic|/dev/zero}}, simple patterns (badblocks, eg.) or other unrandom data before setting up Block device encryption if you are serious about it!}}<br />
<br />
== Data remanence ==<br />
<br />
See also [[Wikipedia:Data remanence]].<br />
<br />
The residual representation of data may remain even after attempts have been made to remove or erase the data.<br />
<br />
Residual data may get wiped by writing (random) data to the disk with a single or even more than one iteration. However, more than one iteration may not significantly decrease the possibility to reconstruct the data of hard disk drives. See [[#Residual magnetism]]. <br />
<br />
=== Operating system, programs and filesystem ===<br />
<br />
The operating system, executed programs or [[Wikipedia:Journaling file system|journaling file system]]s may copy your unencrypted data throughout the block device. When writing to plain disks this should only be relevant in conjunction with one of the above.<br />
<br />
If the data can get exactly located on the disk and was never copied anywhere else, wiping with random data can be thoroughgoing and impressively quick as long there is enough entropy in the pool.<br />
<br />
A good example is cryptsetup using {{ic|/dev/urandom}} for [[Dm-crypt/Device encryption#Key management|wiping the LUKS keyslots]].<br />
<br />
=== Hardware-specific issues ===<br />
<br />
==== Flash memory ====<br />
<br />
[[Wikipedia:Write amplification|Write amplification]] and other characteristics make Flash memory (explicitly including SSDs) a stubborn target for reliable wiping.<br />
As there is a lot of transparent abstraction in between data as seen by a device's controller chip and the operating system sight data is never overwritten in place and wiping particular blocks or files is not reliable.<br />
<br />
Other "features" like transparent compression (all SandForce SSD's) can compress your /dev/zero or pattern stream so if wiping is fast beyond belief this might be the case.<br />
<br />
Disassembling Flash memory devices, unsoldering the chips and analyzing data content without the controller in between is feasible without difficulty using [http://www.flash-extractor.com/manual/reader_models/ simple hardware]. Data recovery companys do it for cheap money.<br />
<br />
For more information see:<br />
<br />
* [[SSD memory cell clearing]]<br />
* [http://www.usenix.org/events/fast11/tech/full_papers/Wei.pdf Reliably Erasing Data From Flash-Based Solid State Drives].<br />
* [[#Select a target]]<br />
==== Marked Bad Sectors ====<br />
<br />
If a hard drive marks a sector as bad, it cordons it off, and the section becomes impossible to write to via software. Thus a full overwrite would not reach it. However because of block sizes, these sections would only amount to a few theoretically recoverable KB.<br />
<br />
==== Residual magnetism ====<br />
<br />
A single, full overwrite with zeros or random data does not lead to any recoverable data on a modern high-density storage device.[http://www.howtogeek.com/115573/htg-explains-why-you-only-have-to-wipe-a-disk-once-to-erase-it/] Indications otherwise refer to single residual bits; reconstruction of byte patterns is generally not feasible.[https://web.archive.org/web/20120102004746/http://www.h-online.com/newsticker/news/item/Secure-deletion-a-single-overwrite-will-do-it-739699.html] See also [https://www.google.com/search?tbs=bks:1&q=isbn:9783540898610], [http://security.stackexchange.com/questions/26132/is-data-remanence-a-myth/26134#26134] and [http://www.nber.org/sys-admin/overwritten-data-guttman.html].<br />
<br />
{{Remove|This argument directly goes against the source linked above [http://www.nber.org/sys-admin/overwritten-data-guttman.html], which, while not academic, looks at existing material on the subject and concludes against the importance of "data remanence". In contrast, the argument below gives no actual references on its claim, only referring to general material which describes the terms used. [[w:Data_remanence#Feasibility_of_recovering_overwritten_data]] should do a better job at covering this issue, and we're already linking to that article from the top of [[#Data remanence]].}}<br />
<br />
Overwriting old magnetic storage devices (e.g. floppy disks, magnetic tape, early-generation hard drives) only once can instead allow the wiped data to be reconstructed by analyzing the measured [[Wikipedia:Remanence|residual magnetics]], due to much lower [[Wikipedia:Memory storage density|memory storage density]]. Such devices can get disassembled in a cleanroom and then analyzed with equipment like a [[Wikipedia:Magnetic force microscope|magnetic force microscope]]. This method of data recovery requires however substantial financial resources. For this reason, it is advisable to overwrite old storage devices multiple times; [[Wikipedia:Degaussing#Degaussing magnetic data storage media|degaussing]] is another practiced countermeasure, and to ensure that data has been completely erased, most resources even advise physical destruction.<br />
<br />
== Select a target ==<br />
<br />
{{Note|Fdisk will not work on [[GPT]] formatted devices. Use gdisk ({{Pkg|gptfdisk}}) instead.}}<br />
Use fdisk to locate all read/write devices the user has read acess to.<br />
<br />
Check the output for lines that start with devices such as {{ic|/dev/sd"X"}}.<br />
<br />
This is an example for a HDD formatted to boot a linux system:<br />
<br />
{{hc|# fdisk -l|<nowiki>Disk /dev/sda: 250.1 GB, 250059350016 bytes, 488397168 sectors<br />
Units = sectors of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
Disk identifier: 0x00ff784a<br />
<br />
Device Boot Start End Blocks Id System<br />
/dev/sda1 * 2048 206847 102400 83 Linux<br />
/dev/sda2 206848 488397167 244095160 83 Linux</nowiki>}}<br />
<br />
Or the Arch Install Medium written to a 4GB USB thumb drive:<br />
<br />
{{hc|# fdisk -l|<nowiki>Disk /dev/sdb: 4075 MB, 4075290624 bytes, 7959552 sectors<br />
Units = sectors of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
Disk identifier: 0x526e236e<br />
<br />
Device Boot Start End Blocks Id System<br />
/dev/sdb1 * 0 802815 401408 17 Hidden HPFS/NTFS</nowiki>}}<br />
<br />
If you are worried about unintentional damage of important data on the primary computer, consider using an isolated environment such as a virtual environment (VirtualBox, VMWare, QEMU, etc...) with direct connected disk drives to it or a single computer only with a storage disk(s) that need to be wiped booted from a [[Archiso|Live Media]](USB, CD, PXE, etc...) or use a script to [[Securely wipe disk/Tips and tricks#Prevent wiping mounted partitions|prevent wiping mounted partitions by typo]].<br />
<br />
== Select a block size ==<br />
<br />
See also [[Wikipedia:Dd (Unix)#Block size]], [http://people.redhat.com/msnitzer/docs/io-limits.txt blocksize io-limits].<br />
<br />
If you have an [[Wikipedia:Advanced Format|Advanced Format]] hard drive it is recommended that you specify a block size larger than the default 512 bytes. To speed up the overwriting process choose a block size matching your drive's physical geometry by appending the block size option to the ''dd'' command (i.e. {{ic|<nowiki>bs=4096</nowiki>}} for 4KB).<br />
<br />
''fdisk'' prints physical and logical sector size for every disk. <br />
<br />
Alternatively sysfs does expose information:<br />
/sys/block/sdX/size<br />
/sys/block/sdX/queue/physical_block_size<br />
/sys/block/sdX/queue/logical_block_size<br />
/sys/block/sdX/sdXY/alignment_offset<br />
/sys/block/sdX/sdXY/start<br />
/sys/block/sdX/sdXY/size<br />
<br />
{{Tip|This script helps to calculate parameters to wipe a device/partition with dd {{AUR|genwipe.sh}}, e.g.{{ic| genwipe.sh /dev/sd"XY"}}.}}<br />
<br />
=== Calculate blocks to wipe manually ===<br />
<br />
In the following the determination of the data area to wipe is done in an example. <br />
<br />
A block storage devices contains sectors and a size of a single sector that can be used to calculate the whole size of device in bytes. You can do it by multiplying sectors with size of the sector.<br />
<br />
As an example we use the parameters with the ''dd'' command to wipe a partition: <br />
<br />
# dd if=''data_source'' of=/dev/sd"X" bs=''sector_size'' count=''sector_number'' seek=''partitions_start_sector''<br />
<br />
Here you will see only a part of output of {{ic|fdisk -l /dev/sdX}} with root, showing the example partition information: <br />
<br />
{{bc|Device Boot Start End Sectors Size Id Type<br />
/dev/sd"XA" 2048 3839711231 3839709184 1,8T 83 Linux<br />
/dev/sd"XB" 3839711232 3907029167 67317936 32,1G 5 Extended<br />
}}<br />
<br />
The first line of the ''fdisk'' output shows the disk size in bytes and logical sectors:<br />
<br />
Disk /dev/sd"X": 1,8 TiB, 2000398934016 bytes, 3907029168 sectors<br />
<br />
To calculate size of a single logical sector use {{ic|echo $((2000398934016 / 3907029168))}} or use data from the second line of ''fdisk'' output:<br />
<br />
Units: sectors of 1 * 512 = 512 bytes<br />
<br />
To calculate physical sectors that will make it work faster we can use the third line:<br />
<br />
Sector size (logical/physical): 512 bytes / 4096 bytes<br />
<br />
To get disk size in the physical sectors you will need the known disk size in bytes divided with size of a single physical sector {{ic|echo $((2000398934016 / 4096))}}, you can get size of the storage device or partition on it even with the {{ic|blockdev --getsize64 /dev/sd"XY"}} command.<br />
<br />
{{Note|<br />
* In the examples below we will use the logical sector size.<br />
* You can even wipe unallocated disk space with a {{ic|dd}} command by calculating the difference between the end of one and start of the next partition.}}<br />
<br />
To wipe partition {{ic|/dev/sd"XA"}} the example parameters with logical sectors would be used like this: <br />
<br />
{{bc|1=Start=2048<br />
End=3839711231<br />
BytesInSector=512}}<br />
<br />
By using the starting address of the partition on the device by defining it in the {{ic|1=seek=}} option<br />
<br />
# dd if=''data_source'' of=/dev/sd"X" bs=${BytesInSector} count=${End} seek=${Start}<br />
<br />
By using the partitions name<br />
<br />
{{bc|1=LogicalSectors=3839709184}}<br />
<br />
# dd if=''data_source'' of=/dev/sd"XA" bs=${BytesInSector} count=${LogicalSectors}<br />
<br />
Or, to wipe the whole disk by using physical sectors:<br />
<br />
{{bc|1=AllDiskPhysicalSectors=488378646<br />
PhysicalSectorSizeBytes=4096}}<br />
<br />
# dd if=''data_source'' of=/dev/sd"X" bs=${PhysicalSectorSizeBytes} count=${AllDiskPhysicalSectors} seek=0<br />
<br />
{{Note|The {{ic|1=count=}} option not necessary when wiping the physical limited area e.g. {{ic|sd"XY"}} or {{ic|sd"X"}} from begin to the end but will show an error about out of free space when will try to write outside of limits.}}<br />
<br />
== Select a data source ==<br />
<br />
As just said If you want to wipe sensitive data you can use anything matching your needs. <br />
<br />
If you want to setup block device encryption afterwards, you should always wipe at least with an encryption cipher as source or even pseudorandom data.<br />
<br />
For data that is not truly random your disk's writing speed should be the only limiting factor. If you need random data, the required system performance to generate it may extremely depend on what you choose as source of entropy.<br />
<br />
=== Non-random data ===<br />
<br />
Overwriting with {{ic|/dev/zero}} or simple patterns is considered secure in most resources. In the case of current HDD's it should be sufficient for fast disk wipes.<br />
<br />
{{Warning|A drive that is abnormally fast in writing patterns or zeroing could be doing transparent compression. It is obviously presumable not all blocks get wiped this way. Some [[#Flash memory]] devices do "feature" that.}}<br />
<br />
==== Pattern write test ====<br />
<br />
[[#Badblocks]] can write simple patterns to every block of a device and then read and check them searching for damaged areas (just like memtest86* does with memory).<br />
<br />
As the pattern is written to every accesible block this effectively wipes the device.<br />
<br />
=== Random data ===<br />
<br />
For differences between random and pseudorandom data as source, please see [[Random number generation]].<br />
<br />
{{Note|Data that is hard to compress (random data) will get written slower, if the drive logic mentioned in the [[#Non-random data]] warning tries compressing it. This should not lead to [[#Data remanence]] though. As maximum write-speed is not the performance-bottleneck it can get completely neglected while wiping disks with random data.}}<br />
<br />
=== Encrypted data ===<br />
<br />
When preparing a drive for full-disk encryption, sourcing high quality entropy is usually not necessary. The alternative is to use an encrypted datastream. For example, if you will use AES for your encrypted partition, you would wipe it with an equivalent encryption cipher prior to creating the filesystem to make the empty space not distinguishable from the used space.<br />
<br />
== Overwrite the target ==<br />
<br />
The chosen drive can be overwritten with several utilities, make your choice. If you only want to wipe a single file, [[Securely wipe disk/Tips and tricks#Wipe a single file]] has considerations in addition to the utilities mentioned below. <br />
<br />
=== By redirecting output ===<br />
<br />
The redirected output can be used both for creation of the files to rewrite free space on the partition, wipe the whole device or a single partition on it.<br />
<br />
In the following are examples that can be used to rewrite the partition or a block device by redirecting [http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-3.html stdout] from other utilities: <br />
<br />
{{hc|$ cat /dev/urandom > /dev/sd"XY"|<br />
cat: write error: No space left on device}}<br />
<br />
{{hc|$ xz -z0 /dev/urandom -c > /dev/sd"XY"|<br />
xz: (stdout): Write error: No space left on device}}<br />
<br />
{{hc|1=$ dd if=/dev/urandom > /dev/sd"XY"|2=<br />
dd: writing to ‘standard output’: No space left on device<br />
20481+0 records in<br />
20480+0 records out<br />
10485760 bytes (10 MB) copied, 2.29914 s, 4.6 MB/s}}<br />
<br />
The file copy command {{ic|cp}} can also be used to rewrite the device, because it ignores the type of the destination:<br />
<br />
{{hc|$ cp /dev/urandom /dev/sd"XY"|<br />
cp: error writing ‘/dev/sd"XY"’: No space left on device<br />
cp: failed to extend ‘/dev/sd"XY"’: No space left on device}}<br />
<br />
To show speed and time you can use {{Pkg|pv}}:<br />
<br />
# pv --timer --rate --stop-at-size -s "$(blockdev --getsize64 /dev/sd"XY" )" /dev/zero > /dev/sd"XY"<br />
<br />
=== dd ===<br />
<br />
See also [[Core utilities#dd]].<br />
<br />
{{Warning|There is no confirmation regarding the sanity of this command so '''repeatedly check''' that the correct drive or partition has been targeted. Make certain that the {{ic|<nowiki>of=...</nowiki>}} option points to the target drive and not to a system disk.}}<br />
<br />
Zero-fill the disk by writing a zero byte to every addressable location on the disk using the [[Wikipedia:/dev/zero|/dev/zero]] stream. {{ic|iflag}} and {{ic|oflag}} as below will try to disable buffering, which is senseless for a constant stream.<br />
<br />
# dd if=/dev/zero of=/dev/sdX iflag=nocache oflag=direct bs=4096<br />
<br />
Or the [[Wikipedia:/dev/random|/dev/urandom]] stream:<br />
# dd if=/dev/urandom of=/dev/sdX bs=4096<br />
<br />
The process is finished when dd reports, {{ic|No space left on device}}:<br />
dd: writing to ‘/dev/sdb’: No space left on device<br />
7959553+0 records in<br />
7959552+0 records out<br />
4075290624 bytes (4.1 GB) copied, 1247.7 s, 3.3 MB/s<br />
<br />
To speed up wiping a large drive, see also: <br />
* [[Securely wipe disk/Tips and tricks#dd - advanced example]] which uses OpenSSL, <br />
* [[Securely wipe disk/Tips and tricks#Using a template file]] which wipes with non-random preset data(e.g. overwrite a whole disk with a single file) but is very fast<br />
* [[Dm-crypt/Drive preparation#dm-crypt specific methods]] which uses dm-crypt.<br />
<br />
=== wipe ===<br />
<br />
Specialized on wiping files and is available as the {{Pkg|wipe}} package. To make a quick wipe of a destination you can use something like:<br />
<br />
$ wipe -r -q /path/to/wipe<br />
<br />
See also:<br />
[http://linux.die.net/man/1/wipe man page].<br />
<br />
=== shred ===<br />
<br />
[https://www.gnu.org/software/coreutils/manual/html_node/shred-invocation.html ''shred''] (from the {{Pkg|coreutils}} package) is a Unix command that can be used to securely delete individual files or full devices so that they can be recovered only with great difficulty with specialised hardware, if at all. ''shred'' uses three passes, writing [[Random number generation|pseudo-random data]] to the device during each pass. This can be reduced or increased.<br />
<br />
The following command invokes shred with its default settings and displays the progress.<br />
# shred -v /dev/sd''X''<br />
<br />
Alternatively, shred can be instructed to do only one pass, with entropy from e.g. {{ic|/dev/urandom}}.<br />
# shred --verbose --random-source=/dev/urandom -n1 /dev/sd''X''<br />
<br />
=== Badblocks ===<br />
<br />
For letting badblocks (from the {{Pkg|e2fsprogs}} package) perform a disk wipe, a destructive [[Badblocks#read-write_Test|read-write test]] has to be done:<br />
<br />
# badblocks -c <NUMBER_BLOCKS> -wsv /dev/<drive><br />
<br />
=== hdparm ===<br />
{{warning|Do not attempt to issue a Secure Erase ATA command on a device connected through USB; see https://ata.wiki.kernel.org/index.php/ATA_Secure_Erase and http://www.tomshardware.co.uk/answers/id-1984547/secure-erase-external-usb-hard-drive.html for details.}}<br />
<br />
[[hdparm]] supports [http://tinyapps.org/docs/wipe_drives_hdparm.html ATA Secure Erase], which is functionally equivalent to zero-filling a disk. It is however handled by the hard-drive firmware itself, and includes "hidden data areas". As such, it can be seen as a modern-day "low-level format" command. [[SSD]] drives reportedly achieve factory performance after issuing this command, but may not be sufficiently wiped (see [[#Flash memory]]).<br />
<br />
Some drives support '''Enhanced Secure Erase''', which uses distinct patterns defined by the manufacturer. If the output of {{ic|hdparm -I}} for the device indicates a manifold time advantage for the '''Enhanced''' erasure, the device probably has a hardware encryption feature and the wipe will be performed to the encryption keys only. <br />
<br />
For detailed instructions on using ATA Secure Erase, see the [https://ata.wiki.kernel.org/index.php/ATA_Secure_Erase Linux ATA wiki].<br />
<br />
=== secure-delete ===<br />
<br />
The {{AUR|secure-delete}} package from [[AUR]] provides several utilites for secure erasion, including {{ic|sfill}}, which deletes only free space in a specified mount. For example:<br />
<br />
# sfill -v /<br />
<br />
See [http://superuser.com/questions/19326/how-to-wipe-free-disk-space-in-linux the tools list] for more info.</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=User_talk:Indigo&diff=441416User talk:Indigo2016-07-14T15:51:44Z<p>Andy Crowd: /* wipe-safe-at */ re:</p>
<hr />
<div>Feel free to leave comments about my wiki edits or other points of interest. Please note I have changed preferences so that the account does not automatically watch articles I edit. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 23:31, 1 August 2015 (UTC)<br />
<br />
== Comments ==<br />
<br />
== wipe-safe-at ==<br />
<br />
Hi! If you don't mind and have time then can you help with my second man page? I have cleaned up the code in the script with necessary comments and also wrote much about code in the man page, I don't know if it is a good idea but for them who want to edit and customize the script it might be useful.<br />
[https://github.com/AndyCrowd/safe-disk-wiper/blob/master/man-page.wipe,txt man-page]<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:33, 29 April 2016 (UTC)).<br />
<br />
:Hi, sure, I'll reply here when I had time to look at it. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 08:12, 30 April 2016 (UTC)<br />
<br />
:Hi, I had a look at your manpage for the tool. A number of the options don't make sense for me, i.e. I regard them as misleading. Examples of what I think is misleading: <br />
# --order mentions some command shortcuts (ddr, ddz, cprs,cpz) but these are explained nowhere. <br />
# With --show-me you require the user to use a "-e NO_DRY" .. well, have a look what [[w:Dry_run_(testing)]] usually means for a tool. Your usage of --no-dry-run (also "$NO_DRY" mentioned later in the example output) is - to my understanding - totally contrary to regular usage. <br />
# What does --safety=2/max (default) result in, if the tool "will stop if at least one partition is mounted"? Of course there is at least one partition mounted (/). <br />
<br />
:I think your tool is more a hack for yourself to perform wipe actions you frequently perform. I don't see really how a user can benefit from the wiping part, because if a user understands the bash methods output in the first place, it is simpler to perform to create a dd command than to figure the method you define. Overall, I don't think you should package the tool as is (personal opinion, do as you wish of course). It does not make things simpler for a user. <br />
:The main benefit of the tool is to provide a wrapper around dd, so that no mounted partitions can be wiped by error. Ok, but that does not require such complicated scripting, you have already contributed [[Securely wipe disk/Tips and tricks#Prevent wiping mounted partitions]] for that, which users can [[Alias]] around dd, if they so prefer. <br />
<br />
:I can improve the english of the manpage, but with misleading options that does not mean users get help. So, I'd rather not do that. Have a think about it how to proceed. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 20:19, 1 May 2016 (UTC)<br />
<br />
:: I will remove many options from {{AUR|wipe-safe-at}} many options and will leave only '''dd''' command. I made another one that may be is much better for beginners, it doesn't wipe anything but only shows preconfigured commands that can be used to wipe a destination. To use for wiping is only need to copy/paste output or combine with commands xargs,cut,grep [[https://github.com/AndyCrowd/genwipe.sh/blob/master/genwipe.sh genwipe.sh]], take a look when you have time. I don't think that man page is necessary for genwipe.sh.(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 15:50, 14 July 2016 (UTC)).<br />
<br />
== <s>Question about style regarding snippets</s> ==<br />
<br />
Hi, I recently added the section about [[Etckeeper#Using_etckeeper_provided_hook|Using etckeeper provided hooks]] on the etckeeper page.<br />
I see that you are a wiki administrator. There is one thing about style and the wiki I don't really know, which is, whether we keep the<br />
comments in sample code ''as present in the original file'' or we edit them.<br />
<br />
The small snippet of configuration included in the page was using the [https://github.com/joeyh/etckeeper/blob/master/etckeeper.conf#L45|exact verbiage used in the original configuration file].<br />
<br />
The comments in the configuration snippet were put as they were in the configuration file to help finding the proper location and also give the context sensitive information they intend to give. What would be the proper etiquette about quoting partial configuration files? I don't think the [[Help:Style]] page touches that specific subject, except about the eliding of redundant lines.<br />
<br />
I will not myself revert the change, as I think it would be rude to basically go after a Wiki Administrator's changes.<br />
<br />
Thanks!<br />
<br />
(Once resolved, this can be deleted from your talk page, if you wish)<br />
<br />
[[User:Samueldr|Samueldr]] ([[User talk:Samueldr|talk]]) 14:40, 19 June 2016 (UTC)<br />
<br />
:Hi, thanks for your comment. I did not check and was unaware you quoted the original configuration file. You are right, we should not change wording in such cases - that can be confusing to the reader indeed. But since the comments are there anyway and upstream may change wording of comments, whereas naming of options is less likely to change as quick, hopefully:), my suggestion would be to leave out the comments from the code out in total and just make an example of it. <br />
:I did this with [https://wiki.archlinux.org/index.php?title=Etckeeper&type=revision&diff=438544&oldid=438543] now. <br />
:Relevant style part is [[Help:Style#Code formatting]] (keeping in mind the note about comments in [[Help:Style#Command line text]]). I close this. If you are unhappy with the result, just reply here or expand the example instructions of that section again a little. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 16:59, 19 June 2016 (UTC)</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Securely_wipe_disk&diff=441222Securely wipe disk2016-07-13T18:28:08Z<p>Andy Crowd: /* Select a block size */ Added Tip about "genwipe.sh" to show examples for dd with already preset values.</p>
<hr />
<div>[[Category:Security]]<br />
[[Category:File systems]]<br />
[[ja:ディスクの完全消去]]<br />
{{Related articles start}}<br />
{{Related|Securely wipe disk/Tips and tricks}}<br />
{{Related|File recovery}}<br />
{{Related|Benchmarking/Data storage devices}}<br />
{{Related|Frandom}}<br />
{{Related|Disk encryption#Preparing the disk}}<br />
{{Related|dm-crypt}}<br />
{{Related articles end}}<br />
Wiping a disk is done by writing new data over every single bit.<br />
<br />
{{Note|References to "disks" in this article also apply to loopback devices.}}<br />
<br />
== Common use cases ==<br />
<br />
=== Wipe all data left on the device ===<br />
<br />
The most common usecase for completely and irrevocably wiping a device will be when the device is going to be given away or sold. There may be (unencrypted) data left on the device and you want to protect against simple forensic investigation that is mere child's play with for example [[File recovery]] software.<br />
<br />
If you want to quickly wipe everything from the disk, {{ic|/dev/zero}} or simple patterns allow maximum performance while adequate randomness can be advantageous in some cases that should be covered up in [[#Data remanence]].<br />
<br />
Every overwritten bit means to provide a level of data erasure not allowing recovery with normal system functions (like standard ATA/SCSI commands) and hardware interfaces. Any file recovery software mentioned above then would need to be specialized on proprietary storage-hardware features.<br />
<br />
In case of a HDD data recreation will not be possible without at least undocumented drive commands or fiddling about the device’s controller or firmware to make them read out for example reallocated sectors (bad blocks that [[S.M.A.R.T.]] retired from use).<br />
<br />
There are different wiping issues with different physical storage technologies, most notably all Flash memory based devices and older magnetic storage (old HDD's, floppy disks, tape).<br />
<br />
=== Preparations for block device encryption ===<br />
<br />
If you want to prepare your drive to securely set up [[Disk encryption#Block device encryption]] inside the wiped area afterwards you really should use [[#Random data]] generated by a trusted cryptographically strong random number generator (referred to as RNG in this article from now on).<br />
<br />
See also [[Wikipedia:Random number generation]].<br />
<br />
{{Warning|If Block device encryption is mapped on a partition that contains anything else than random/encrypted data, disclosure of usage patterns on the encrypted drive is possible and weakens the encryption being comparable with filesystem-level-encryption. Never use {{ic|/dev/zero}}, simple patterns (badblocks, eg.) or other unrandom data before setting up Block device encryption if you are serious about it!}}<br />
<br />
== Data remanence ==<br />
<br />
See also [[Wikipedia:Data remanence]].<br />
<br />
The residual representation of data may remain even after attempts have been made to remove or erase the data.<br />
<br />
Residual data may get wiped by writing (random) data to the disk with a single or even more than one iteration. However, more than one iteration may not significantly decrease the possibility to reconstruct the data of hard disk drives. See [[#Residual magnetism]]. <br />
<br />
=== Operating system, programs and filesystem ===<br />
<br />
The operating system, executed programs or [[Wikipedia:Journaling file system|journaling file system]]s may copy your unencrypted data throughout the block device. When writing to plain disks this should only be relevant in conjunction with one of the above.<br />
<br />
If the data can get exactly located on the disk and was never copied anywhere else, wiping with random data can be thoroughgoing and impressively quick as long there is enough entropy in the pool.<br />
<br />
A good example is cryptsetup using {{ic|/dev/urandom}} for [[Dm-crypt/Device encryption#Key management|wiping the LUKS keyslots]].<br />
<br />
=== Hardware-specific issues ===<br />
<br />
==== Flash memory ====<br />
<br />
[[Wikipedia:Write amplification|Write amplification]] and other characteristics make Flash memory (explicitly including SSDs) a stubborn target for reliable wiping.<br />
As there is a lot of transparent abstraction in between data as seen by a device's controller chip and the operating system sight data is never overwritten in place and wiping particular blocks or files is not reliable.<br />
<br />
Other "features" like transparent compression (all SandForce SSD's) can compress your /dev/zero or pattern stream so if wiping is fast beyond belief this might be the case.<br />
<br />
Disassembling Flash memory devices, unsoldering the chips and analyzing data content without the controller in between is feasible without difficulty using [http://www.flash-extractor.com/manual/reader_models/ simple hardware]. Data recovery companys do it for cheap money.<br />
<br />
For more information see:<br />
<br />
* [[SSD memory cell clearing]]<br />
* [http://www.usenix.org/events/fast11/tech/full_papers/Wei.pdf Reliably Erasing Data From Flash-Based Solid State Drives].<br />
* [[#Select a target]]<br />
==== Marked Bad Sectors ====<br />
<br />
If a hard drive marks a sector as bad, it cordons it off, and the section becomes impossible to write to via software. Thus a full overwrite would not reach it. However because of block sizes, these sections would only amount to a few theoretically recoverable KB.<br />
<br />
==== Residual magnetism ====<br />
<br />
A single, full overwrite with zeros or random data does not lead to any recoverable data on a modern high-density storage device.[http://www.howtogeek.com/115573/htg-explains-why-you-only-have-to-wipe-a-disk-once-to-erase-it/] Indications otherwise refer to single residual bits; reconstruction of byte patterns is generally not feasible.[https://web.archive.org/web/20120102004746/http://www.h-online.com/newsticker/news/item/Secure-deletion-a-single-overwrite-will-do-it-739699.html] See also [https://www.google.com/search?tbs=bks:1&q=isbn:9783540898610], [http://security.stackexchange.com/questions/26132/is-data-remanence-a-myth/26134#26134] and [http://www.nber.org/sys-admin/overwritten-data-guttman.html].<br />
<br />
{{Remove|This argument directly goes against the source linked above [http://www.nber.org/sys-admin/overwritten-data-guttman.html], which, while not academic, looks at existing material on the subject and concludes against the importance of "data remanence". In contrast, the argument below gives no actual references on its claim, only referring to general material which describes the terms used. [[w:Data_remanence#Feasibility_of_recovering_overwritten_data]] should do a better job at covering this issue, and we're already linking to that article from the top of [[#Data remanence]].}}<br />
<br />
Overwriting old magnetic storage devices (e.g. floppy disks, magnetic tape, early-generation hard drives) only once can instead allow the wiped data to be reconstructed by analyzing the measured [[Wikipedia:Remanence|residual magnetics]], due to much lower [[Wikipedia:Memory storage density|memory storage density]]. Such devices can get disassembled in a cleanroom and then analyzed with equipment like a [[Wikipedia:Magnetic force microscope|magnetic force microscope]]. This method of data recovery requires however substantial financial resources. For this reason, it is advisable to overwrite old storage devices multiple times; [[Wikipedia:Degaussing#Degaussing magnetic data storage media|degaussing]] is another practiced countermeasure, and to ensure that data has been completely erased, most resources even advise physical destruction.<br />
<br />
== Select a target ==<br />
<br />
{{Note|Fdisk will not work on [[GPT]] formatted devices. Use gdisk ({{Pkg|gptfdisk}}) instead.}}<br />
Use fdisk to locate all read/write devices the user has read acess to.<br />
<br />
Check the output for lines that start with devices such as {{ic|/dev/sd"X"}}.<br />
<br />
This is an example for a HDD formatted to boot a linux system:<br />
<br />
{{hc|# fdisk -l|<nowiki>Disk /dev/sda: 250.1 GB, 250059350016 bytes, 488397168 sectors<br />
Units = sectors of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
Disk identifier: 0x00ff784a<br />
<br />
Device Boot Start End Blocks Id System<br />
/dev/sda1 * 2048 206847 102400 83 Linux<br />
/dev/sda2 206848 488397167 244095160 83 Linux</nowiki>}}<br />
<br />
Or the Arch Install Medium written to a 4GB USB thumb drive:<br />
<br />
{{hc|# fdisk -l|<nowiki>Disk /dev/sdb: 4075 MB, 4075290624 bytes, 7959552 sectors<br />
Units = sectors of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
Disk identifier: 0x526e236e<br />
<br />
Device Boot Start End Blocks Id System<br />
/dev/sdb1 * 0 802815 401408 17 Hidden HPFS/NTFS</nowiki>}}<br />
<br />
If you are worried about unintentional damage of important data on the primary computer, consider using an isolated environment such as a virtual environment (VirtualBox, VMWare, QEMU, etc...) with direct connected disk drives to it or a single computer only with a storage disk(s) that need to be wiped booted from a [[Archiso|Live Media]](USB, CD, PXE, etc...) or use a script to [[Securely wipe disk/Tips and tricks#Prevent wiping mounted partitions|prevent wiping mounted partitions by typo]].<br />
<br />
== Select a block size ==<br />
<br />
See also [[Wikipedia:Dd (Unix)#Block size]], [http://people.redhat.com/msnitzer/docs/io-limits.txt blocksize io-limits].<br />
<br />
If you have an [[Wikipedia:Advanced Format|Advanced Format]] hard drive it is recommended that you specify a block size larger than the default 512 bytes. To speed up the overwriting process choose a block size matching your drive's physical geometry by appending the block size option to the ''dd'' command (i.e. {{ic|<nowiki>bs=4096</nowiki>}} for 4KB).<br />
<br />
''fdisk'' prints physical and logical sector size for every disk. <br />
<br />
Alternatively sysfs does expose information:<br />
/sys/block/sdX/size<br />
/sys/block/sdX/queue/physical_block_size<br />
/sys/block/sdX/queue/logical_block_size<br />
/sys/block/sdX/sdXY/alignment_offset<br />
/sys/block/sdX/sdXY/start<br />
/sys/block/sdX/sdXY/size<br />
<br />
{{Tip|To show calculated dd examples for the destination storage device use {{AUR|genwipe.sh}}, e.g.{{ic| genwipe.sh /dev/sd"XY"}}.}}<br />
<br />
=== Calculate blocks to wipe manually ===<br />
<br />
In the following the determination of the data area to wipe is done in an example. <br />
<br />
A block storage devices contains sectors and a size of a single sector that can be used to calculate the whole size of device in bytes. You can do it by multiplying sectors with size of the sector.<br />
<br />
As an example we use the parameters with the ''dd'' command to wipe a partition: <br />
<br />
# dd if=''data_source'' of=/dev/sd"X" bs=''sector_size'' count=''sector_number'' seek=''partitions_start_sector''<br />
<br />
Here you will see only a part of output of {{ic|fdisk -l /dev/sdX}} with root, showing the example partition information: <br />
<br />
{{bc|Device Boot Start End Sectors Size Id Type<br />
/dev/sd"XA" 2048 3839711231 3839709184 1,8T 83 Linux<br />
/dev/sd"XB" 3839711232 3907029167 67317936 32,1G 5 Extended<br />
}}<br />
<br />
The first line of the ''fdisk'' output shows the disk size in bytes and logical sectors:<br />
<br />
Disk /dev/sd"X": 1,8 TiB, 2000398934016 bytes, 3907029168 sectors<br />
<br />
To calculate size of a single logical sector use {{ic|echo $((2000398934016 / 3907029168))}} or use data from the second line of ''fdisk'' output:<br />
<br />
Units: sectors of 1 * 512 = 512 bytes<br />
<br />
To calculate physical sectors that will make it work faster we can use the third line:<br />
<br />
Sector size (logical/physical): 512 bytes / 4096 bytes<br />
<br />
To get disk size in the physical sectors you will need the known disk size in bytes divided with size of a single physical sector {{ic|echo $((2000398934016 / 4096))}}, you can get size of the storage device or partition on it even with the {{ic|blockdev --getsize64 /dev/sd"XY"}} command.<br />
<br />
{{Note|<br />
* In the examples below we will use the logical sector size.<br />
* You can even wipe unallocated disk space with a {{ic|dd}} command by calculating the difference between the end of one and start of the next partition.}}<br />
<br />
To wipe partition {{ic|/dev/sd"XA"}} the example parameters with logical sectors would be used like this: <br />
<br />
{{bc|1=Start=2048<br />
End=3839711231<br />
BytesInSector=512}}<br />
<br />
By using the starting address of the partition on the device by defining it in the {{ic|1=seek=}} option<br />
<br />
# dd if=''data_source'' of=/dev/sd"X" bs=${BytesInSector} count=${End} seek=${Start}<br />
<br />
By using the partitions name<br />
<br />
{{bc|1=LogicalSectors=3839709184}}<br />
<br />
# dd if=''data_source'' of=/dev/sd"XA" bs=${BytesInSector} count=${LogicalSectors}<br />
<br />
Or, to wipe the whole disk by using physical sectors:<br />
<br />
{{bc|1=AllDiskPhysicalSectors=488378646<br />
PhysicalSectorSizeBytes=4096}}<br />
<br />
# dd if=''data_source'' of=/dev/sd"X" bs=${PhysicalSectorSizeBytes} count=${AllDiskPhysicalSectors} seek=0<br />
<br />
{{Note|The {{ic|1=count=}} option not necessary when wiping the physical limited area e.g. {{ic|sd"XY"}} or {{ic|sd"X"}} from begin to the end but will show an error about out of free space when will try to write outside of limits.}}<br />
<br />
== Select a data source ==<br />
<br />
As just said If you want to wipe sensitive data you can use anything matching your needs. <br />
<br />
If you want to setup block device encryption afterwards, you should always wipe at least with an encryption cipher as source or even pseudorandom data.<br />
<br />
For data that is not truly random your disk's writing speed should be the only limiting factor. If you need random data, the required system performance to generate it may extremely depend on what you choose as source of entropy.<br />
<br />
=== Non-random data ===<br />
<br />
Overwriting with {{ic|/dev/zero}} or simple patterns is considered secure in most resources. In the case of current HDD's it should be sufficient for fast disk wipes.<br />
<br />
{{Warning|A drive that is abnormally fast in writing patterns or zeroing could be doing transparent compression. It is obviously presumable not all blocks get wiped this way. Some [[#Flash memory]] devices do "feature" that.}}<br />
<br />
==== Pattern write test ====<br />
<br />
[[#Badblocks]] can write simple patterns to every block of a device and then read and check them searching for damaged areas (just like memtest86* does with memory).<br />
<br />
As the pattern is written to every accesible block this effectively wipes the device.<br />
<br />
=== Random data ===<br />
<br />
For differences between random and pseudorandom data as source, please see [[Random number generation]].<br />
<br />
{{Note|Data that is hard to compress (random data) will get written slower, if the drive logic mentioned in the [[#Non-random data]] warning tries compressing it. This should not lead to [[#Data remanence]] though. As maximum write-speed is not the performance-bottleneck it can get completely neglected while wiping disks with random data.}}<br />
<br />
=== Encrypted data ===<br />
<br />
When preparing a drive for full-disk encryption, sourcing high quality entropy is usually not necessary. The alternative is to use an encrypted datastream. For example, if you will use AES for your encrypted partition, you would wipe it with an equivalent encryption cipher prior to creating the filesystem to make the empty space not distinguishable from the used space.<br />
<br />
== Overwrite the target ==<br />
<br />
The chosen drive can be overwritten with several utilities, make your choice. If you only want to wipe a single file, [[Securely wipe disk/Tips and tricks#Wipe a single file]] has considerations in addition to the utilities mentioned below. <br />
<br />
=== By redirecting output ===<br />
<br />
The redirected output can be used both for creation of the files to rewrite free space on the partition, wipe the whole device or a single partition on it.<br />
<br />
In the following are examples that can be used to rewrite the partition or a block device by redirecting [http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-3.html stdout] from other utilities: <br />
<br />
{{hc|$ cat /dev/urandom > /dev/sd"XY"|<br />
cat: write error: No space left on device}}<br />
<br />
{{hc|$ xz -z0 /dev/urandom -c > /dev/sd"XY"|<br />
xz: (stdout): Write error: No space left on device}}<br />
<br />
{{hc|1=$ dd if=/dev/urandom > /dev/sd"XY"|2=<br />
dd: writing to ‘standard output’: No space left on device<br />
20481+0 records in<br />
20480+0 records out<br />
10485760 bytes (10 MB) copied, 2.29914 s, 4.6 MB/s}}<br />
<br />
The file copy command {{ic|cp}} can also be used to rewrite the device, because it ignores the type of the destination:<br />
<br />
{{hc|$ cp /dev/urandom /dev/sd"XY"|<br />
cp: error writing ‘/dev/sd"XY"’: No space left on device<br />
cp: failed to extend ‘/dev/sd"XY"’: No space left on device}}<br />
<br />
To show speed and time you can use {{Pkg|pv}}:<br />
<br />
# pv --timer --rate --stop-at-size -s "$(blockdev --getsize64 /dev/sd"XY" )" /dev/zero > /dev/sd"XY"<br />
<br />
=== dd ===<br />
<br />
See also [[Core utilities#dd]].<br />
<br />
{{Warning|There is no confirmation regarding the sanity of this command so '''repeatedly check''' that the correct drive or partition has been targeted. Make certain that the {{ic|<nowiki>of=...</nowiki>}} option points to the target drive and not to a system disk.}}<br />
<br />
Zero-fill the disk by writing a zero byte to every addressable location on the disk using the [[Wikipedia:/dev/zero|/dev/zero]] stream. {{ic|iflag}} and {{ic|oflag}} as below will try to disable buffering, which is senseless for a constant stream.<br />
<br />
# dd if=/dev/zero of=/dev/sdX iflag=nocache oflag=direct bs=4096<br />
<br />
Or the [[Wikipedia:/dev/random|/dev/urandom]] stream:<br />
# dd if=/dev/urandom of=/dev/sdX bs=4096<br />
<br />
The process is finished when dd reports, {{ic|No space left on device}}:<br />
dd: writing to ‘/dev/sdb’: No space left on device<br />
7959553+0 records in<br />
7959552+0 records out<br />
4075290624 bytes (4.1 GB) copied, 1247.7 s, 3.3 MB/s<br />
<br />
To speed up wiping a large drive, see also: <br />
* [[Securely wipe disk/Tips and tricks#dd - advanced example]] which uses OpenSSL, <br />
* [[Securely wipe disk/Tips and tricks#Using a template file]] which wipes with non-random preset data(e.g. overwrite a whole disk with a single file) but is very fast<br />
* [[Dm-crypt/Drive preparation#dm-crypt specific methods]] which uses dm-crypt.<br />
<br />
=== wipe ===<br />
<br />
Specialized on wiping files and is available as the {{Pkg|wipe}} package. To make a quick wipe of a destination you can use something like:<br />
<br />
$ wipe -r -q /path/to/wipe<br />
<br />
See also:<br />
[http://linux.die.net/man/1/wipe man page].<br />
<br />
=== shred ===<br />
<br />
[https://www.gnu.org/software/coreutils/manual/html_node/shred-invocation.html ''shred''] (from the {{Pkg|coreutils}} package) is a Unix command that can be used to securely delete individual files or full devices so that they can be recovered only with great difficulty with specialised hardware, if at all. ''shred'' uses three passes, writing [[Random number generation|pseudo-random data]] to the device during each pass. This can be reduced or increased.<br />
<br />
The following command invokes shred with its default settings and displays the progress.<br />
# shred -v /dev/sd''X''<br />
<br />
Alternatively, shred can be instructed to do only one pass, with entropy from e.g. {{ic|/dev/urandom}}.<br />
# shred --verbose --random-source=/dev/urandom -n1 /dev/sd''X''<br />
<br />
=== Badblocks ===<br />
<br />
For letting badblocks (from the {{Pkg|e2fsprogs}} package) perform a disk wipe, a destructive [[Badblocks#read-write_Test|read-write test]] has to be done:<br />
<br />
# badblocks -c <NUMBER_BLOCKS> -wsv /dev/<drive><br />
<br />
=== hdparm ===<br />
{{warning|Do not attempt to issue a Secure Erase ATA command on a device connected through USB; see https://ata.wiki.kernel.org/index.php/ATA_Secure_Erase and http://www.tomshardware.co.uk/answers/id-1984547/secure-erase-external-usb-hard-drive.html for details.}}<br />
<br />
[[hdparm]] supports [http://tinyapps.org/docs/wipe_drives_hdparm.html ATA Secure Erase], which is functionally equivalent to zero-filling a disk. It is however handled by the hard-drive firmware itself, and includes "hidden data areas". As such, it can be seen as a modern-day "low-level format" command. [[SSD]] drives reportedly achieve factory performance after issuing this command, but may not be sufficiently wiped (see [[#Flash memory]]).<br />
<br />
Some drives support '''Enhanced Secure Erase''', which uses distinct patterns defined by the manufacturer. If the output of {{ic|hdparm -I}} for the device indicates a manifold time advantage for the '''Enhanced''' erasure, the device probably has a hardware encryption feature and the wipe will be performed to the encryption keys only. <br />
<br />
For detailed instructions on using ATA Secure Erase, see the [https://ata.wiki.kernel.org/index.php/ATA_Secure_Erase Linux ATA wiki].<br />
<br />
=== secure-delete ===<br />
<br />
The {{AUR|secure-delete}} package from [[AUR]] provides several utilites for secure erasion, including {{ic|sfill}}, which deletes only free space in a specified mount. For example:<br />
<br />
# sfill -v /<br />
<br />
See [http://superuser.com/questions/19326/how-to-wipe-free-disk-space-in-linux the tools list] for more info.</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=XDG_MIME_Applications&diff=436891XDG MIME Applications2016-06-01T18:56:48Z<p>Andy Crowd: /* Example: .xml and related .desktop configuration */Created Note // added function into my script to show(list) file name extensions with their description found in .xml files</p>
<hr />
<div>[[Category:Desktop environments]]<br />
[[ja:デフォルトアプリケーション]]<br />
[[ru:Changing filetype association via MIME]]<br />
[[zh-cn:Default applications]]<br />
{{Related articles start}}<br />
{{Related|Desktop entries}}<br />
{{Related|Desktop environment}}<br />
{{Related|Window manager}}<br />
{{Related articles end}}<br />
<br />
Setting default applications per file type involves detection of the file type as the first step. Since the application launcher cannot fully understand all file types, the detection is based on reading only a small part of the file. There are two common ways to determine the file type:<br />
<br />
* using the file name extension, for example ''.html'' or ''.jpeg''<br />
* using the so-called "magic bytes" at the start of the file<br />
<br />
The first method is very simple and fast, but inaccurate if the file is not named "correctly". The second is more accurate, but slower.<br />
<br />
Since files are not required to have an extension and multiple file name extensions can be used for the same file type, [[w:MIME type|MIME type]]s are commonly used instead to uniquely represent the type of a file. In Arch, tools from the {{Pkg|shared-mime-info}} package are used to maintain the MIME type database, which is used by other packages to register new MIME types. Each package can also use the [[Desktop entries]] to provide information about the MIME types that can be handled by the packaged software. There is frequently more than one application able to handle data of a certain MIME type, so users and even some packages (e.g. [[desktop environments]]) assemble lists of default applications for each MIME type.<br />
<br />
Note that while Arch Linux does not provide custom presets for default applications, the [[desktop environment]] you install may do so. Some desktop environments also provide a GUI or a file-manager which enables to interactively configure default applications for certain file extensions. If this suffices for your system usage, you may not need to configure anything further. <br />
<br />
The scope of this article are the freedesktop [https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html Association between MIME types and applications] specification and related parts of the [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176 Shared MIME-info Database] specification. <br />
<br />
== MIME types and desktop entries ==<br />
<br />
{{Expansion|Complete list available at: [http://www.iana.org/assignments/media-types/media-types.xhtml]. Not sure if it's needed to maintain a summarized version in this article.}}<br />
<br />
MIME-types are specified by two slash ({{ic|/}}) parts: ''Type/Extension'', for example {{ic|video/x-ms-wmv}}. The second part of the MIME-type is expanding faster, for example with new applications or data encoding standards. <br />
<br />
The default applications to open a MIME-type are usually stored in [[#Default mimeapps.list paths|mimeapps.list]] files, but some programs store MIME-type associations in their own custom configuration files. If a MIME-type association is not found in the default configuration, the program should look for the first match of the MIME-type in ''.desktop'' files. <br />
<br />
Description of some MIME-type first part and examples of second parts:<br />
<br />
{| class="wikitable"<br />
! Type of MIME (1st part) !! Description !! Examples of extension (2nd part)<br />
|-<br />
|application || Files with binary content such, e.g.: documents,archives,... || epub+zip, ereader, excel, gbr, gzip<br />
|-<br />
|audio || Audio files that that can be played by a music player or audio editor || flac, m4a, midi<br />
|-<br />
|chemical || Chemical information, molecular and other chemical data || x-cif, x-cml, x-daylight-smiles, x-gamess-input, x-gamess-output, x-gaussian-checkpoint, x-gaussian-cube, x-gaussian-log, x-mopac-out, x-pdb, x-qchem-output, x-xyz<br />
|-<br />
|image || Image files that can be opened by image editor or image viewer || bmp, crw, g3fax, gif, jp2, jpeg, jpeg2000, jpg<br />
|-<br />
|inode || Can be opened by a file manager || blockdevice, chardevice, directory, fifo, mount-point, socket, symlink<br />
|-<br />
|message || Message protocols || delivery-status, disposition-notification, external-body, news, partial, rfc822, x-gnu-rmail<br />
|-<br />
|misc || Streaming meta data || ultravox<br />
|-<br />
|text || Text documents that can be viewed (e.g. with command ''less'') or opened with a text editor || html, javascript, mathml, mml, plain<br />
|-<br />
|video || Video files that can be played or edited with a video editor || flv, mp2t, mp4<br />
|-<br />
|x-content || Content on disks such as e.g. Audio,Video,Image or blank disk || audio-cdda, audio-player, blank-bd, blank-cd, blank-dvd, blank-hddvd, image-picturecd, video-dvd, video-svcd, video-vcd<br />
|-<br />
|x-scheme-handler || Internet protocol || ftp, geo, ghelp, help, http, https, hwplay, icy, icyx, info, irc, magnet, mailto, man, mms, mmsh, net, pnm, rtmp, rtp, rtsp, skype, uvox, vnc, xmpp<br />
|-<br />
|x-epoc || SISX package ||x-sisx-app<br />
|-<br />
|multipart || Multi-part mime messages ||alternative, appledouble, digest, encrypted, mixed, related, report, signed, x-mixed-replace<br />
|-<br />
|model || such as 3D model || x-kpovmodeler, vrml, x-modelica<br />
|}<br />
<br />
For the description of MIME-types you can search in XDG database:<br />
$ grep -e 'mime-type type=' -e '<comment>' /usr/share/mime/packages/freedesktop.org.xml<br />
<br />
{{Tip|To see all MIME extensions in the system's ''.desktop'' files that belongs to a MIME-type you can use {{AUR|lsdesktopf}}, for example {{ic|lsdesktopf --gm -gx video}}, to search available in ''.xml'' configuration/database files use {{ic|lsdesktopf --gdx -gx video}}.}} <br />
<br />
If you ever require to create a custom association of a new file extension to a MIME-type, see the <br />
the short [[#Example: .xml and related .desktop configuration]] and the [http://standards.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html Association between MIME types and applications] standard.<br />
<br />
== Set default applications == <br />
<br />
In order to set a default application, you need to <br />
* decide which of the [[#Default mimeapps.list files]] is applicable for your case and, <br />
* change the [[#Configuration of the mimeapps.list file]] accordingly. <br />
<br />
Any manual configuration of the [[#Shared MIME-info database]] is only required, if the application is not setup correctly or desktop does not comply to the standard yet.<br />
<br />
=== Default mimeapps.list files ===<br />
<br />
{{Expansion|Moving deprecated configuration files to a Note, rather than include them in the table, would improve overview. More context on the changing of the file location could also be useful.}}<br />
<br />
The {{ic|mimeapps.list}} file stores the configuration for the default application to open a MIME-type. <br />
There are different locations for it: <br />
* system-wide, <br />
* per-user, <br />
* custom locations used by some programs.<br />
<br />
The {{ic|''$desktop''}} in the following list denotes the name of the related desktop environment or window manager. The search order of paths is: <br />
<br />
{| class="wikitable"<br />
! Path !! Usage<br />
|-<br />
| {{ic|$HOME/.config/''$desktop''-mimeapps.list}} || user overrides, desktop-specific<br />
|-<br />
| {{ic|$HOME/.config/mimeapps.list}} || user overrides<br />
|-<br />
| {{ic|/etc/xdg/''$desktop''-mimeapps.list}} || sysadmin and vendor overrides, desktop-specific<br />
|-<br />
| {{ic|/etc/xdg/mimeapps.list}} || sysadmin and vendor overrides<br />
|-<br />
| {{ic|$HOME/.local/share/applications/''$desktop''-mimeapps.list}} || for compatibility but now deprecated, desktop-specific<br />
|-<br />
| {{ic|$HOME/.local/share/applications/mimeapps.list}} || for compatibility but now deprecated<br />
|-<br />
| {{ic|/usr/local/share/applications/''$desktop''-mimeapps.list}}<br>{{ic|/usr/share/applications/$desktop-mimeapps.list}} || distribution-provided defaults, desktop-specific<br />
|-<br />
| {{ic|/usr/local/share/applications/mimeapps.list}}<br>{{ic|/usr/share/applications/mimeapps.list}} || distribution-provided defaults<br />
|}<br />
<br />
=== Configuration of the mimeapps.list file ===<br />
<br />
The file contains two main sections for default and additional alternatives to open files of a MIME-type. The second and the third section ({{ic|[Removed Associations]}}) are optional. <br />
<br />
If the application installed a correct [[desktop entry]] file (examples used below {{ic|default1.desktop}}, {{ic|foo1.desktop}}, etc.), it contains the registered MIME-types it can handle. To '''set a default application''', all you need to do is adjust the associations in the respective {{ic|mimeapps.list}} (see also the freedesktop [https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html#associations specification]). <br />
<br />
For example, the following sets {{ic|default1.desktop}} to open {{ic|mimetype1}}: <br />
<br />
[Default Applications]<br />
mimetype1=default1.desktop<br />
<br />
Defined additional associations of applications to MIME-types (these might appear in file manager ''Open with'' GUI, for example):<br />
[Added Associations]<br />
mimetype1=foo1.desktop;foo2.desktop;foo3.desktop;<br />
mimetype2=foo4.desktop;<br />
<br />
Removed associations of applications with MIME-types (blacklisting a MIME-type association of an application in its ''.desktop'' file):<br />
[Removed Associations]<br />
mimetype1=foo5.desktop<br />
<br />
Multiple ''.desktop'' files for a single MIME-type must be semicolon-separated. Not supported entries are ignored in {{ic|mimeapps.list}}. The DE/WM then searches for the first match to the needed MIME-type them in the default path for ''.desktop'' files. <br />
<br />
{{Tip|To get a quick overview of how many and which ''.desktop'' files can be associated with a certain MIME-type, you can use the {{AUR|lsdesktopf}} utility, e.g. {{ic|lsdesktopf --gen-mimeapps}}.}}<br />
<br />
{{Note|Arch Linux itself does not provide system-wide presets for associations, but other distributions and specific desktop environments may do so via packaged {{ic|mimeapps.list}} files, or the older and deprecated {{ic|defaults.list}} files.}}<br />
<br />
Your choice of desktop environment, or none, will affect how your default applications are associated. Further, note that some packages use additional work-around presets, for example Mozilla's packages install a {{ic|/etc/mime.types}} file.<br />
<br />
=== Shared MIME-info database ===<br />
<br />
In background to the {{ic|mimeapps.list}} files, the system holds a database of MIME-type information registered via the installed applications' ''.desktop'' files, the [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176 Shared MIME-info Database]. It is created automatically as soon as an application depending on it is installed, via the following [[pacman#Hooks]]: <br />
* {{ic|/usr/share/libalpm/hooks/update-mime-database.hook}} from {{Pkg|shared-mime-info}} <br />
:updates the MIME-info database in {{ic|/usr/share/mime}}, in particular also the ''.xml'' specification in {{ic|/usr/share/mime/packages/freedesktop.org.xml}} for the MIME-types standards<br />
* {{ic|/usr/share/libalpm/hooks/update-desktop-database.hook}} from {{Pkg|desktop-file-utils}}<br />
:updates the {{ic|mimeinfo.cache}} located (per default) in {{ic|/usr/share/applications}}<br />
<br />
These files keep track of which MIME-types are associated with which ''.desktop'' files overall. When an application is installed, updated or removed, the pacman hooks keep the database updated accordingly. <br />
<br />
{{Warning|The database files are not meant to be edited directly.}}<br />
<br />
Application specific configuration is stored in ''.xml'' files and further files of the database (see [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176 .xml source files]) are stored in ''.keys'' and ''.mime'' files that are located in {{ic|/usr/share/mime-info/}}.<br />
<br />
Global directories for the ''.xml'' files are:<br />
<br />
/usr/share/mimelnk/application/<br />
/usr/share/mime/packages/ <br />
<br />
{{Warning|Above should not be modified, for user-specific configuration see below.}}<br />
<br />
Any user-specific ''.xml'' configuration may be stored in:<br />
~/.local/share/mime/packages/<br />
<br />
==== Example: .xml and related .desktop configuration ====<br />
<br />
The following is a short example to ''create'' files to associate an application with a MIME-type. It only needs to be followed, if the application has '''not''' setup and registered its configuration sufficiently. <br />
<br />
User-specific paths are used to override system defaults, while keeping the integrity of the rest of the system-wide configuration. <br />
<br />
Create and edit {{ic|~/.local/share/mime/packages/application-x-foobar.xml}}:<br />
<br />
{{bc|1=<br />
<?xml version="1.0" encoding="UTF-8"?><br />
<nowiki><mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"></nowiki><br />
'''<mime-type type="application/x-foobar">'''<br />
<comment>foo file</comment><br />
<icon name="application-x-foobar"/><br />
<glob-deleteall/><br />
'''<glob pattern="*.foo"/>'''<br />
</mime-type><br />
</mime-info><br />
}}<br />
{{Tip|To see all file name extensions in ''.xml'' configuration or database files, that available in ''glob pattern'', with their description in ''comment'' use {{AUR|lsdesktopf}}: {{ic|lsdesktopf --gdx -gfx}}.}}<br />
Create a related [[desktop entry]] file:<br />
<br />
{{hc|~/.local/share/applications/foobar.desktop|2=<br />
[Desktop Entry]<br />
Name=Foobar<br />
Exec=/usr/bin/foobar<br />
'''MimeType=application/x-foobar'''<br />
Icon=foobar<br />
Terminal=false<br />
Type=Application<br />
Categories=AudioVideo;Player;Video;<br />
Comment=<br />
}}<br />
<br />
Now update the application and mime database with:<br />
<br />
$ update-desktop-database ~/.local/share/applications<br />
$ update-mime-database ~/.local/share/mime<br />
<br />
Programs that use MIME-types, such as file managers, should now open {{ic|*.foo}} files with foobar (you may need to restart your file manager to see the change.)<br />
<br />
{{Style|The relation between environment variables and the above discussion on MIME types is not immediate. Setting {{ic|BROWSER}} e.a, while also related to default applications, is a different approach entirely.}}<br />
<br />
See also [[Environment variables#Examples]] about global variables that can be used in start-up scripts to set default applications for specific actions.<br />
<br />
== Utilities to manage MIME types ==<br />
<br />
Many of the file managers has options to set up and configure associations of mime types with programs. <br />
<br />
It can be done by using:<br />
<br />
* Preferences for selected file<br />
* File manager configuration menu<br />
* External program for a specific file manager<br />
<br />
Other utilities to manage MIME-types are: <br />
<br />
{{Accuracy|Packages such as {{AUR|sx-open}} may replace xdg-utils in the sense that they have a provides/replaces field to pacman, but they miss tools used by other applications such as {{ic|xdg-screensaver}} and {{ic|xdg-icon-resource}}. This is not clear from the table. The table should also be better adapted to the section below, or the "based on" section could simply be left out.}}<br />
<br />
{| class="wikitable"<br />
! Name/Package !! Method !! Based on !! xdg-utils replacement !! Configuration file<br />
|-<br />
| {{Pkg|mime-editor}} || MIME-type || Utility for [http://rox.sourceforge.net/desktop/home.html ROX] applications || ||<br />
|-<br />
| {{AUR|busking-git}} || regex || {{Pkg|perl-file-mimeinfo}} || yes || custom<br />
|-<br />
| {{AUR|linopen}} || || {{Pkg|file}} || || custom<br />
|-<br />
| {{AUR|mimeo}} || MIME-type <br> regex || {{Pkg|file}} || {{AUR|xdg-utils-mimeo}} ||{{ic|mimeapps.list}} <br> {{ic|defaults.list}} <br> custom is optional<br />
|-<br />
| {{AUR|mimi-git}} || || {{Pkg|file}} || yes || custom<br />
|-<br />
| {{ic|rifle}} <br> part of {{Pkg|ranger}} || MIME-type <br> name <br> regex || {{Pkg|file}} || || custom<br />
|-<br />
| {{AUR|sx-open}} || regex || {{Pkg|file}} <br> bash regex || yes || custom<br />
|-<br />
| {{AUR|whippet}} || MIME-type <br> name <br> regex || SQLite database <br> {{Pkg|file}} <br> {{Pkg|perl-file-mimeinfo}}, etc || xdg-open || custom SQLite database <br> {{ic|mimeapps.list}}<br />
|-<br />
| {{Pkg|xdg-utils}} || || {{Pkg|file}} <br> {{Pkg|perl-file-mimeinfo}} || ||<br />
|}<br />
<br />
=== Examples of usage ===<br />
<br />
Here is a short description about how to use command line tools to show MIME-type of a file or set preferred program as default to open MIME-type.<br />
<br />
==== Detect MIME-type ====<br />
<br />
{{Style|Unclear what is meant by "it is two standards". Going by the {{ic|Magic -> XML}} entries, the first seems to be a "compiled database", without indication how it is created. The second the XML files as described in [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.20.html]. Latter can also define file contents, and the "extension associated with one program but content is associated with another MIME-type" is vague at best.}}<br />
<br />
Tools detecting MIME-type by reading meta-data from header of the file or detecting by magic number that is in two bytes identifier in the begin of the file. See [[Wikipedia:File format#File header|File header]].<br />
<br />
Many programs are using command ''file'' to detect correct MIME-type. For detection it uses compiled database that is stored in the {{ic|/usr/share/misc/magic/}} directory. It has many options to determinate correct MIME-type and for showing output.<br />
<br />
In Linux it is two standards to detect MIME-type that can affect which program will start and open the file, e.g. extension is associated with one program but content is associated with another MIME-type. The simplest way to see what is your system prioritizes is by renaming file extension and check again with tools that can use custom [[#Associate file extensions with applications MIME-type|*.xml]] configuration files.<br />
<br />
{{Accuracy|The following sentence is true only when {{pkg|perl-file-mimeinfo}} is installed. Otherwise, ''file'' is used and hence the detection method is different.}}<br />
<br />
Here is examples of utility ''xdg-mime'' that first checking association of extension in [[#Associate file extensions with applications MIME-type|*.xml]] configuration files.<br />
{| class="wikitable"<br />
! Without extension !! With extension <br />
|-<br />
|xdg-mime query filetype ''foo-file'' || xdg-mime query filetype ''foo-file''.''jpg''<br />
|-<br />
! application/vnd.oasis.opendocument.text || image/jpeg<br />
|-<br />
|}<br />
<br />
Comparison functionality of the tools <br />
<br />
Here is shown options only for simple or multiple checks of a file, for more options read their own documentation.<br />
{| class="wikitable"<br />
! Tool !! Option !! Detection order !! Functionality !! Type !! Interface<br />
|-<br />
|file || ''(has many)'' || Magic(Byte/Pattern) || Show only || binary || terminal<br />
|-<br />
|xdg-mime || query filetype || *.xml -> Magic || Show / Set || script || terminal<br />
|-<br />
|mimetype || -i ''(*.xml)'' -M ''(Magic)'' || *.xml -> Magic || Show only || script || terminal<br />
|-<br />
|mimeo || -m || *.xml -> Magic || Show / Set / Launch || script || terminal<br />
|}<br />
<br />
==== Set use of MIME-type by default ====<br />
<br />
Comparison functionality of the tools <br />
<br />
Here is shown options only for single file associations, for more options read their own documentation.<br />
<br />
{| class="wikitable"<br />
! Tool !! Option !! Functionality !! Type !! Interface<br />
|-<br />
|xdg-mime || default ''*.desktop'' Type1/Extension1 Type2/Extension2 || Show / Set || script || terminal<br />
|-<br />
|mimeo || --prefer 'regex:^Type/(Extension'''1'''<nowiki> |</nowiki>Extension?'''2''')$' ''*.desktop'' || Show / Set / Launch || script || terminal<br />
|-<br />
|mimeopen || --ask-default ''(interactive)'' || Set / Launch || script || terminal<br />
|}<br />
<br />
=== Application launchers ===<br />
<br />
{{Style|Why start over with sections when we already have a table? Pick one.}}<br />
<br />
==== xdg-open ====<br />
<br />
''xdg-open'' (from the {{Pkg|xdg-utils}} package) uses {{Pkg|perl-file-mimeinfo}} as a fallback ("generic") method if no [[desktop environment]] is detected. It is a desktop-independent tool. Many applications invoke the {{ic|xdg-open}} command internally. Inside a [[desktop environment]] it passes the arguments to desktop supported environment's file-opener applications (e.g. ''gvfs-open'', ''kde-open'', or ''exo-open''). When no desktop environment is detected the ''xdg-open'' will use its own configuration files.<br />
<br />
==== mimeopen ====<br />
<br />
''mimeopen'' (from the {{Pkg|perl-file-mimeinfo}} package) can launch applications from command line. It can use custom database and prompt user to chose default application from a list of detected relevant and offers to chose own alternative.<br />
<br />
Example of the prompt:<br />
<br />
{{hc|$ mimeopen -d /path/to/foo-file|<br />
Please choose a default application for files of type ''Type''/''Extension''<br />
1) notepad (wine-extension-txt)<br />
2) Leafpad (leafpad)<br />
3) OpenOffice.org Writer (writer)<br />
4) gVim (gvim)<br />
5) Other...<br />
}}<br />
<br />
Your answer becomes the default handler for that type of file. Mimeopen is installed as {{ic|/usr/bin/vendor_perl/mimeopen}}.<br />
<br />
If you run ''xdg-open'' without a desktop environment, you should also install {{Pkg|perl-file-mimeinfo}}, or {{AUR|xdg-utils-mimeo}} and {{AUR|mimeo}} from the [[AUR]] for a faster alternative.<br />
<br />
==== mailcap ====<br />
<br />
The [http://linux.die.net/man/4/mailcap mailcap] file.<br />
<br />
{{Expansion|When using {{AUR|run-mailcap}}, ''xdg-open'' may refer to it.[http://cgit.freedesktop.org/xdg/xdg-utils/tree/scripts/xdg-open.in#n266] It should then clearly not be combined with the below file to prevent endless loops.}}<br />
<br />
The ''.mailcap'' file format is used by mail programs such as {{Pkg|mutt}} and {{Pkg|sylpheed}}. To have those programs use ''xdg-open'', edit {{ic|~/.mailcap}}:<br />
<br />
{{hc|~/.mailcap|<br />
*/*; xdg-open "%s"<br />
}}<br />
<br />
=== Extended practical examples ===<br />
<br />
{{Style|Redundant and oddly named header; it is also odd that alternatives are discussed before the regular {{Pkg|xdg-utils}}.}}<br />
<br />
==== xdg-open ====<br />
<br />
''xdg-mime'' modifies the local file {{ic|~/.config/mimeapps.list}} and {{ic|~/.local/share/applications/mimeapps.list}} (deprecated).<br />
<br />
To '''query''' the mime type used by an existing file, use <br />
$ xdg-mime query ''filetype'' ''file.ext''<br />
<br />
To change an associated desktop entry by setting [[Thunar]] as the default file browser:<br />
<br />
$ xdg-mime default Thunar.desktop inode/directory<br />
Note that you should not specify the complete path, but only the name of the ''.desktop'' file.<br />
<br />
This command can take multiple mime-types, allowing related files to be handled by the same program. The example below associates [[Emacs]] to all known source files:<br />
$ xdg-mime default emacs.desktop $(grep '^text/x-*' /usr/share/mime/types)<br />
<br />
===== Set the default browser =====<br />
<br />
To set the default application for {{ic|http(s)://}} internet protocols:<br />
<br />
$ xdg-mime default midori.desktop x-scheme-handler/http<br />
$ xdg-mime default midori.desktop x-scheme-handler/https<br />
<br />
As an alternative try:<br />
<br />
$ xdg-settings set default-web-browser netsurf.desktop<br />
<br />
To verify if the URLs opens correctly:<br />
<br />
$ xdg-open <nowiki>https://archlinux.org</nowiki><br />
<br />
To associate ''.html'' files with the {{Pkg|netsurf}} web-browser:<br />
<br />
$ xdg-mime default netsurf.desktop text/html<br />
<br />
== Troubleshooting == <br />
<br />
=== Variables in .desktop files that affect application launch ===<br />
<br />
{{Expansion|1=The fact {{ic|MimeType}} entries may be missing in the desktop files is only implied here, i.e. "Even if an application...", though this is a common cause of errors. Some openers may also associate mime types not explicitely listed in a desktop file (such as {{Pkg|exo}}). Further environment-specific factors are at play, e.g. whether {{ic|1=Terminal=true}} has an effect, though latter should arguably be expanded on in [[Desktop entries]].}}<br />
<br />
Desktop environments and file managers supporting the specifications launch programs according to definition in the ''.desktop'' files. See [[Desktop entries#Application entry]]. <br />
<br />
Usually, configuration of the packaged ''.desktop'' files is not required, but it may not be bug-free. Even if an application containing necessary MIME-type description in the ''.desktop'' file {{ic|MimeType}} variable that is used for association, it can fail to start correctly, not start at all or start without opening a file. <br />
<br />
This may happen, for example, if the {{ic|Exec}} variable is missing internal options needed for how to open a file, or how the application is shown in the menu. The {{ic|Exec}} variable usually begins with {{ic|%}}; for its currently supported options, see [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables exec-variables].<br />
<br />
The following table lists the main variable entries of ''.desktop'' files that affect how an application starts, if it has a MIME-type associated with it. <br />
<br />
{| class="wikitable"<br />
! Variable names !! Example 1 content !! Example 2 content !! Description<br />
|-<br />
| DBusActivatable || DBusActivatable=true || DBusActivatable=false || Application interact with [https://www.freedesktop.org/wiki/Software/dbus/ D-Bus]. <br> See also configuration: [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#dbus D-Bus].<br />
|-<br />
| MimeType || MimeType=application/vnd.oasis.opendocument.text || MimeType=application/vnd.sun.xml.math || List of MIME types supported by application<br />
|-<br />
| StartupWMClass || StartupWMClass=google-chrome || StartupWMClass=xpad || Associate windows with the owning application<br />
|-<br />
| Terminal || Terminal=true || Terminal=false || Start in default terminal<br />
|}</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=XDG_MIME_Applications&diff=436825XDG MIME Applications2016-05-31T16:24:06Z<p>Andy Crowd: /* MIME types and desktop entries */ added new function to script and added into Tip example. Allows user to search in .xml by same way as in .desktop files</p>
<hr />
<div>[[Category:Desktop environments]]<br />
[[ja:デフォルトアプリケーション]]<br />
[[ru:Changing filetype association via MIME]]<br />
[[zh-cn:Default applications]]<br />
{{Related articles start}}<br />
{{Related|Desktop entries}}<br />
{{Related|Desktop environment}}<br />
{{Related|Window manager}}<br />
{{Related articles end}}<br />
<br />
Setting default applications per file type involves detection of the file type as the first step. Since the application launcher cannot fully understand all file types, the detection is based on reading only a small part of the file. There are two common ways to determine the file type:<br />
<br />
* using the file name extension, for example ''.html'' or ''.jpeg''<br />
* using the so-called "magic bytes" at the start of the file<br />
<br />
The first method is very simple and fast, but inaccurate if the file is not named "correctly". The second is more accurate, but slower.<br />
<br />
Since files are not required to have an extension and multiple file name extensions can be used for the same file type, [[w:MIME type|MIME type]]s are commonly used instead to uniquely represent the type of a file. In Arch, tools from the {{Pkg|shared-mime-info}} package are used to maintain the MIME type database, which is used by other packages to register new MIME types. Each package can also use the [[Desktop entries]] to provide information about the MIME types that can be handled by the packaged software. There is frequently more than one application able to handle data of a certain MIME type, so users and even some packages (e.g. [[desktop environments]]) assemble lists of default applications for each MIME type.<br />
<br />
Note that while Arch Linux does not provide custom presets for default applications, the [[desktop environment]] you install may do so. Some desktop environments also provide a GUI or a file-manager which enables to interactively configure default applications for certain file extensions. If this suffices for your system usage, you may not need to configure anything further. <br />
<br />
The scope of this article are the freedesktop [https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html Association between MIME types and applications] specification and related parts of the [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176 Shared MIME-info Database] specification. <br />
<br />
== MIME types and desktop entries ==<br />
<br />
{{Expansion|Complete list available at: [http://www.iana.org/assignments/media-types/media-types.xhtml]. Not sure if it's needed to maintain a summarized version in this article.}}<br />
<br />
MIME-types are specified by two slash ({{ic|/}}) parts: ''Type/Extension'', for example {{ic|video/x-ms-wmv}}. The second part of the MIME-type is expanding faster, for example with new applications or data encoding standards. <br />
<br />
The default applications to open a MIME-type are usually stored in [[#Default mimeapps.list paths|mimeapps.list]] files, but some programs store MIME-type associations in their own custom configuration files. If a MIME-type association is not found in the default configuration, the program should look for the first match of the MIME-type in ''.desktop'' files. <br />
<br />
Description of some MIME-type first part and examples of second parts:<br />
<br />
{| class="wikitable"<br />
! Type of MIME (1st part) !! Description !! Examples of extension (2nd part)<br />
|-<br />
|application || Files with binary content such, e.g.: documents,archives,... || epub+zip, ereader, excel, gbr, gzip<br />
|-<br />
|audio || Audio files that that can be played by a music player or audio editor || flac, m4a, midi<br />
|-<br />
|chemical || Chemical information, molecular and other chemical data || x-cif, x-cml, x-daylight-smiles, x-gamess-input, x-gamess-output, x-gaussian-checkpoint, x-gaussian-cube, x-gaussian-log, x-mopac-out, x-pdb, x-qchem-output, x-xyz<br />
|-<br />
|image || Image files that can be opened by image editor or image viewer || bmp, crw, g3fax, gif, jp2, jpeg, jpeg2000, jpg<br />
|-<br />
|inode || Can be opened by a file manager || blockdevice, chardevice, directory, fifo, mount-point, socket, symlink<br />
|-<br />
|message || Message protocols || delivery-status, disposition-notification, external-body, news, partial, rfc822, x-gnu-rmail<br />
|-<br />
|misc || Streaming meta data || ultravox<br />
|-<br />
|text || Text documents that can be viewed (e.g. with command ''less'') or opened with a text editor || html, javascript, mathml, mml, plain<br />
|-<br />
|video || Video files that can be played or edited with a video editor || flv, mp2t, mp4<br />
|-<br />
|x-content || Content on disks such as e.g. Audio,Video,Image or blank disk || audio-cdda, audio-player, blank-bd, blank-cd, blank-dvd, blank-hddvd, image-picturecd, video-dvd, video-svcd, video-vcd<br />
|-<br />
|x-scheme-handler || Internet protocol || ftp, geo, ghelp, help, http, https, hwplay, icy, icyx, info, irc, magnet, mailto, man, mms, mmsh, net, pnm, rtmp, rtp, rtsp, skype, uvox, vnc, xmpp<br />
|-<br />
|x-epoc || SISX package ||x-sisx-app<br />
|-<br />
|multipart || Multi-part mime messages ||alternative, appledouble, digest, encrypted, mixed, related, report, signed, x-mixed-replace<br />
|-<br />
|model || such as 3D model || x-kpovmodeler, vrml, x-modelica<br />
|}<br />
<br />
For the description of MIME-types you can search in XDG database:<br />
$ grep -e 'mime-type type=' -e '<comment>' /usr/share/mime/packages/freedesktop.org.xml<br />
<br />
{{Tip|To see all MIME extensions in the system's ''.desktop'' files that belongs to a MIME-type you can use {{AUR|lsdesktopf}}, for example {{ic|lsdesktopf --gm -gx video}}, to search available in ''.xml'' configuration/database files use {{ic|lsdesktopf --gdx -gx video}}.}} <br />
<br />
If you ever require to create a custom association of a new file extension to a MIME-type, see the <br />
the short [[#Example: .xml and related .desktop configuration]] and the [http://standards.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html Association between MIME types and applications] standard.<br />
<br />
== Set default applications == <br />
<br />
In order to set a default application, you need to <br />
* decide which of the [[#Default mimeapps.list files]] is applicable for your case and, <br />
* change the [[#Configuration of the mimeapps.list file]] accordingly. <br />
<br />
Any manual configuration of the [[#Shared MIME-info database]] is only required, if the application is not setup correctly or desktop does not comply to the standard yet.<br />
<br />
=== Default mimeapps.list files ===<br />
<br />
{{Expansion|Moving deprecated configuration files to a Note, rather than include them in the table, would improve overview. More context on the changing of the file location could also be useful.}}<br />
<br />
The {{ic|mimeapps.list}} file stores the configuration for the default application to open a MIME-type. <br />
There are different locations for it: <br />
* system-wide, <br />
* per-user, <br />
* custom locations used by some programs.<br />
<br />
The {{ic|''$desktop''}} in the following list denotes the name of the related desktop environment or window manager. The search order of paths is: <br />
<br />
{| class="wikitable"<br />
! Path !! Usage<br />
|-<br />
| {{ic|$HOME/.config/''$desktop''-mimeapps.list}} || user overrides, desktop-specific<br />
|-<br />
| {{ic|$HOME/.config/mimeapps.list}} || user overrides<br />
|-<br />
| {{ic|/etc/xdg/''$desktop''-mimeapps.list}} || sysadmin and vendor overrides, desktop-specific<br />
|-<br />
| {{ic|/etc/xdg/mimeapps.list}} || sysadmin and vendor overrides<br />
|-<br />
| {{ic|$HOME/.local/share/applications/''$desktop''-mimeapps.list}} || for compatibility but now deprecated, desktop-specific<br />
|-<br />
| {{ic|$HOME/.local/share/applications/mimeapps.list}} || for compatibility but now deprecated<br />
|-<br />
| {{ic|/usr/local/share/applications/''$desktop''-mimeapps.list}}<br>{{ic|/usr/share/applications/$desktop-mimeapps.list}} || distribution-provided defaults, desktop-specific<br />
|-<br />
| {{ic|/usr/local/share/applications/mimeapps.list}}<br>{{ic|/usr/share/applications/mimeapps.list}} || distribution-provided defaults<br />
|}<br />
<br />
=== Configuration of the mimeapps.list file ===<br />
<br />
The file contains two main sections for default and additional alternatives to open files of a MIME-type. The second and the third section ({{ic|[Removed Associations]}}) are optional. <br />
<br />
If the application installed a correct [[desktop entry]] file (examples used below {{ic|default1.desktop}}, {{ic|foo1.desktop}}, etc.), it contains the registered MIME-types it can handle. To '''set a default application''', all you need to do is adjust the associations in the respective {{ic|mimeapps.list}} (see also the freedesktop [https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html#associations specification]). <br />
<br />
For example, the following sets {{ic|default1.desktop}} to open {{ic|mimetype1}}: <br />
<br />
[Default Applications]<br />
mimetype1=default1.desktop<br />
<br />
Defined additional associations of applications to MIME-types (these might appear in file manager ''Open with'' GUI, for example):<br />
[Added Associations]<br />
mimetype1=foo1.desktop;foo2.desktop;foo3.desktop;<br />
mimetype2=foo4.desktop;<br />
<br />
Removed associations of applications with MIME-types (blacklisting a MIME-type association of an application in its ''.desktop'' file):<br />
[Removed Associations]<br />
mimetype1=foo5.desktop<br />
<br />
Multiple ''.desktop'' files for a single MIME-type must be semicolon-separated. Not supported entries are ignored in {{ic|mimeapps.list}}. The DE/WM then searches for the first match to the needed MIME-type them in the default path for ''.desktop'' files. <br />
<br />
{{Tip|To get a quick overview of how many and which ''.desktop'' files can be associated with a certain MIME-type, you can use the {{AUR|lsdesktopf}} utility, e.g. {{ic|lsdesktopf --gen-mimeapps}}.}}<br />
<br />
{{Note|Arch Linux itself does not provide system-wide presets for associations, but other distributions and specific desktop environments may do so via packaged {{ic|mimeapps.list}} files, or the older and deprecated {{ic|defaults.list}} files.}}<br />
<br />
Your choice of desktop environment, or none, will affect how your default applications are associated. Further, note that some packages use additional work-around presets, for example Mozilla's packages install a {{ic|/etc/mime.types}} file.<br />
<br />
=== Shared MIME-info database ===<br />
<br />
In background to the {{ic|mimeapps.list}} files, the system holds a database of MIME-type information registered via the installed applications' ''.desktop'' files, the [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176 Shared MIME-info Database]. It is created automatically as soon as an application depending on it is installed, via the following [[pacman#Hooks]]: <br />
* {{ic|/usr/share/libalpm/hooks/update-mime-database.hook}} from {{Pkg|shared-mime-info}} <br />
:updates the MIME-info database in {{ic|/usr/share/mime}}, in particular also the ''.xml'' specification in {{ic|/usr/share/mime/packages/freedesktop.org.xml}} for the MIME-types standards<br />
* {{ic|/usr/share/libalpm/hooks/update-desktop-database.hook}} from {{Pkg|desktop-file-utils}}<br />
:updates the {{ic|mimeinfo.cache}} located (per default) in {{ic|/usr/share/applications}}<br />
<br />
These files keep track of which MIME-types are associated with which ''.desktop'' files overall. When an application is installed, updated or removed, the pacman hooks keep the database updated accordingly. <br />
<br />
{{Warning|The database files are not meant to be edited directly.}}<br />
<br />
Application specific configuration is stored in ''.xml'' files and further files of the database (see [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176 .xml source files]) are stored in ''.keys'' and ''.mime'' files that are located in {{ic|/usr/share/mime-info/}}.<br />
<br />
Global directories for the ''.xml'' files are:<br />
<br />
/usr/share/mimelnk/application/<br />
/usr/share/mime/packages/ <br />
<br />
{{Warning|Above should not be modified, for user-specific configuration see below.}}<br />
<br />
Any user-specific ''.xml'' configuration may be stored in:<br />
~/.local/share/mime/packages/<br />
<br />
==== Example: .xml and related .desktop configuration ====<br />
<br />
The following is a short example to ''create'' files to associate an application with a MIME-type. It only needs to be followed, if the application has '''not''' setup and registered its configuration sufficiently. <br />
<br />
User-specific paths are used to override system defaults, while keeping the integrity of the rest of the system-wide configuration. <br />
<br />
Create and edit {{ic|~/.local/share/mime/packages/application-x-foobar.xml}}:<br />
<br />
{{bc|1=<br />
<?xml version="1.0" encoding="UTF-8"?><br />
<nowiki><mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"></nowiki><br />
'''<mime-type type="application/x-foobar">'''<br />
<comment>foo file</comment><br />
<icon name="application-x-foobar"/><br />
<glob-deleteall/><br />
'''<glob pattern="*.foo"/>'''<br />
</mime-type><br />
</mime-info><br />
}}<br />
<br />
Create a related [[desktop entry]] file:<br />
<br />
{{hc|~/.local/share/applications/foobar.desktop|2=<br />
[Desktop Entry]<br />
Name=Foobar<br />
Exec=/usr/bin/foobar<br />
'''MimeType=application/x-foobar'''<br />
Icon=foobar<br />
Terminal=false<br />
Type=Application<br />
Categories=AudioVideo;Player;Video;<br />
Comment=<br />
}}<br />
<br />
Now update the application and mime database with:<br />
<br />
$ update-desktop-database ~/.local/share/applications<br />
$ update-mime-database ~/.local/share/mime<br />
<br />
Programs that use MIME-types, such as file managers, should now open {{ic|*.foo}} files with foobar (you may need to restart your file manager to see the change.)<br />
<br />
{{Style|The relation between environment variables and the above discussion on MIME types is not immediate. Setting {{ic|BROWSER}} e.a, while also related to default applications, is a different approach entirely.}}<br />
<br />
See also [[Environment variables#Examples]] about global variables that can be used in start-up scripts to set default applications for specific actions.<br />
<br />
== Utilities to manage MIME types ==<br />
<br />
Many of the file managers has options to set up and configure associations of mime types with programs. <br />
<br />
It can be done by using:<br />
<br />
* Preferences for selected file<br />
* File manager configuration menu<br />
* External program for a specific file manager<br />
<br />
Other utilities to manage MIME-types are: <br />
<br />
{{Accuracy|Packages such as {{AUR|sx-open}} may replace xdg-utils in the sense that they have a provides/replaces field to pacman, but they miss tools used by other applications such as {{ic|xdg-screensaver}} and {{ic|xdg-icon-resource}}. This is not clear from the table. The table should also be better adapted to the section below, or the "based on" section could simply be left out.}}<br />
<br />
{| class="wikitable"<br />
! Name/Package !! Method !! Based on !! xdg-utils replacement !! Configuration file<br />
|-<br />
| {{Pkg|mime-editor}} || MIME-type || Utility for [http://rox.sourceforge.net/desktop/home.html ROX] applications || ||<br />
|-<br />
| {{AUR|busking-git}} || regex || {{Pkg|perl-file-mimeinfo}} || yes || custom<br />
|-<br />
| {{AUR|linopen}} || || {{Pkg|file}} || || custom<br />
|-<br />
| {{AUR|mimeo}} || MIME-type <br> regex || {{Pkg|file}} || {{AUR|xdg-utils-mimeo}} ||{{ic|mimeapps.list}} <br> {{ic|defaults.list}} <br> custom is optional<br />
|-<br />
| {{AUR|mimi-git}} || || {{Pkg|file}} || yes || custom<br />
|-<br />
| {{ic|rifle}} <br> part of {{Pkg|ranger}} || MIME-type <br> name <br> regex || {{Pkg|file}} || || custom<br />
|-<br />
| {{AUR|sx-open}} || regex || {{Pkg|file}} <br> bash regex || yes || custom<br />
|-<br />
| {{AUR|whippet}} || MIME-type <br> name <br> regex || SQLite database <br> {{Pkg|file}} <br> {{Pkg|perl-file-mimeinfo}}, etc || xdg-open || custom SQLite database <br> {{ic|mimeapps.list}}<br />
|-<br />
| {{Pkg|xdg-utils}} || || {{Pkg|file}} <br> {{Pkg|perl-file-mimeinfo}} || ||<br />
|}<br />
<br />
=== Examples of usage ===<br />
<br />
Here is a short description about how to use command line tools to show MIME-type of a file or set preferred program as default to open MIME-type.<br />
<br />
==== Detect MIME-type ====<br />
<br />
{{Style|Unclear what is meant by "it is two standards". Going by the {{ic|Magic -> XML}} entries, the first seems to be a "compiled database", without indication how it is created. The second the XML files as described in [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.20.html]. Latter can also define file contents, and the "extension associated with one program but content is associated with another MIME-type" is vague at best.}}<br />
<br />
Tools detecting MIME-type by reading meta-data from header of the file or detecting by magic number that is in two bytes identifier in the begin of the file. See [[Wikipedia:File format#File header|File header]].<br />
<br />
Many programs are using command ''file'' to detect correct MIME-type. For detection it uses compiled database that is stored in the {{ic|/usr/share/misc/magic/}} directory. It has many options to determinate correct MIME-type and for showing output.<br />
<br />
In Linux it is two standards to detect MIME-type that can affect which program will start and open the file, e.g. extension is associated with one program but content is associated with another MIME-type. The simplest way to see what is your system prioritizes is by renaming file extension and check again with tools that can use custom [[#Associate file extensions with applications MIME-type|*.xml]] configuration files.<br />
<br />
{{Accuracy|The following sentence is true only when {{pkg|perl-file-mimeinfo}} is installed. Otherwise, ''file'' is used and hence the detection method is different.}}<br />
<br />
Here is examples of utility ''xdg-mime'' that first checking association of extension in [[#Associate file extensions with applications MIME-type|*.xml]] configuration files.<br />
{| class="wikitable"<br />
! Without extension !! With extension <br />
|-<br />
|xdg-mime query filetype ''foo-file'' || xdg-mime query filetype ''foo-file''.''jpg''<br />
|-<br />
! application/vnd.oasis.opendocument.text || image/jpeg<br />
|-<br />
|}<br />
<br />
Comparison functionality of the tools <br />
<br />
Here is shown options only for simple or multiple checks of a file, for more options read their own documentation.<br />
{| class="wikitable"<br />
! Tool !! Option !! Detection order !! Functionality !! Type !! Interface<br />
|-<br />
|file || ''(has many)'' || Magic(Byte/Pattern) || Show only || binary || terminal<br />
|-<br />
|xdg-mime || query filetype || *.xml -> Magic || Show / Set || script || terminal<br />
|-<br />
|mimetype || -i ''(*.xml)'' -M ''(Magic)'' || *.xml -> Magic || Show only || script || terminal<br />
|-<br />
|mimeo || -m || *.xml -> Magic || Show / Set / Launch || script || terminal<br />
|}<br />
<br />
==== Set use of MIME-type by default ====<br />
<br />
Comparison functionality of the tools <br />
<br />
Here is shown options only for single file associations, for more options read their own documentation.<br />
<br />
{| class="wikitable"<br />
! Tool !! Option !! Functionality !! Type !! Interface<br />
|-<br />
|xdg-mime || default ''*.desktop'' Type1/Extension1 Type2/Extension2 || Show / Set || script || terminal<br />
|-<br />
|mimeo || --prefer 'regex:^Type/(Extension'''1'''<nowiki> |</nowiki>Extension?'''2''')$' ''*.desktop'' || Show / Set / Launch || script || terminal<br />
|-<br />
|mimeopen || --ask-default ''(interactive)'' || Set / Launch || script || terminal<br />
|}<br />
<br />
=== Application launchers ===<br />
<br />
{{Style|Why start over with sections when we already have a table? Pick one.}}<br />
<br />
==== xdg-open ====<br />
<br />
''xdg-open'' (from the {{Pkg|xdg-utils}} package) uses {{Pkg|perl-file-mimeinfo}} as a fallback ("generic") method if no [[desktop environment]] is detected. It is a desktop-independent tool. Many applications invoke the {{ic|xdg-open}} command internally. Inside a [[desktop environment]] it passes the arguments to desktop supported environment's file-opener applications (e.g. ''gvfs-open'', ''kde-open'', or ''exo-open''). When no desktop environment is detected the ''xdg-open'' will use its own configuration files.<br />
<br />
==== mimeopen ====<br />
<br />
''mimeopen'' (from the {{Pkg|perl-file-mimeinfo}} package) can launch applications from command line. It can use custom database and prompt user to chose default application from a list of detected relevant and offers to chose own alternative.<br />
<br />
Example of the prompt:<br />
<br />
{{hc|$ mimeopen -d /path/to/foo-file|<br />
Please choose a default application for files of type ''Type''/''Extension''<br />
1) notepad (wine-extension-txt)<br />
2) Leafpad (leafpad)<br />
3) OpenOffice.org Writer (writer)<br />
4) gVim (gvim)<br />
5) Other...<br />
}}<br />
<br />
Your answer becomes the default handler for that type of file. Mimeopen is installed as {{ic|/usr/bin/vendor_perl/mimeopen}}.<br />
<br />
If you run ''xdg-open'' without a desktop environment, you should also install {{Pkg|perl-file-mimeinfo}}, or {{AUR|xdg-utils-mimeo}} and {{AUR|mimeo}} from the [[AUR]] for a faster alternative.<br />
<br />
==== mailcap ====<br />
<br />
The [http://linux.die.net/man/4/mailcap mailcap] file.<br />
<br />
{{Expansion|When using {{AUR|run-mailcap}}, ''xdg-open'' may refer to it.[http://cgit.freedesktop.org/xdg/xdg-utils/tree/scripts/xdg-open.in#n266] It should then clearly not be combined with the below file to prevent endless loops.}}<br />
<br />
The ''.mailcap'' file format is used by mail programs such as {{Pkg|mutt}} and {{Pkg|sylpheed}}. To have those programs use ''xdg-open'', edit {{ic|~/.mailcap}}:<br />
<br />
{{hc|~/.mailcap|<br />
*/*; xdg-open "%s"<br />
}}<br />
<br />
=== Extended practical examples ===<br />
<br />
{{Style|Redundant and oddly named header; it is also odd that alternatives are discussed before the regular {{Pkg|xdg-utils}}.}}<br />
<br />
==== xdg-open ====<br />
<br />
''xdg-mime'' modifies the local file {{ic|~/.config/mimeapps.list}} and {{ic|~/.local/share/applications/mimeapps.list}} (deprecated).<br />
<br />
To '''query''' the mime type used by an existing file, use <br />
$ xdg-mime query ''filetype'' ''file.ext''<br />
<br />
To change an associated desktop entry by setting [[Thunar]] as the default file browser:<br />
<br />
$ xdg-mime default Thunar.desktop inode/directory<br />
Note that you should not specify the complete path, but only the name of the ''.desktop'' file.<br />
<br />
This command can take multiple mime-types, allowing related files to be handled by the same program. The example below associates [[Emacs]] to all known source files:<br />
$ xdg-mime default emacs.desktop $(grep '^text/x-*' /usr/share/mime/types)<br />
<br />
===== Set the default browser =====<br />
<br />
To set the default application for {{ic|http(s)://}} internet protocols:<br />
<br />
$ xdg-mime default midori.desktop x-scheme-handler/http<br />
$ xdg-mime default midori.desktop x-scheme-handler/https<br />
<br />
As an alternative try:<br />
<br />
$ xdg-settings set default-web-browser netsurf.desktop<br />
<br />
To verify if the URLs opens correctly:<br />
<br />
$ xdg-open <nowiki>https://archlinux.org</nowiki><br />
<br />
To associate ''.html'' files with the {{Pkg|netsurf}} web-browser:<br />
<br />
$ xdg-mime default netsurf.desktop text/html<br />
<br />
== Troubleshooting == <br />
<br />
=== Variables in .desktop files that affect application launch ===<br />
<br />
{{Expansion|1=The fact {{ic|MimeType}} entries may be missing in the desktop files is only implied here, i.e. "Even if an application...", though this is a common cause of errors. Some openers may also associate mime types not explicitely listed in a desktop file (such as {{Pkg|exo}}). Further environment-specific factors are at play, e.g. whether {{ic|1=Terminal=true}} has an effect, though latter should arguably be expanded on in [[Desktop entries]].}}<br />
<br />
Desktop environments and file managers supporting the specifications launch programs according to definition in the ''.desktop'' files. See [[Desktop entries#Application entry]]. <br />
<br />
Usually, configuration of the packaged ''.desktop'' files is not required, but it may not be bug-free. Even if an application containing necessary MIME-type description in the ''.desktop'' file {{ic|MimeType}} variable that is used for association, it can fail to start correctly, not start at all or start without opening a file. <br />
<br />
This may happen, for example, if the {{ic|Exec}} variable is missing internal options needed for how to open a file, or how the application is shown in the menu. The {{ic|Exec}} variable usually begins with {{ic|%}}; for its currently supported options, see [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables exec-variables].<br />
<br />
The following table lists the main variable entries of ''.desktop'' files that affect how an application starts, if it has a MIME-type associated with it. <br />
<br />
{| class="wikitable"<br />
! Variable names !! Example 1 content !! Example 2 content !! Description<br />
|-<br />
| DBusActivatable || DBusActivatable=true || DBusActivatable=false || Application interact with [https://www.freedesktop.org/wiki/Software/dbus/ D-Bus]. <br> See also configuration: [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#dbus D-Bus].<br />
|-<br />
| MimeType || MimeType=application/vnd.oasis.opendocument.text || MimeType=application/vnd.sun.xml.math || List of MIME types supported by application<br />
|-<br />
| StartupWMClass || StartupWMClass=google-chrome || StartupWMClass=xpad || Associate windows with the owning application<br />
|-<br />
| Terminal || Terminal=true || Terminal=false || Start in default terminal<br />
|}</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Securely_wipe_disk&diff=436758Securely wipe disk2016-05-30T17:31:03Z<p>Andy Crowd: /* By redirecting output */ added missed option "-s" to command "pv"</p>
<hr />
<div>[[Category:Security]]<br />
[[Category:File systems]]<br />
[[ja:ディスクの完全消去]]<br />
{{Related articles start}}<br />
{{Related|Securely wipe disk/Tips and tricks}}<br />
{{Related|File recovery}}<br />
{{Related|Benchmarking/Data storage devices}}<br />
{{Related|Frandom}}<br />
{{Related|Disk encryption#Preparing the disk}}<br />
{{Related|dm-crypt}}<br />
{{Related articles end}}<br />
Wiping a disk is done by writing new data over every single bit.<br />
<br />
{{Note|References to "disks" in this article also apply to loopback devices.}}<br />
<br />
== Common use cases ==<br />
<br />
=== Wipe all data left on the device ===<br />
<br />
The most common usecase for completely and irrevocably wiping a device will be when the device is going to be given away or sold. There may be (unencrypted) data left on the device and you want to protect against simple forensic investigation that is mere child's play with for example [[File recovery]] software.<br />
<br />
If you want to quickly wipe everything from the disk, {{ic|/dev/zero}} or simple patterns allow maximum performance while adequate randomness can be advantageous in some cases that should be covered up in [[#Data remanence]].<br />
<br />
Every overwritten bit means to provide a level of data erasure not allowing recovery with normal system functions (like standard ATA/SCSI commands) and hardware interfaces. Any file recovery software mentioned above then would need to be specialized on proprietary storage-hardware features.<br />
<br />
In case of a HDD data recreation will not be possible without at least undocumented drive commands or fiddling about the device’s controller or firmware to make them read out for example reallocated sectors (bad blocks that [[S.M.A.R.T.]] retired from use).<br />
<br />
There are different wiping issues with different physical storage technologies, most notably all Flash memory based devices and older magnetic storage (old HDD's, floppy disks, tape).<br />
<br />
=== Preparations for block device encryption ===<br />
<br />
If you want to prepare your drive to securely set up [[Disk encryption#Block device encryption]] inside the wiped area afterwards you really should use [[#Random data]] generated by a trusted cryptographically strong random number generator (referred to as RNG in this article from now on).<br />
<br />
See also [[Wikipedia:Random number generation]].<br />
<br />
{{Warning|If Block device encryption is mapped on a partition that contains anything else than random/encrypted data, disclosure of usage patterns on the encrypted drive is possible and weakens the encryption being comparable with filesystem-level-encryption. Never use {{ic|/dev/zero}}, simple patterns (badblocks, eg.) or other unrandom data before setting up Block device encryption if you are serious about it!}}<br />
<br />
== Data remanence ==<br />
<br />
See also [[Wikipedia:Data remanence]].<br />
<br />
The residual representation of data may remain even after attempts have been made to remove or erase the data.<br />
<br />
Residual data may get wiped by writing (random) data to the disk with a single or even more than one iteration. However, more than one iteration may not significantly decrease the possibility to reconstruct the data of hard disk drives. See [[#Residual magnetism]]. <br />
<br />
=== Operating system, programs and filesystem ===<br />
<br />
The operating system, executed programs or [[Wikipedia:Journaling file system|journaling file system]]s may copy your unencrypted data throughout the block device. When writing to plain disks this should only be relevant in conjunction with one of the above.<br />
<br />
If the data can get exactly located on the disk and was never copied anywhere else, wiping with random data can be thoroughgoing and impressively quick as long there is enough entropy in the pool.<br />
<br />
A good example is cryptsetup using {{ic|/dev/urandom}} for [[Dm-crypt/Device encryption#Key management|wiping the LUKS keyslots]].<br />
<br />
=== Hardware-specific issues ===<br />
<br />
==== Flash memory ====<br />
<br />
[[Wikipedia:Write amplification|Write amplification]] and other characteristics make Flash memory (explicitly including SSDs) a stubborn target for reliable wiping.<br />
As there is a lot of transparent abstraction in between data as seen by a device's controller chip and the operating system sight data is never overwritten in place and wiping particular blocks or files is not reliable.<br />
<br />
Other "features" like transparent compression (all SandForce SSD's) can compress your /dev/zero or pattern stream so if wiping is fast beyond belief this might be the case.<br />
<br />
Disassembling Flash memory devices, unsoldering the chips and analyzing data content without the controller in between is feasible without difficulty using [http://www.flash-extractor.com/manual/reader_models/ simple hardware]. Data recovery companys do it for cheap money.<br />
<br />
For more information see:<br />
<br />
* [[SSD memory cell clearing]]<br />
* [http://www.usenix.org/events/fast11/tech/full_papers/Wei.pdf Reliably Erasing Data From Flash-Based Solid State Drives].<br />
* [[#Select a target]]<br />
==== Marked Bad Sectors ====<br />
<br />
If a hard drive marks a sector as bad, it cordons it off, and the section becomes impossible to write to via software. Thus a full overwrite would not reach it. However because of block sizes, these sections would only amount to a few theoretically recoverable KB.<br />
<br />
==== Residual magnetism ====<br />
<br />
A single, full overwrite with zeros or random data does not lead to any recoverable data on a modern high-density storage device.[http://www.howtogeek.com/115573/htg-explains-why-you-only-have-to-wipe-a-disk-once-to-erase-it/] Indications otherwise refer to single residual bits; reconstruction of byte patterns is generally not feasible.[https://web.archive.org/web/20120102004746/http://www.h-online.com/newsticker/news/item/Secure-deletion-a-single-overwrite-will-do-it-739699.html] See also [https://www.google.com/search?tbs=bks:1&q=isbn:9783540898610], [http://security.stackexchange.com/questions/26132/is-data-remanence-a-myth/26134#26134] and [http://www.nber.org/sys-admin/overwritten-data-guttman.html].<br />
<br />
Overwriting old magnetic storage devices (e.g. floppy disks, magnetic tape, early-generation hard drives) only once can instead allow the wiped data to be reconstructed by analyzing the measured [[Wikipedia:Remanence|residual magnetics]], due to much lower [[Wikipedia:Memory storage density|memory storage density]]. Such devices can get disassembled in a cleanroom and then analyzed with equipment like a [[Wikipedia:Magnetic force microscope|magnetic force microscope]]. This method of data recovery requires however substantial financial resources. For this reason, it is advisable to overwrite old storage devices multiple times; [[Wikipedia:Degaussing#Degaussing magnetic data storage media|degaussing]] is another practiced countermeasure, and to ensure that data has been completely erased, most resources even advise physical destruction.<br />
<br />
== Select a target ==<br />
<br />
{{Note|Fdisk will not work on [[GPT]] formatted devices. Use gdisk ({{Pkg|gptfdisk}}) instead.}}<br />
Use fdisk to locate all read/write devices the user has read acess to.<br />
<br />
Check the output for lines that start with devices such as {{ic|/dev/sd"X"}}.<br />
<br />
This is an example for a HDD formatted to boot a linux system:<br />
<br />
{{hc|# fdisk -l|<nowiki>Disk /dev/sda: 250.1 GB, 250059350016 bytes, 488397168 sectors<br />
Units = sectors of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
Disk identifier: 0x00ff784a<br />
<br />
Device Boot Start End Blocks Id System<br />
/dev/sda1 * 2048 206847 102400 83 Linux<br />
/dev/sda2 206848 488397167 244095160 83 Linux</nowiki>}}<br />
<br />
Or the Arch Install Medium written to a 4GB USB thumb drive:<br />
<br />
{{hc|# fdisk -l|<nowiki>Disk /dev/sdb: 4075 MB, 4075290624 bytes, 7959552 sectors<br />
Units = sectors of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
Disk identifier: 0x526e236e<br />
<br />
Device Boot Start End Blocks Id System<br />
/dev/sdb1 * 0 802815 401408 17 Hidden HPFS/NTFS</nowiki>}}<br />
<br />
If you are worried about unintentional damage of important data on the primary computer, consider using an isolated environment such as a virtual environment (VirtualBox, VMWare, QEMU, etc...) with direct connected disk drives to it or a single computer only with a storage disk(s) that need to be wiped booted from a [[Archiso|Live Media]](USB, CD, PXE, etc...) or use a script to [[Securely wipe disk/Tips and tricks#Prevent wiping mounted partitions|prevent wiping mounted partitions by typo]].<br />
<br />
== Select a block size ==<br />
<br />
See also [[Wikipedia:Dd (Unix)#Block size]], [http://people.redhat.com/msnitzer/docs/io-limits.txt blocksize io-limits].<br />
<br />
If you have an [[Wikipedia:Advanced Format|Advanced Format]] hard drive it is recommended that you specify a block size larger than the default 512 bytes. To speed up the overwriting process choose a block size matching your drive's physical geometry by appending the block size option to the ''dd'' command (i.e. {{ic|<nowiki>bs=4096</nowiki>}} for 4KB).<br />
<br />
''fdisk'' prints physical and logical sector size for every disk. <br />
<br />
Alternatively sysfs does expose information:<br />
/sys/block/sdX/size<br />
/sys/block/sdX/queue/physical_block_size<br />
/sys/block/sdX/queue/logical_block_size<br />
/sys/block/sdX/sdXY/alignment_offset<br />
/sys/block/sdX/sdXY/start<br />
/sys/block/sdX/sdXY/size<br />
<br />
=== Calculate blocks to wipe manually ===<br />
<br />
In the following the determination of the data area to wipe is done in an example. <br />
<br />
A block storage devices contains sectors and a size of a single sector that can be used to calculate the whole size of device in bytes. You can do it by multiplying sectors with size of the sector.<br />
<br />
As an example we use the parameters with the ''dd'' command to wipe a partition: <br />
<br />
# dd if=''data_source'' of=/dev/sd"X" bs=''sector_size'' count=''sector_number'' seek=''partitions_start_sector''<br />
<br />
Here you will see only a part of output of {{ic|fdisk -l /dev/sdX}} with root, showing the example partition information: <br />
<br />
{{bc|Device Boot Start End Sectors Size Id Type<br />
/dev/sd"XA" 2048 3839711231 3839709184 1,8T 83 Linux<br />
/dev/sd"XB" 3839711232 3907029167 67317936 32,1G 5 Extended<br />
}}<br />
<br />
The first line of the ''fdisk'' output shows the disk size in bytes and logical sectors:<br />
<br />
Disk /dev/sd"X": 1,8 TiB, 2000398934016 bytes, 3907029168 sectors<br />
<br />
To calculate size of a single logical sector use {{ic|echo $((2000398934016 / 3907029168))}} or use data from the second line of ''fdisk'' output:<br />
<br />
Units: sectors of 1 * 512 = 512 bytes<br />
<br />
To calculate physical sectors that will make it work faster we can use the third line:<br />
<br />
Sector size (logical/physical): 512 bytes / 4096 bytes<br />
<br />
To get disk size in the physical sectors you will need the known disk size in bytes divided with size of a single physical sector {{ic|echo $((2000398934016 / 4096))}}, you can get size of the storage device or partition on it even with the {{ic|blockdev --getsize64 /dev/sd"XY"}} command.<br />
<br />
{{Note|<br />
* In the examples below we will use the logical sector size.<br />
* You can even wipe unallocated disk space with a {{ic|dd}} command by calculating the difference between the end of one and start of the next partition.}}<br />
<br />
To wipe partition {{ic|/dev/sd"XA"}} the example parameters with logical sectors would be used like this: <br />
<br />
{{bc|1=Start=2048<br />
End=3839711231<br />
BytesInSector=512}}<br />
<br />
By using the starting address of the partition on the device by defining it in the {{ic|1=seek=}} option<br />
<br />
# dd if=''data_source'' of=/dev/sd"X" bs=${BytesInSector} count=${End} seek=${Start}<br />
<br />
By using the partitions name<br />
<br />
{{bc|1=LogicalSectors=3839709184}}<br />
<br />
# dd if=''data_source'' of=/dev/sd"XA" bs=${BytesInSector} count=${LogicalSectors}<br />
<br />
Or, to wipe the whole disk by using physical sectors:<br />
<br />
{{bc|1=AllDiskPhysicalSectors=488378646<br />
PhysicalSectorSizeBytes=4096}}<br />
<br />
# dd if=''data_source'' of=/dev/sd"X" bs=${PhysicalSectorSizeBytes} count=${AllDiskPhysicalSectors} seek=0<br />
<br />
{{Note|The {{ic|1=count=}} option not necessary when wiping the physical limited area e.g. {{ic|sd"XY"}} or {{ic|sd"X"}} from begin to the end but will show an error about out of free space when will try to write outside of limits.}}<br />
<br />
== Select a data source ==<br />
<br />
As just said If you want to wipe sensitive data you can use anything matching your needs. <br />
<br />
If you want to setup block device encryption afterwards, you should always wipe at least with an encryption cipher as source or even pseudorandom data.<br />
<br />
For data that is not truly random your disk's writing speed should be the only limiting factor. If you need random data, the required system performance to generate it may extremely depend on what you choose as source of entropy.<br />
<br />
=== Non-random data ===<br />
<br />
Overwriting with {{ic|/dev/zero}} or simple patterns is considered secure in most resources. In the case of current HDD's it should be sufficient for fast disk wipes.<br />
<br />
{{Warning|A drive that is abnormally fast in writing patterns or zeroing could be doing transparent compression. It is obviously presumable not all blocks get wiped this way. Some [[#Flash memory]] devices do "feature" that.}}<br />
<br />
==== Pattern write test ====<br />
<br />
[[#Badblocks]] can write simple patterns to every block of a device and then read and check them searching for damaged areas (just like memtest86* does with memory).<br />
<br />
As the pattern is written to every accesible block this effectively wipes the device.<br />
<br />
=== Random data ===<br />
<br />
For differences between random and pseudorandom data as source, please see [[Random number generation]].<br />
<br />
{{Note|Data that is hard to compress (random data) will get written slower, if the drive logic mentioned in the [[#Non-random data]] warning tries compressing it. This should not lead to [[#Data remanence]] though. As maximum write-speed is not the performance-bottleneck it can get completely neglected while wiping disks with random data.}}<br />
<br />
=== Encrypted data ===<br />
<br />
When preparing a drive for full-disk encryption, sourcing high quality entropy is usually not necessary. The alternative is to use an encrypted datastream. For example, if you will use AES for your encrypted partition, you would wipe it with an equivalent encryption cipher prior to creating the filesystem to make the empty space not distinguishable from the used space.<br />
<br />
== Overwrite the target ==<br />
<br />
The chosen drive can be overwritten with several utilities, make your choice. If you only want to wipe a single file, [[Securely wipe disk/Tips and tricks#Wipe a single file]] has considerations in addition to the utilities mentioned below. <br />
<br />
=== By redirecting output ===<br />
<br />
The redirected output can be used both for creation of the files to rewrite free space on the partition, wipe the whole device or a single partition on it.<br />
<br />
In the following are examples that can be used to rewrite the partition or a block device by redirecting [http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-3.html stdout] from other utilities: <br />
<br />
{{hc|$ cat /dev/urandom > /dev/sd"XY"|<br />
cat: write error: No space left on device}}<br />
<br />
{{hc|$ xz -z0 /dev/urandom -c > /dev/sd"XY"|<br />
xz: (stdout): Write error: No space left on device}}<br />
<br />
{{hc|1=$ dd if=/dev/urandom > /dev/sd"XY"|2=<br />
dd: writing to ‘standard output’: No space left on device<br />
20481+0 records in<br />
20480+0 records out<br />
10485760 bytes (10 MB) copied, 2.29914 s, 4.6 MB/s}}<br />
<br />
The file copy command {{ic|cp}} can also be used to rewrite the device, because it ignores the type of the destination:<br />
<br />
{{hc|$ cp /dev/urandom /dev/sd"XY"|<br />
cp: error writing ‘/dev/sd"XY"’: No space left on device<br />
cp: failed to extend ‘/dev/sd"XY"’: No space left on device}}<br />
<br />
To show speed and time you can use {{Pkg|pv}}:<br />
<br />
# pv --timer --rate --stop-at-size -s "$(blockdev --getsize64 /dev/sd"XY" )" /dev/zero > /dev/sd"XY"<br />
<br />
=== dd ===<br />
<br />
See also [[Core utilities#dd]].<br />
<br />
{{Warning|There is no confirmation regarding the sanity of this command so '''repeatedly check''' that the correct drive or partition has been targeted. Make certain that the {{ic|<nowiki>of=...</nowiki>}} option points to the target drive and not to a system disk.}}<br />
<br />
Zero-fill the disk by writing a zero byte to every addressable location on the disk using the [[Wikipedia:/dev/zero|/dev/zero]] stream. {{ic|iflag}} and {{ic|oflag}} as below will try to disable buffering, which is senseless for a constant stream.<br />
<br />
# dd if=/dev/zero of=/dev/sdX iflag=nocache oflag=direct bs=4096<br />
<br />
Or the [[Wikipedia:/dev/random|/dev/urandom]] stream:<br />
# dd if=/dev/urandom of=/dev/sdX bs=4096<br />
<br />
The process is finished when dd reports, {{ic|No space left on device}}:<br />
dd: writing to ‘/dev/sdb’: No space left on device<br />
7959553+0 records in<br />
7959552+0 records out<br />
4075290624 bytes (4.1 GB) copied, 1247.7 s, 3.3 MB/s<br />
<br />
To speed up wiping a large drive, see also: <br />
* [[Securely wipe disk/Tips and tricks#dd - advanced example]] which uses OpenSSL, <br />
* [[Securely wipe disk/Tips and tricks#Using a template file]] which wipes with non-random preset data(e.g. overwrite a whole disk with a single file) but is very fast<br />
* [[Dm-crypt/Drive preparation#dm-crypt specific methods]] which uses dm-crypt.<br />
<br />
=== wipe ===<br />
<br />
Specialized on wiping files and is available as the {{Pkg|wipe}} package. To make a quick wipe of a destination you can use something like:<br />
<br />
$ wipe -r -q /path/to/wipe<br />
<br />
See also:<br />
[http://linux.die.net/man/1/wipe man page].<br />
<br />
=== shred ===<br />
<br />
[https://www.gnu.org/software/coreutils/manual/html_node/shred-invocation.html ''shred''] (from the {{Pkg|coreutils}} package) is a Unix command that can be used to securely delete individual files or full devices so that they can be recovered only with great difficulty with specialised hardware, if at all. ''shred'' uses three passes, writing [[Random number generation|pseudo-random data]] to the device during each pass. This can be reduced or increased.<br />
<br />
The following command invokes shred with its default settings and displays the progress.<br />
# shred -v /dev/sd''X''<br />
<br />
Alternatively, shred can be instructed to do only one pass, with entropy from e.g. {{ic|/dev/urandom}}.<br />
# shred --verbose --random-source=/dev/urandom -n1 /dev/sd''X''<br />
<br />
=== Badblocks ===<br />
<br />
For letting badblocks (from the {{Pkg|e2fsprogs}} package) perform a disk wipe, a destructive [[Badblocks#read-write_Test|read-write test]] has to be done:<br />
<br />
# badblocks -c <NUMBER_BLOCKS> -wsv /dev/<drive><br />
<br />
=== hdparm ===<br />
{{warning|Do not attempt to issue a Secure Erase ATA command on a device connected through USB; see https://ata.wiki.kernel.org/index.php/ATA_Secure_Erase and http://www.tomshardware.co.uk/answers/id-1984547/secure-erase-external-usb-hard-drive.html for details.}}<br />
<br />
[[hdparm]] supports [http://tinyapps.org/docs/wipe_drives_hdparm.html ATA Secure Erase], which is functionally equivalent to zero-filling a disk. It is however handled by the hard-drive firmware itself, and includes "hidden data areas". As such, it can be seen as a modern-day "low-level format" command. [[SSD]] drives reportedly achieve factory performance after issuing this command, but may not be sufficiently wiped (see [[#Flash memory]]).<br />
<br />
Some drives support '''Enhanced Secure Erase''', which uses distinct patterns defined by the manufacturer. If the output of {{ic|hdparm -I}} for the device indicates a manifold time advantage for the '''Enhanced''' erasure, the device probably has a hardware encryption feature and the wipe will be performed to the encryption keys only. <br />
<br />
For detailed instructions on using ATA Secure Erase, see the [https://ata.wiki.kernel.org/index.php/ATA_Secure_Erase Linux ATA wiki].<br />
<br />
=== secure-delete ===<br />
<br />
The {{AUR|secure-delete}} package from [[AUR]] provides several utilites for secure erasion, including {{ic|sfill}}, which deletes only free space in a specified mount. For example:<br />
<br />
# sfill -v /<br />
<br />
See [http://superuser.com/questions/19326/how-to-wipe-free-disk-space-in-linux the tools list] for more info.</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Desktop_entries&diff=436379Desktop entries2016-05-26T08:43:26Z<p>Andy Crowd: /* List or search in *.desktop files */ corrected link to description of "mimeapps.list"</p>
<hr />
<div>[[Category:Package development]]<br />
[[ja:デスクトップエントリ]]<br />
[[zh-CN:Desktop entries]]<br />
The freedesktop [http://www.freedesktop.org/wiki/ Desktop Entry specification] provides a standard for applications to integrate into a [[desktop environment]]. Desktop entries are the configuration files that describe how an application is launched and which data it can handle. They also configure how an application appears in a menu with an icon, which is subject to the related [https://specifications.freedesktop.org/menu-spec/latest/ menu specification] standard. <br />
<br />
The most common desktop entries are the {{ic|.desktop}} and {{ic|.directory}} files. This article explains briefly how to create useful and standard compliant desktop entries. It is mainly intended for package contributors and maintainers, but may also be useful for software developers and others.<br />
<br />
There are roughly three types of desktop entries:<br />
<br />
; Application : a shortcut to an application<br />
; Link : a shortcut to a web link.<br />
; Directory : a container of meta data of a menu entry<br />
<br />
The following sections will roughly explain how these are created and validated. <br />
<br />
Related to this content, and also defined in {{ic|.desktop}} files, are MIME-type associations for data files. [[Default applications]] describes how these are configured. <br />
<br />
== Application entry ==<br />
<br />
Desktop entries for applications, or {{ic|.desktop}} files, are generally a combination of meta information resources and a shortcut of an application. These files usually reside in {{ic|/usr/share/applications}} or {{ic|/usr/local/share/applications}} for applications installed system-wide, or {{ic|~/.local/share/applications}} for user-specific applications. User entries take precedence over system entries.<br />
<br />
=== File example ===<br />
<br />
Following is an example of its structure with additional comments. The example is only meant to give a quick impression, and does not show how to utilize all possible entry keys. The complete list of keys can be found in the [http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s05.html freedesktop.org specification].<br />
<br />
[Desktop Entry]<br />
Type=Application # Indicates the type as listed above<br />
Version=1.0 # The version of the desktop entry specification to which this file complies<br />
Name=jMemorize # The name of the application<br />
Comment=Flash card based learning tool # A comment which can/will be used as a tooltip<br />
Path=/opt/jmemorise # The path to the folder in which the executable is run<br />
Exec=jmemorize # The executable of the application.<br />
Icon=jmemorize # The name of the icon that will be used to display this entry<br />
Terminal=false # Describes whether this application needs to be run in a terminal or not<br />
Categories=Education;Languages;Java; # Describes the categories in which this entry should be shown<br />
<br />
=== Key definition ===<br />
<br />
All Desktop recognized desktop entries can be found on the [http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s05.html freedesktop.org ]site.<br />
For example, the {{Ic|Type}} key defines three types of desktop entries: Application (type 1), Link (type 2) and Directory (type 3).<br />
<br />
* {{Ic|Version}} key does not stand for the version of the application, but for the version of the desktop entry specification to which this file complies.<br />
<br />
* {{Ic|Name}}, {{Ic|GenericName}} and {{Ic|Comment}} often contain redundant values in the form of combinations of them, like:<br />
<br />
Name=Pidgin Internet Messenger<br />
GenericName=Internet Messenger<br />
or<br />
Name=NoteCase notes manager<br />
Comment=Notes Manager<br />
<br />
This should be avoided, as it will only be confusing to users. The {{Ic|Name}} key should only contain the name, or maybe an abbreviation/acronym if available.<br />
<br />
* {{Ic|GenericName}} should state what you would generally call an application that does what this specific application offers (i.e. Firefox is a "Web Browser").<br />
* {{Ic|Comment}} is intended to contain any usefull additional information.<br />
<br />
==== Deprecation ====<br />
<br />
There are quite some keys that have become deprecated over time as the standard has matured. The best/simplest way is to use the tool {{Ic|desktop-file-validate}} which is part of the package {{Pkg|desktop-file-utils}}. To validate, run<br />
$ desktop-file-validate <your desktop file><br />
This will give you very verbose and useful warnings and error messages.<br />
<br />
== Icons ==<br />
<br />
=== Common image formats ===<br />
<br />
Here is a short overview of image formats commonly used for icons.<br />
<br />
{| class="wikitable" align="center"<br />
|+ Support for image formats for icons as specified by the [http://standards.freedesktop.org/icon-theme-spec/latest/ar01s02.html freedesktop.org standard].<br />
! Extension<br />
! Full Name and/or Description<br />
! Graphics Type<br />
! Container Format<br />
! Supported<br />
|-<br />
!align="left" | .[[wikipedia:Portable Network Graphics|png]]<br />
| Portable Network Graphics<br />
| [[wikipedia:Raster graphics|Raster]]<br />
| {{No}}<br />
| {{Yes}}<br />
|-<br />
!align="left" | .[[wikipedia:Scalable Vector Graphics|svg(z)]]<br />
| Scalable Vector Graphics<br />
| [[wikipedia:Vector graphics|Vector]]<br />
| {{No}}<br />
| {{G|Yes (optional)}}<br />
|-<br />
!align="left" | .[[wikipedia:X PixMap|xpm]]<br />
| X PixMap<br />
| [[wikipedia:Raster graphics|Raster]]<br />
| {{No}}<br />
| {{Y|Yes (deprecated)}}<br />
|-<br />
!align="left" | .[[wikipedia:Graphics Interchange Format|gif]]<br />
| Graphics Interchange Format<br />
| [[wikipedia:Raster graphics|Raster]]<br />
| {{No}}<br />
| {{No}}<br />
|-<br />
!align="left" | .[[wikipedia:ICO (icon image file format)|ico]]<br />
| MS Windows Icon Format<br />
| [[wikipedia:Raster graphics|Raster]]<br />
| {{Yes}}<br />
| {{No}}<br />
|-<br />
!align="left" | .[[wikipedia:Apple Icon Image|icns]]<br />
| Apple Icon Image<br />
| [[wikipedia:Raster graphics|Raster]]<br />
| {{Yes}}<br />
| {{No}}<br />
|-<br />
|}<br />
<br />
=== Converting icons ===<br />
<br />
If you stumble across an icon which is in a format that is not supported by the freedesktop.org standard (like {{ic|gif}} or {{ic|ico}}), you can use the ''convert'' tool (which is part of the {{Pkg|imagemagick}}) to convert it to a supported/recommended format, e.g.:<br />
<br />
$ convert <icon name>.gif <icon name>.png<br />
<br />
If you convert from a container format like {{ic|ico}}, you will get all images that were encapsulated in the {{ic|ico}} file in the form {{ic|<icon name>-<number>.png}}. If you want to know the size of the image, or the number of images in a container file like {{ic|ico}} you can use the ''identify'' tool (also part of the {{Pkg|imagemagick}} package):<br />
<br />
{{hc|$ identify /usr/share/vlc/vlc48x48.ico|<br />
/usr/share/vlc/vlc48x48.ico[0] ICO 32x32 32x32+0+0 8-bit DirectClass 84.3kb<br />
/usr/share/vlc/vlc48x48.ico[1] ICO 16x16 16x16+0+0 8-bit DirectClass 84.3kb<br />
/usr/share/vlc/vlc48x48.ico[2] ICO 128x128 128x128+0+0 8-bit DirectClass 84.3kb<br />
/usr/share/vlc/vlc48x48.ico[3] ICO 48x48 48x48+0+0 8-bit DirectClass 84.3kb<br />
/usr/share/vlc/vlc48x48.ico[4] ICO 32x32 32x32+0+0 8-bit DirectClass 84.3kb<br />
/usr/share/vlc/vlc48x48.ico[5] ICO 16x16 16x16+0+0 8-bit DirectClass 84.3kb<br />
}}<br />
<br />
As you can see, the example ''ico'' file, although its name might suggest a single image of size 48x48, contains no less than 6 different sizes, of which one is even greater than 48x48, namely 128x128.<br />
<br />
Alternatively, you can use ''icotool'' (from {{Pkg|icoutils}}) to extract png images from ico container:<br />
$ icotool -x <icon name>.ico<br />
<br />
For extracting images from .icns container, you can use ''icns2png'' (provided by {{Aur|libicns}}):<br />
$ icns2png -x <icon name>.icns<br />
<br />
=== Obtaining icons ===<br />
<br />
Although packages that already ship with a .desktop-file most certainly contain an icon or a set of icons, there is sometimes the case when a developer has not created a .desktop-file, but may ship icons, nonetheless. So a good start is to look for icons in the source package.<br />
You can i.e. first filter for the extension with '''find''' and then use '''grep''' to filter further for certain buzzwords like the package name, "icon", "logo", etc, if there are quite a lot of images in the source package.<br />
$ find /path/to/source/package -regex ".*\.\(svg\|png\|xpm\|gif\|ico\)$"<br />
If the developers of an application do not include icons in their source packages, the next step would be to search on their web sites.<br />
Some projects, like i.e. ''tvbrowser'' have an [http://enwiki.tvbrowser.org/index.php/Banners,_Logos_and_other_Promotion_Material artwork/logo page] where additional icons may be found. If a project is multi-platform, there may be the case that even if the linux/unix package does not come with an icon, the Windows package might provide one. If the project uses a [[wikipedia:Version control system|Version control system]] like CVS/SVN/etc. and you have some experience with it, you also might consider browsing it for icons.<br />
If everything fails, the project might simple have no icon/logo yet.<br />
<br />
== Tools ==<br />
<br />
=== gendesk ===<br />
{{Pkg|gendesk}} started as an Arch Linux-specific tool for generating .desktop files by fetching the needed information directly from PKGBUILD files. Now it is a general tool that takes command-line arguments.<br />
<br />
Icons can be automatically downloaded from [http://openiconlibrary.sourceforge.net/ openiconlibrary], if available. (The source for icons can easily be changed in the future).<br />
<br />
==== How to use ====<br />
<br />
* Add {{Ic|gendesk}} to makedepends<br />
<br />
* Start the {{Ic|prepare()}} function with:<br />
<br />
{{bc|gendesk --pkgname "$pkgname" --pkgdesc "$pkgdesc"}}<br />
<br />
* Alternatively, if an icon is already provided ($pkgname.png, for instance). The {{Ic|-n}} flag is for not downloading an icon or using the default icon. Example:<br />
<br />
{{bc|gendesk -n --pkgname "$pkgname" --pkgdesc "$pkgdesc"}}<br />
<br />
* {{Ic|$srcdir/$pkgname.desktop}}&nbsp;will be created and can be installed in the {{Ic|package()}} function with:<br />
<br />
{{bc|install -Dm644 "$pkgname.desktop" "$pkgdir/usr/share/applications/$pkgname.desktop"}}<br />
<br />
* The icon can be installed with:<br />
<br />
{{bc|install -Dm644 "$pkgname.png" "$pkgdir/usr/share/pixmaps/$pkgname.png"}}<br />
<br />
* Use {{Ic|1=--name='Program Name'}} for choosing a name for the menu entry.<br />
<br />
* Use {{Ic|1=--exec='/opt/some_app/elf --with-ponies'}} for setting the exec field.<br />
<br />
* See the [https://github.com/xyproto/gendesk gendesk project] for more information.<br />
<br />
=== List or search in *.desktop files ===<br />
<br />
The {{AUR|lsdesktopf}} script is listing available {{ic|*.desktop}} files or searching in their content.<br />
<br />
Examples<br />
# lsdesktopf<br />
# lsdesktopf --less<br />
# lsdesktopf --less gtk zh_TW,zh_CN,en_GB<br />
<br />
List MIME-types or parts of MIME-types found in ''*.desktop'', and which desktop files shares same MIME-type, output is equal as in [[Default applications#Configuration of the mimeapps.list file |''mimeapps.list'']] for section ''[Added Associations]'' . <br />
<br />
# lsdesktopf --gm<br />
# lsdesktopf --gm [options]<br />
<br />
For more options use {{ic|lsdesktopf --help}}.<br />
<br />
=== fbrokendesktop ===<br />
<br />
The {{AUR|fbrokendesktop}} bash script using command "which" to detect broken Exec that points to not existing path. Without any parameters it uses preset folders in "DskPath" array. It shows only broken *.desktop with full path and filename that is missing.<br />
<br />
Examples<br />
<br />
# fbrokendesktop<br />
# fbrokendesktop /usr<br />
# fbrokendesktop /usr/share/apps/kdm/sessions/icewm.desktop<br />
<br />
== Tips and tricks ==<br />
<br />
=== Hide desktop entries ===<br />
<br />
{{Tip|Desktop entries can be hidden by creating a symbolic link to {{ic|/dev/null}}. For example:<br />
$ ln -s /dev/null ~/.local/share/applications/''foo''.desktop<br />
}}<br />
<br />
Firstly, copy the desktop entry file in question to {{ic|~/.local/share/applications}} to avoid your changes being overwritten.<br />
<br />
Then, to hide the entry in all environments, open the desktop entry file in a text editor and add the following line: {{ic|NoDisplay&#61;true}}.<br />
<br />
To hide the entry in a specific desktop, add the following line to the desktop entry file: {{ic|NotShowIn&#61;''desktop-name''}}<br />
<br />
where ''desktop-name'' can be option such as ''GNOME'', ''Xfce'', ''KDE'' etc. A desktop entry can be hidden in more than desktop at once - simply separate the desktop names with a semi-colon.<br />
<br />
=== Autostart ===<br />
<br />
If you use an XDG-compliant desktop environment, such as GNOME or KDE, the desktop environment will automatically start [[Desktop entries|*.desktop]] files found in the following directories:<br />
<br />
* System-wide: {{ic|$XDG_CONFIG_DIRS/autostart/}} ({{ic|/etc/xdg/autostart/}} by default)<br />
:* GNOME also starts files found in {{ic|/usr/share/gnome/autostart/}}<br />
* User-specific: {{ic|$XDG_CONFIG_HOME/autostart/}} ({{ic|~/.config/autostart/}} by default)<br />
<br />
Users can override system-wide {{ic|*.desktop}} files by copying them into the user-specific {{ic|~/.config/autostart/}} folder.<br />
<br />
For an explanation of the desktop file standard refer to [http://standards.freedesktop.org/desktop-entry-spec/latest/ Desktop Entry Specification]. For a more specific description of directories used, [http://standards.freedesktop.org/autostart-spec/autostart-spec-latest.html Desktop Application Autostart Specification]. <br />
<br />
{{Note|This method is supported only by XDG-compliant desktop environments. Tools like {{AUR|dapper}}, {{pkg|dex}}, or {{AUR|fbautostart}} can be used to offer XDG autostart in unsupported desktop environments as long as some other autostart mechanism exists. Use the existing mechanism to start the xdg compliant autostart tool.}}<br />
<br />
=== Modify environment variables ===<br />
<br />
Edit the {{ic|Exec}} command by appending {{ic|env}}, for example:<br />
<br />
{{hc|~/.local/share/applications/abiword.desktop|2=<br />
Exec=env LANG=he_IL.UTF-8 abiword %U<br />
}}<br />
<br />
== See also ==<br />
<br />
* [[DeveloperWiki:Removal of desktop files]]<br />
* [[Wikipedia:.desktop|desktop wikipedia article]]<br />
* [http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s05.html recognized desktop entry keys]<br />
* [http://freedesktop.org/wiki/Specifications/desktop-entry-spec freedesktop.org desktop entry specification]<br />
* [http://freedesktop.org/wiki/Specifications/icon-theme-spec freedesktop.org icon theme specification]<br />
* [http://freedesktop.org/wiki/Specifications/menu-spec freedesktop.org menu specification]<br />
* [http://freedesktop.org/wiki/Specifications/basedir-spec freedesktop.org basedir specification]<br />
* [http://freedesktop.org/wiki/Howto_desktop_files information for developers]</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Talk:XDG_MIME_Applications&diff=436232Talk:XDG MIME Applications2016-05-24T13:00:25Z<p>Andy Crowd: /* "Reason: The following comparison table either conflicts" */ re:</p>
<hr />
<div>== Futher improvement ==<br />
<br />
Would be great to see such detailed explanation for KDE too. --[[User:AlexanderR|AlexanderR]] 23:57, 22 January 2012 (EST)<br />
<br />
It might be worth to mention that Enlightenment's file browser (in version e19) still uses the depreciated defaults.list file. --[[User:Drtebi|Drtebi]] ([[User talk:Drtebi|talk]]) 09:01, 25 December 2014 (UTC)<br />
<br />
: This can be placed in section "File managers" as a subsection for "Application launchers" (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 14:16, 20 May 2016 (UTC)).<br />
<br />
== <s>Clean up and Merging</s> ==<br />
<br />
This article is very difficult to read and understand. Also it provides redundant information which is better described within other wiki pages. <br />
<br />
* All *.desktop file related sections can be deleted and/or merged to the [[https://wiki.archlinux.org/index.php/Desktop_entries Desktop Entries]] article<br />
* All xdg-open related sections can be deleted and/or moved to the [[https://wiki.archlinux.org/index.php/Xdg-open xdg-open]] article<br />
<br />
After cleaning up and linking to those 'renewed' sections, this article should be rewritten in a way, that the reader understands the basics: <br />
<br />
* Which ways of defining default applications are available<br />
* Which ways are recommended for DEs, WMs or TTY environments<br />
* In which way does the system solve <br />
<br />
Following this, new sections describe different system environment setups. Hands-On examples or links end each environment section.<br />
<br />
{{unsigned|17:42, 21 March 2015|T.ask}}<br />
<br />
:Related discussion: [[Talk:xdg-open#About Merge]]. I think it would be simpler to recreate the article from scratch than try to fix it. -- [[User:Alad|Alad]] ([[User talk:Alad|talk]]) 18:05, 21 March 2015 (UTC)<br />
<br />
== <s>Maintaining settings for multiple desktop environments</s> ==<br />
<br />
Remove "This article or section needs expansion" in section "Maintaining settings for multiple desktop environments"?<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 10:27, 14 May 2016 (UTC)).<br />
:: I have renamed section and removed "tag" (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 09:43, 16 May 2016 (UTC)).<br />
<br />
== <s>about "Undo revision 434926"</s> ==<br />
<br />
# I have removed variables Categories and Keywords because they are not global as "NotShowIn" or "OnlyShowIn " or fixed as "Actions" and not affecting start up type as "Terminal", "DBusActivatable" or "MimeType".<br />
# The article is not directly related to *.desktop files but only on how MIME-types and *.desktop are related and affecting start up of programs in *.desktop. I could get a really big list of variables with {{ic|lsdesktopf --sud}} but this article is only about basics.<br />
* May be also add description about variables that begins with {{ic|X-}} are not general and supporting only by related desktop environments?<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 10:53, 14 May 2016 (UTC)).<br />
<br />
:I don't follow that. If the article is just about MIME type associations, why does the sentence above the table read "Common entries in *.desktop files that affects how application acts and '''shown in menu'''." and why do you add the link to the [https://specifications.freedesktop.org/menu-spec/latest/ menu specification] below it with [https://wiki.archlinux.org/index.php?title=Default_applications&diff=prev&oldid=434919]? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 11:32, 14 May 2016 (UTC)<br />
<br />
:: "Shown in menu" - I should explain more "shown in menu for default actions" in file manager, or removed it after I removed Keywords and Categories. This (freedesktop.org "[https://specifications.freedesktop.org/menu-spec/latest/ menu specification]".) I should also removed because it is not related to MIME-types.<br />
:: Or may be also remove variables: NoDisplay , NotShowIn , OnlyShowIn , TargetEnvironment? And leave only: Actions ,DBusActivatable ,MimeType ,StartupWMClass ,Terminal ,Type ?<br />
:: (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 12:05, 14 May 2016 (UTC)).<br />
<br />
:::Ok, I now understand why you removed "Categories" and "Keywords" and also which way you are working, but I do not agree yet: <br />
:::Whole desktop environments (e.g. [[MATE]]) were created because a lot of users prefer a traditional desktop with a menu tree for applications. A .desktop "Category" will sort an application into the correct position in the menu. That's a completely different way to work with the desktop than your way of using your desktop via right-click filemanager or MIME type assocations. <br />
:::(I appreciate your work for this article, but please stop editing it until is it clarified what content it is meant to contain. You editing out content I quote above is counter-productive. [https://wiki.archlinux.org/index.php?title=Default_applications&diff=next&oldid=434980]). <br />
:::In my view the article should be general, e.g. enable MATE users as well. What do you think (e.g. which article should MATE users get their info from)? <br />
:::--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:30, 14 May 2016 (UTC)<br />
<br />
:::: If the User questions is about why application isn't shown in a "Menu" then it should be in [[Desktop entries]] section but if the question is about MIME-type associations, correct start up of programs in *.desktop and variable: "Actions" related then it should be section about MIME-types. And may be give more description about variable '''Type'''. Here is output of unique '''Type''' that I found with my script:<br />
{{bc|1=Type=Application<br />
Type=MBTheme<br />
Type=MimeType<br />
Type=Service<br />
Type=XSession}} <br />
::::EDIT: Here is a big list of variables found only in my {{ic|/usr/share/applications}} directory: [[User:Andy Crowd/sandbox/Desktop users#List of variables | List of variables ]]<br />
:::: (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 14:22, 14 May 2016 (UTC)).<br />
<br />
::::: Ah, yes, that makes sense. I was reading too quick and did not follow through the link to [[Desktop entries]] via the [[Default applications#Maintaining settings for multiple desktop environments]] expansion template. <br />
::::: I agree now it makes sense to only have the .desktop variables in the table that relate to this article (MIME associations) and have undone my revert: [https://wiki.archlinux.org/index.php?title=Default_applications&diff=434996&oldid=434982] <br />
::::: There is [[Desktop entries#File example]] for the ones that affect how an application is put in the menu. Removing more (you mention NoDisplay, NotShowIn, OnlyShowIn, TargetEnvironment) makes sense too, but we should look first if something is useful to move to the other [[Desktop entries#File example]] list. <br />
::::: The two articles are very related and should crosslink each other in the intro, but that's another topic. <br />
::::: edit: I've added back [https://wiki.archlinux.org/index.php?title=Default_applications&diff=prev&oldid=435002], and [https://wiki.archlinux.org/index.php?title=Desktop_entries&type=revision&diff=435004&oldid=434032], [https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=435003&oldid=435002] to relate both articles. <br />
::::: Thanks for explaining! Ok to close this or other points related? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:06, 14 May 2016 (UTC)<br />
<br />
== Output examples by tools ==<br />
<br />
Almost for every output I use my lsdesktopf script or adding new functions to make need output, it feels like making of the useful advertisement. I am not sure if it is OK to write everywhere "See also:" "Use to show:" for my script that only shows everything to stdout or for other programs that manages mime-types in console and have some kind of output? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 21:27, 15 May 2016 (UTC)).<br />
<br />
: I see what you mean, your tool is very useful for complex searches. You can of course use a [[Template:Tip]] in a place where you think ''lfdesktopf'' is particularly handy for readers. Two further ideas: (1) You could change the second ''lsdesktopf'' example you provide in [[Desktop_entries#List_or_search_in_.2A.desktop_files]] for the tool to one that handling MIME-type information relevant here. (2) We still also have [[Xdg-open]], which is more about tools to configure. It has [[Xdg-open#Usage]] examples about searching MIME type, which can be crosslinked as examples too. <br />
: Apart from a tip, I would not use much more examples for tools in this article at the current time. First, it should be decided what happens to [[Xdg-open]]. After [[Talk:Xdg-open#Move_suggestion]] and [[Talk:Xdg-open#About_Merge]] are clear, we should have a place where some more useful tool command examples (incl. ''mimeo'' and ''lsdesktopf'') can be put. <br />
: Ok? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 16:43, 16 May 2016 (UTC)<br />
<br />
:: I am done with the 1st advice. But in [[Xdg-open#xdg-open replacements | xdg-open replacements]] can be moved to [[Default applications#Utilities to manage MIME types|Utilities to manage MIME types]], but I must rewrite section "Utilities to manage MIME types" in style as table in "xdg-open replacements" for some tools that is not there yet, I can't provide so detailed info about missing yet. Other parts I haven't decided where I can put, but it can be minimized very much. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:56, 16 May 2016 (UTC)).<br />
<br />
::: Alright, nice. I think it is simpler to convert all tools to [[Template:App]], as suggested in the style template, and drop the table. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:34, 17 May 2016 (UTC)<br />
<br />
:::: I think that it is better with table because it is comparison of tools and not just description with a link as in [[Template:App]]. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 04:39, 18 May 2016 (UTC)).<br />
<br />
::::: Fair enough, I've merged into the table. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:06, 18 May 2016 (UTC)<br />
<br />
:::::: After I will test all ''command line'' tools in table I will probably rewrite it in a table if I will find some bigger difference or similarity. Many programs are prioritizing *.xml instead of mimeapps*. It will be a big list of short examples for a while until I will short it down. And one more thing---- It is good to have a separator between examples but not section names, is it good if I will use bold text of tool names instead? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 16:17, 18 May 2016 (UTC)).<br />
<br />
::::::: We can't have examples for too many different tools, so I think one example section and bold as separator is a good idea. By the way: Why do you use ''xdg-mine'' for the first examples in [[Default_applications#Examples_of_usage]]? If they are needed here, they should be crosslinked to [[Xdg-open#Configuration]]. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 19:05, 18 May 2016 (UTC)<br />
<br />
:::::: I have edited table but it is so Ugly code inside, may be make new or it other was to make it look good. It might be also an alternative to have One More Table with Columns: Type(Launcher,Both,Setting,Incl. Tool),GUI(Yes,No),Prioritize Order(*.xml,file,other) (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:13, 18 May 2016 (UTC)).<br />
<br />
::::::: We can remake the table in simpler format. I can help, but not today. I also have to catch-up with all the great work you have already put into the article; I'll do that one of the next days. <br />
::::::: The new columns "Type" and "GUI" read good. One question from me: What do you mean by '''prioritize order'''(*.xml,file,other)? To my understanding, the *.xml files are part of the packages and should not be user modified (see [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923467984]). The new pacman hook does the automatic work for [https://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec/#index2h3 update-mime-database] according to what the applications provide in the .xml specs. It is ok to mention the *.xml files, because they are part of the logic. However, to my understanding the configuration of the correct {{ic|mimeapps.list}} should be the focus in his article, because this is where the user choice (app per mime type) is configured. <br />
::::::: So, what do you mean by "prioritize" ? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 19:03, 18 May 2016 (UTC)<br />
<br />
:::::::: I have created an example table at the bottom that shows "prioritize order", *.xml = that it detects MIME-type by extension, Magic = if no description about extension is found in *.xml (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:59, 18 May 2016 (UTC)).<br />
<br />
::::::::: I see and like how you are progressing with new ideas about the section and now also understand what you mean with "prioritize" (great you also adopted the archived AUR packages). The example you provide in [https://wiki.archlinux.org/index.php?title=Default_applications&curid=11760&diff=435514&oldid=435466] sounds like a ''xdg-mime'' bug to me actually - or was it a text that you renamed to foo-file.jpg to show the effect? Other than that I don't have more input at current. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 17:57, 19 May 2016 (UTC)<br />
<br />
Just try examples with and without any extension or with wrong extension, if you have DE installed and necessary tools. I just added extension to "foo-file". (The discussion is too tight now so I start with a new begin.) (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:07, 19 May 2016 (UTC)).<br />
<br />
: I think that I am done with all related to article name sections. I will not use many outputs per tool, only basic and little configuration.<br />
# '''Default applications'''<br />
## Description of what MIME-type is and ways Linux uses them.<br />
## Set default applications<br />
### Configure *.mimeapps.list files<br />
### Configure *.xml files<br />
### Use tools for configuration<br />
## Get information about MIME-types<br />
### in MIME-type database<br />
### using tools<br />
## Start default applications by<br />
### using utilities<br />
### configuring other applications to use tools for starting default applications<br />
## Troubleshooting of *.desktop files if associated program doesn't start correct<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 13:52, 20 May 2016 (UTC)).<br />
<br />
:I went through the article until the [[Default_applications#Utilities_to_manage_MIME_types]] section, please have a look, thanks. I like your above TOC layout a lot. I have started to implement it in a similar manner ([https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=435829&oldid=435824]) until the section I got today. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:00, 20 May 2016 (UTC)<br />
<br />
:: You did great, but I didn't described completely when I used word "misconfiguration" in section "Variables in .desktop files that affect application launch", I meant that not all variables in "Exec" can be combined in the same *.desktop file or in the same "Exec"(in some *.desktop files I found more then one "Exec" that belongs to each new section that related to description in variable Actions, for each Action own Exec in the new section within same *.desktop file), e.g. to open file and to open device can't be in the same *.desktop file with "Exec" but standard changes so I didn't wrote about all details only that "misconfigured" Exec can affect start or be shown in the menu. For the section about tools I don't know what is good and how much I should write about each tool or in subsections, e.g. xdg-open may be need more details but article is not about xdg-utils but too much examples not good. May be it can be different between subsections (in one more examples and in another less or no examples, e.g. as it look like now). May be also add a section about file managers as in suggestion: [[Talk:Default_applications#Futher_improvement]]? Add information about GUI launchers that each DE is using? Add some "ERROR" template about that sections about tools is not complete and must be extended or something in that style (it is very messy in that part) because I think that it can take long time until it will be completed? I don't know how much time I will have to put on wiki but I will do my best to "finish"(until I have some ideas and time left) this article and also may be add some more info to [[Desktop entries]]. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 23:57, 20 May 2016 (UTC)).<br />
<br />
::: Glad you are generally ok with my changes yesterday, if you see something wrong later - just change or tell me. Don't worry about time. The article is in a much better state already thanks to your expertise and careful work! If you want, you can also leave it to me to go over the [[Default applications#Utilities to manage MIME types]] section first, and see afterwards what of your ideas you want to implement as soon as you have time/want to work on it further. <br />
::: For the "Variables in .desktop files that affect application launch" section: yes I think I understand. Perhaps one of us has an idea later how to improve it without mentioning too many exceptional cases, it is a complicated topic. I think it should stay in Troubleshooting though, like you put it above in the TOC. <br />
::: For command output: I don't think we should mention much more about GUI tools/filemanagers of particular DE/WM. That should be left to the DE/WM (e.g. [[GNOME#Default applications]], [[Xfce#Menu]]), so that this article can stay more general. For more see my reply below to Kynikos. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:15, 21 May 2016 (UTC)<br />
<br />
I haven't followed this discussion closely, but after merging [[xdg-open]] I do think that at least some examples from the [https://wiki.archlinux.org/index.php?title=Xdg-open&oldid=435329#Configuration xdg-open#Configuration] section should be restored here, because for example the tables in [[Default_applications#Detect_MIME-type]] are quite informative, but at a glance it doesn't even look like they're talking about actual commands :) — [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 09:37, 21 May 2016 (UTC)<br />
<br />
:Yes, we all agree on this I think (see Andy's above reply). I think for now it is pretty simple to add back more command output, because Andy had actually [https://wiki.archlinux.org/index.php?title=Default_applications&diff=435514&oldid=435466 written] a meaningful command example before. In my view it should suffice for now to add back the commands leading to the [[Default_applications#Detect_MIME-type]] tables for now and then see how it works out. <br />
:Btw, can you name a couple of specifics for the top-level style template you put? I'd like to fix them on the next go through. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:15, 21 May 2016 (UTC)<br />
<br />
:: Is it OK to have a section with additional practical examples for other tools too as I started in [[Default applications#Extended practical examples]], without any cryptic descriptions (instead ''Type/Extension'' use ''video/flv'')? I don't see a better way of adding more examples without destroying logical layout of other sections. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:39, 21 May 2016 (UTC)).<br />
<br />
:::Thanks Andy, your solution works for me.<br />
:::@Indigo, I've [https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=436018&oldid=435979 fixed] several formatting/punctuation non-compliances, however I've left the values in the tables almost untouched for the moment; in theory options and variables should all be shown with [[Template:ic]], and I'm not sure under which [[Help:Style/Formatting and punctuation]] category we could consider MIME types to belong.<br />
:::– [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 05:46, 22 May 2016 (UTC)<br />
<br />
:::: Thanks for fixing, Kynikos. It was actually my confusion when I used [[Template:ic]] for ''.desktop'' extension et al. When I did so, I recalled Lahwaacz had reminded me to something similar a good year ago, but got misled trying to find it again in the style guide ^^ <br />
:::: For the MIME types: I don't think we can fix these 100%. I'd say they can be either [[Help:Style/Formatting_and_punctuation#Configuration_parameters.2C_variables.2C_options.2C_properties...|properties]] or (e.g. for custom x-* ones) [[Help:Style/Formatting and punctuation#File content]]. So, monospace in my view when mentiioned in text, but I'd like to keep them normal text in the tables. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 11:43, 23 May 2016 (UTC)<br />
<br />
:::::I agree with using monospace for MIME types, and, as long as it's done consistently, I have no problems with keeping the tables in plain text :) — [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 09:30, 24 May 2016 (UTC)<br />
<br />
== <s>About tag: "Reason: Lacks clarity, content tacked on" </s>==<br />
<br />
What is more missing or must be rewritten to remove tag about: "Reason: Lacks clarity, content tacked on" that is in section "MIME types and desktop entries"<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 09:47, 16 May 2016 (UTC))<br />
<br />
: I have removed <nowiki>"{{Style|Lacks clarity, content tacked on}}"</nowiki> and closed this discussion. If I was wrong then explain please what is still missing. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:25, 18 May 2016 (UTC)).<br />
<br />
== <s>Remove section ''Default locations of the mimeapps.list_files'' ? </s> ==<br />
<br />
[[Default_applications#Default_locations_of_the_.2Amimeapps.list_files| this section]] is a RAW copy from [https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html#file freedesktop.org]. It is better to have a link to it instead. What do you think, is it good if I remove it? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:44, 17 May 2016 (UTC)).<br />
: 8 vs 10 fields, 2 more fields in table in this wiki. this should stay I missed the difference that 2 global system path is only here. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:18, 17 May 2016 (UTC)).<br />
<br />
<br />
== <s>"Reason: The MIME database is located at" </s> ==<br />
<br />
Read here: [https://specifications.freedesktop.org/desktop-entry-spec/0.9.5/ar01s07.html]. "XDG MIME-type database" is in the {{ic|/usr/share/mime}} but {{ic|mimeinfo.cache}} is located in other folders and updates automatically after update or installation of new programs: {{hc|find /usr/ -type f -name "mimeinfo.cache"|<br />
/usr/local/share/applications/mimeinfo.cache<br />
/usr/share/applications/mimeinfo.cache}} <br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:05, 23 May 2016 (UTC)).<br />
<br />
:The section title is "Shared MIME-info database", there are two links to [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176] and the {{ic|update-mime-database.hook}} updates the database in {{ic|/usr/share/mime/}}. The {{ic|mimeinfo.cache}} files are different database handled by {{ic|update-desktop-database.hook}}. Also, there is an incomplete sentence around the first link. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 17:26, 23 May 2016 (UTC)<br />
<br />
:: Yes, you are right, it must be rewritten and corrected. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 22:21, 23 May 2016 (UTC)).<br />
<br />
::: Thanks for the info, Changed and removed template with [https://wiki.archlinux.org/index.php?title=Default_applications&diff=436222&oldid=436187], please proof-read again. Closing. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 11:49, 24 May 2016 (UTC)<br />
<br />
== "Reason: The following comparison table either conflicts" ==<br />
<br />
The table contains just a list of packages and files to give the user an overview of packages that contains preset MIME-type files or a human readable description of MIME-types.<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:19, 23 May 2016 (UTC)).<br />
<br />
:{{ic|/etc/gnome/defaults.list}} does not contain any human-readable descriptions, but GNOME's default applications associations. {{ic|/etc/mime.types}} is a plain list of (some) MIME types and completely unrelated to the standard being described on the page. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 17:44, 23 May 2016 (UTC)<br />
<br />
:: The [[Wikipedia:Media_type#mime.types|mime.types]] is used as fallback by browsers to detect mime.type by extension, but also by some tools that are used to detect type of the file.<br />
{{hc|file /etc/gnome/defaults.list /usr/share/applications/defaults.list|<br />
/etc/gnome/defaults.list: ASCII text<br />
/usr/share/applications/defaults.list: symbolic link to /etc/gnome/defaults.list}}<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:26, 23 May 2016 (UTC)).<br />
:: Where should the table be placed, create new section? So far as it is not a binary data in the file it is readable, if has patterns then can be used tools like ''grep'', and it is a good basic description of some "1st parts" of MIME-type in this wiki now. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 20:14, 23 May 2016 (UTC)).<br />
<br />
:::Why do you want to show the {{AUR|gnome-defaults-list}} package at all? It doesn't matter that {{ic|/etc/gnome/defaults.list}} is a text file, I just don't see why it's so useful for showing and its relation to the other two packages. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 20:34, 23 May 2016 (UTC)<br />
<br />
:::: I want to show users that it is more than one "default" place where is possible to find files that has some kind of description about MIME-types, even if it is old but is still available online. Why limit article only to modern from official repositories if something is still available in AUR? And it also written only few word about "defaults.list" but may be someone want to know more it? It is just a little more information for curious users. I haven't found a better place for the table yet but I wish it will be somewhere in the Article, only left to find a section for it. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 22:34, 23 May 2016 (UTC)).<br />
:::: I will add some more path to default "text" files, into the table, that contains mime-types. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 22:40, 23 May 2016 (UTC)).<br />
<br />
:::::Again, {{ic|/etc/gnome/defaults.list}} does '''not''' contain any descriptions about MIME types. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 06:24, 24 May 2016 (UTC)<br />
<br />
:::::: I moved two of the three table packages into text.[https://wiki.archlinux.org/index.php?title=Default_applications&diff=436225&oldid=436224#.23Shared_MIME-info_database] [https://wiki.archlinux.org/index.php?title=Default_applications&diff=436227&oldid=436225] <br />
:::::: Andy, please reconsider {{AUR|gnome-defaults-list}}. It is only Ubuntu defaults and might have been useful more in the past for users during the Gnome2->3 switch. Current [[GNOME]] does not have any {{ic|/etc/gnome/}}, so mentioning the package at this place will indeed confuse readers. <br />
:::::: Ok to remove it and ok with the other changes? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 11:58, 24 May 2016 (UTC)<br />
<br />
::::::: Yes, thanks, it's ok. I have copied the table to my User Page and will expand it there for personal use to have as a reference, so it can be completely removed from this article. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 13:00, 24 May 2016 (UTC)).</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=User:Andy_Crowd/Get_information_about_files&diff=436226User:Andy Crowd/Get information about files2016-05-24T11:29:16Z<p>Andy Crowd: </p>
<hr />
<div>__NOINDEX__<br />
<br />
== Get information about files ==<br />
<br />
For a new or unknown files<br />
<br />
* file - get a warrior information about a file<br />
* [[xdg-open|xdg-mime]] - getting a mime type of a file<br />
* md5sum - shows md5sum of a file<br />
* shasum - shows SHA sum, (sha1sum sha224sum sha256sum sha384sum sha512sum shasum)<br />
* ls, dir - those commands are used to list a content in folders<br />
<br />
Mostly used on an already installed operative system<br />
<br />
* basename - shows only filename without its path. {{ic|$ basename /path/filename}} will show only {{ic|filename}}.<br />
* <nowiki>"${FilePathVariable##*/}"</nowiki> - same as ''basename'' but is a bash expression that cuts dir path<br />
* echo /path/filename | sed 's/[^*]*\///g' - shows the basename, same as two examples above<br />
* touch - can create an empty file but not overwriting if the file already exist and can change a file timestamps<br />
* stat - statistics of a file<br />
* {{Pkg|lsof}} - list open files<br />
* mount - mount or show mounted files or devices<br />
* ps - shows information about processes<br />
* du - shows the size of a folder tree or a single file<br />
* {{ic|if [ -f '/path/filename'];then echo exist;fi}} - checking if the file exists<br />
* {{ic|if [ ! -f '/path/filename'];then echo exist;fi}} - checking if the file «doesn't» exists<br />
* getfacl - get info about file's extended access rights<br />
* getfattr - get info about extended attributes <br />
* find - search files or check for broken symlinks {{ic|$ find -L -type l}}<br />
:* {{ic|<nowiki>find -type f -print0 | xargs -0 -L 1 file | grep text</nowiki>}} - grep from stdout info from {{ic|file}} command.<br />
* {{ic|df}} - shows up to ~95% of all available free as without reserved free space<br />
* {{ic|tune2fs}} - shows a warriors information about block device including available reserved free space - {{ic|tune2fs -l /dev/sd"XY"|grep Reserved}}<br />
<br />
* [[Pacman tips|pacman]] - arch package installer and can check which of packages a file belongs to. {{ic|$ pacman -Qo /usr/bin/ifconfig}}<br />
* check dependences {{ic|<nowiki>pactree -l pacman | sort -u | cut -f 1 -d ' '</nowiki>}}<br />
<br />
=== Download files ===<br />
<br />
==== With correct file names ====<br />
<br />
* {{Pkg|wget}} - download files or mirror websites, to download with correct file names if possible:<br />
wget ''--content-disposition'' -m -nd -nH http://website_to_mirror/<br />
<br />
* {{Pkg|curl}} - download files<br />
curl -J -O http://website_to_mirror/<br />
<br />
See also in [http://superuser.com/questions/301044/how-to-wget-a-file-with-correct-name-when-redirected forum]<br />
<br />
==== dump links ====<br />
<br />
From youtube:<br />
lynx -dump 'https://www.youtube.com/playlist?list=PL90ABNRn4Rq7n3xYPjRZZqRLYfoFrVDZj' | awk '/http/{if(index($2,"watch"))print $2}'<br />
<br />
See also: [http://superuser.com/questions/409651/how-do-i-extract-all-the-external-links-of-a-web-page dump links]<br />
<br />
=== Specialized ===<br />
* {{App|identify| Shows more information (and metadata) about image files.{{ic|$ identify -verbose imagename}}|http://www.imagemagick.org/|{{Pkg|imagemagick}}}}<br />
* {{App|mediainfo| shows info about video/audio files.{{ic|$ mediainfo -f mediafile}}|http://mediaarea.net/en/MediaInfo|{{Pkg|mediainfo}}}} <br />
* {{App|feh| Shows the image and/or information about it.{{ic|$ feh -l imagename}}|http://feh.finalrewind.org/|{{Pkg|feh}}}}<br />
* {{App|exiv2| Shows a meta-data info of image files.{{ic|$ exiv2 pr -v imagename}}|http://www.exiv2.org/|{{Pkg|exiv2}}}} <br />
* {{App|pdfinfo| Shows extra information about PDF files.{{ic|$ pdfinfo -js -meta -rawdates -box filename.pdf }}|http://poppler.freedesktop.org/|{{Pkg|poppler}}}}<br />
* {{App|jpeginfo| Shows info and integrity of jpeg files. {{ic|$ jpeginfo -ci imagename.jpg}}.|http://www.kokkonen.net/tjko/projects.html|{{Aur|jpeginfo}}}}<br />
* {{App|pngcheck| Shows info and integrity of PNG, JNG and MNG image types. {{ic|$ pngcheck *.png}}.|http://www.libpng.org/pub/png/apps/pngcheck.html|{{Aur|pngcheck}}}}<br />
* {{App|exiftool| Shows metadata of images. {{ic|$ exiftool *jpg}}.|http://xahlee.info/img/metadata_in_image_files.html}}<br />
* {{App|mogrify| Adding a comment to the image.{{ic|$ mogrify -comment "yourcomment" /path/file.png}}.|http://www.imagemagick.org/|{{Pkg|imagemagick}}}}}}<br />
* which - Shows a path to an executable file by searching it in folders that are in the {{ic|$PATH}} environment variable.{{ic|$ which bash}} will show only {{ic|/bin/bash}}.<br />
* isoinfo - Shows warriors information about the ISO image. {{ic|isoinfo -d /path/isofile.iso}}<br />
<br />
==== Check integrity of images with scripts ====<br />
<br />
This is a python3 script that tests integrity of an image by loading its data and showing errors if got any. Requires the {{Pkg|python-pillow}} library for the proper running. It can be combined with {{ic|find -type f -name "*.jpg" -exec ThisScript.py "{}" \;}} to check multiple images.<br />
<br />
{{bc|1=#!/bin/python3<br />
import sys<br />
from PIL import Image<br />
from optparse import OptionParser<br />
parser = OptionParser()<br />
(options, args) = parser.parse_args()<br />
FileName = "".join(args)<br />
try:<br />
im = Image.open(FileName,"r")<br />
except IOError:<br />
print("Cannot open the «",FileName,"» file!")<br />
else:<br />
try:<br />
TestLoadImgData = list(im.getdata())<br />
except IOError:<br />
print("An error was found in a «",FileName,"» file!")<br />
im.close()<br />
else:<br />
print("No Errors were found!")<br />
im.close()")<br />
}}<br />
<br />
=== Archive testers ===<br />
* {{App|p7zip| Test integrity of files in 7z, wim, tar archives. {{ic|$ 7z t archivename *}}|http://p7zip.sourceforge.net/|{{Pkg|p7zip}}}}<br />
* {{App|unrar| Test integrity of archive files. {{ic|$ unrar t archivename *}}|http://www.rarlab.com/rar_add.htm|{{Pkg|unrar}}}}<br />
Gzip and tar verbose test<br />
$ gunzip -kvc archivename.tar.gz | tar tv<br />
$ gunzip -ktv archivename.gz<br />
$ tar tv archivename.tar<br />
{{Note|Most of the compress/uncompress archive tools includes their own test abilities.}}<br />
<br />
=== MIME-types list of the path to files ===<br />
<br />
There are available additional preset MIME-type descriptions for a various desktop environments.<br />
<br />
{{Accuracy|The following comparison table either conflicts with the previous note or the items should not be compared at all. {{ic|defaults.list}} sets default applications associations, AFAIK the others don't. {{Pkg|shared-mime-info}} is required by many desktop-independent packages.}}<br />
<br />
{| class="wikitable"<br />
! Package name !! Description !! Files<br />
|-<br />
| {{AUR|gnome-defaults-list}} || Ubuntu defaults || {{ic|/etc/gnome/defaults.list}} <br> {{ic|/usr/share/applications/defaults.list}}<br />
|-<br />
| {{Pkg|mime-types}} || Additional list of MIME-types || {{ic|/etc/mime.types}}<br />
|-<br />
| {{Pkg|shared-mime-info}}|| XDG MIME-type database is a part of the package||| {{ic|/usr/share/mime/packages/freedesktop.org.xml}}<br />
|}</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Talk:XDG_MIME_Applications&diff=436191Talk:XDG MIME Applications2016-05-23T22:40:28Z<p>Andy Crowd: /* "Reason: The following comparison table either conflicts" */ added more</p>
<hr />
<div>== Futher improvement ==<br />
<br />
Would be great to see such detailed explanation for KDE too. --[[User:AlexanderR|AlexanderR]] 23:57, 22 January 2012 (EST)<br />
<br />
It might be worth to mention that Enlightenment's file browser (in version e19) still uses the depreciated defaults.list file. --[[User:Drtebi|Drtebi]] ([[User talk:Drtebi|talk]]) 09:01, 25 December 2014 (UTC)<br />
<br />
: This can be placed in section "File managers" as a subsection for "Application launchers" (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 14:16, 20 May 2016 (UTC)).<br />
<br />
== <s>Clean up and Merging</s> ==<br />
<br />
This article is very difficult to read and understand. Also it provides redundant information which is better described within other wiki pages. <br />
<br />
* All *.desktop file related sections can be deleted and/or merged to the [[https://wiki.archlinux.org/index.php/Desktop_entries Desktop Entries]] article<br />
* All xdg-open related sections can be deleted and/or moved to the [[https://wiki.archlinux.org/index.php/Xdg-open xdg-open]] article<br />
<br />
After cleaning up and linking to those 'renewed' sections, this article should be rewritten in a way, that the reader understands the basics: <br />
<br />
* Which ways of defining default applications are available<br />
* Which ways are recommended for DEs, WMs or TTY environments<br />
* In which way does the system solve <br />
<br />
Following this, new sections describe different system environment setups. Hands-On examples or links end each environment section.<br />
<br />
{{unsigned|17:42, 21 March 2015|T.ask}}<br />
<br />
:Related discussion: [[Talk:xdg-open#About Merge]]. I think it would be simpler to recreate the article from scratch than try to fix it. -- [[User:Alad|Alad]] ([[User talk:Alad|talk]]) 18:05, 21 March 2015 (UTC)<br />
<br />
== <s>Maintaining settings for multiple desktop environments</s> ==<br />
<br />
Remove "This article or section needs expansion" in section "Maintaining settings for multiple desktop environments"?<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 10:27, 14 May 2016 (UTC)).<br />
:: I have renamed section and removed "tag" (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 09:43, 16 May 2016 (UTC)).<br />
<br />
== <s>about "Undo revision 434926"</s> ==<br />
<br />
# I have removed variables Categories and Keywords because they are not global as "NotShowIn" or "OnlyShowIn " or fixed as "Actions" and not affecting start up type as "Terminal", "DBusActivatable" or "MimeType".<br />
# The article is not directly related to *.desktop files but only on how MIME-types and *.desktop are related and affecting start up of programs in *.desktop. I could get a really big list of variables with {{ic|lsdesktopf --sud}} but this article is only about basics.<br />
* May be also add description about variables that begins with {{ic|X-}} are not general and supporting only by related desktop environments?<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 10:53, 14 May 2016 (UTC)).<br />
<br />
:I don't follow that. If the article is just about MIME type associations, why does the sentence above the table read "Common entries in *.desktop files that affects how application acts and '''shown in menu'''." and why do you add the link to the [https://specifications.freedesktop.org/menu-spec/latest/ menu specification] below it with [https://wiki.archlinux.org/index.php?title=Default_applications&diff=prev&oldid=434919]? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 11:32, 14 May 2016 (UTC)<br />
<br />
:: "Shown in menu" - I should explain more "shown in menu for default actions" in file manager, or removed it after I removed Keywords and Categories. This (freedesktop.org "[https://specifications.freedesktop.org/menu-spec/latest/ menu specification]".) I should also removed because it is not related to MIME-types.<br />
:: Or may be also remove variables: NoDisplay , NotShowIn , OnlyShowIn , TargetEnvironment? And leave only: Actions ,DBusActivatable ,MimeType ,StartupWMClass ,Terminal ,Type ?<br />
:: (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 12:05, 14 May 2016 (UTC)).<br />
<br />
:::Ok, I now understand why you removed "Categories" and "Keywords" and also which way you are working, but I do not agree yet: <br />
:::Whole desktop environments (e.g. [[MATE]]) were created because a lot of users prefer a traditional desktop with a menu tree for applications. A .desktop "Category" will sort an application into the correct position in the menu. That's a completely different way to work with the desktop than your way of using your desktop via right-click filemanager or MIME type assocations. <br />
:::(I appreciate your work for this article, but please stop editing it until is it clarified what content it is meant to contain. You editing out content I quote above is counter-productive. [https://wiki.archlinux.org/index.php?title=Default_applications&diff=next&oldid=434980]). <br />
:::In my view the article should be general, e.g. enable MATE users as well. What do you think (e.g. which article should MATE users get their info from)? <br />
:::--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:30, 14 May 2016 (UTC)<br />
<br />
:::: If the User questions is about why application isn't shown in a "Menu" then it should be in [[Desktop entries]] section but if the question is about MIME-type associations, correct start up of programs in *.desktop and variable: "Actions" related then it should be section about MIME-types. And may be give more description about variable '''Type'''. Here is output of unique '''Type''' that I found with my script:<br />
{{bc|1=Type=Application<br />
Type=MBTheme<br />
Type=MimeType<br />
Type=Service<br />
Type=XSession}} <br />
::::EDIT: Here is a big list of variables found only in my {{ic|/usr/share/applications}} directory: [[User:Andy Crowd/sandbox/Desktop users#List of variables | List of variables ]]<br />
:::: (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 14:22, 14 May 2016 (UTC)).<br />
<br />
::::: Ah, yes, that makes sense. I was reading too quick and did not follow through the link to [[Desktop entries]] via the [[Default applications#Maintaining settings for multiple desktop environments]] expansion template. <br />
::::: I agree now it makes sense to only have the .desktop variables in the table that relate to this article (MIME associations) and have undone my revert: [https://wiki.archlinux.org/index.php?title=Default_applications&diff=434996&oldid=434982] <br />
::::: There is [[Desktop entries#File example]] for the ones that affect how an application is put in the menu. Removing more (you mention NoDisplay, NotShowIn, OnlyShowIn, TargetEnvironment) makes sense too, but we should look first if something is useful to move to the other [[Desktop entries#File example]] list. <br />
::::: The two articles are very related and should crosslink each other in the intro, but that's another topic. <br />
::::: edit: I've added back [https://wiki.archlinux.org/index.php?title=Default_applications&diff=prev&oldid=435002], and [https://wiki.archlinux.org/index.php?title=Desktop_entries&type=revision&diff=435004&oldid=434032], [https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=435003&oldid=435002] to relate both articles. <br />
::::: Thanks for explaining! Ok to close this or other points related? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:06, 14 May 2016 (UTC)<br />
<br />
== Output examples by tools ==<br />
<br />
Almost for every output I use my lsdesktopf script or adding new functions to make need output, it feels like making of the useful advertisement. I am not sure if it is OK to write everywhere "See also:" "Use to show:" for my script that only shows everything to stdout or for other programs that manages mime-types in console and have some kind of output? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 21:27, 15 May 2016 (UTC)).<br />
<br />
: I see what you mean, your tool is very useful for complex searches. You can of course use a [[Template:Tip]] in a place where you think ''lfdesktopf'' is particularly handy for readers. Two further ideas: (1) You could change the second ''lsdesktopf'' example you provide in [[Desktop_entries#List_or_search_in_.2A.desktop_files]] for the tool to one that handling MIME-type information relevant here. (2) We still also have [[Xdg-open]], which is more about tools to configure. It has [[Xdg-open#Usage]] examples about searching MIME type, which can be crosslinked as examples too. <br />
: Apart from a tip, I would not use much more examples for tools in this article at the current time. First, it should be decided what happens to [[Xdg-open]]. After [[Talk:Xdg-open#Move_suggestion]] and [[Talk:Xdg-open#About_Merge]] are clear, we should have a place where some more useful tool command examples (incl. ''mimeo'' and ''lsdesktopf'') can be put. <br />
: Ok? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 16:43, 16 May 2016 (UTC)<br />
<br />
:: I am done with the 1st advice. But in [[Xdg-open#xdg-open replacements | xdg-open replacements]] can be moved to [[Default applications#Utilities to manage MIME types|Utilities to manage MIME types]], but I must rewrite section "Utilities to manage MIME types" in style as table in "xdg-open replacements" for some tools that is not there yet, I can't provide so detailed info about missing yet. Other parts I haven't decided where I can put, but it can be minimized very much. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:56, 16 May 2016 (UTC)).<br />
<br />
::: Alright, nice. I think it is simpler to convert all tools to [[Template:App]], as suggested in the style template, and drop the table. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:34, 17 May 2016 (UTC)<br />
<br />
:::: I think that it is better with table because it is comparison of tools and not just description with a link as in [[Template:App]]. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 04:39, 18 May 2016 (UTC)).<br />
<br />
::::: Fair enough, I've merged into the table. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:06, 18 May 2016 (UTC)<br />
<br />
:::::: After I will test all ''command line'' tools in table I will probably rewrite it in a table if I will find some bigger difference or similarity. Many programs are prioritizing *.xml instead of mimeapps*. It will be a big list of short examples for a while until I will short it down. And one more thing---- It is good to have a separator between examples but not section names, is it good if I will use bold text of tool names instead? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 16:17, 18 May 2016 (UTC)).<br />
<br />
::::::: We can't have examples for too many different tools, so I think one example section and bold as separator is a good idea. By the way: Why do you use ''xdg-mine'' for the first examples in [[Default_applications#Examples_of_usage]]? If they are needed here, they should be crosslinked to [[Xdg-open#Configuration]]. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 19:05, 18 May 2016 (UTC)<br />
<br />
:::::: I have edited table but it is so Ugly code inside, may be make new or it other was to make it look good. It might be also an alternative to have One More Table with Columns: Type(Launcher,Both,Setting,Incl. Tool),GUI(Yes,No),Prioritize Order(*.xml,file,other) (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:13, 18 May 2016 (UTC)).<br />
<br />
::::::: We can remake the table in simpler format. I can help, but not today. I also have to catch-up with all the great work you have already put into the article; I'll do that one of the next days. <br />
::::::: The new columns "Type" and "GUI" read good. One question from me: What do you mean by '''prioritize order'''(*.xml,file,other)? To my understanding, the *.xml files are part of the packages and should not be user modified (see [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923467984]). The new pacman hook does the automatic work for [https://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec/#index2h3 update-mime-database] according to what the applications provide in the .xml specs. It is ok to mention the *.xml files, because they are part of the logic. However, to my understanding the configuration of the correct {{ic|mimeapps.list}} should be the focus in his article, because this is where the user choice (app per mime type) is configured. <br />
::::::: So, what do you mean by "prioritize" ? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 19:03, 18 May 2016 (UTC)<br />
<br />
:::::::: I have created an example table at the bottom that shows "prioritize order", *.xml = that it detects MIME-type by extension, Magic = if no description about extension is found in *.xml (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:59, 18 May 2016 (UTC)).<br />
<br />
::::::::: I see and like how you are progressing with new ideas about the section and now also understand what you mean with "prioritize" (great you also adopted the archived AUR packages). The example you provide in [https://wiki.archlinux.org/index.php?title=Default_applications&curid=11760&diff=435514&oldid=435466] sounds like a ''xdg-mime'' bug to me actually - or was it a text that you renamed to foo-file.jpg to show the effect? Other than that I don't have more input at current. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 17:57, 19 May 2016 (UTC)<br />
<br />
Just try examples with and without any extension or with wrong extension, if you have DE installed and necessary tools. I just added extension to "foo-file". (The discussion is too tight now so I start with a new begin.) (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:07, 19 May 2016 (UTC)).<br />
<br />
: I think that I am done with all related to article name sections. I will not use many outputs per tool, only basic and little configuration.<br />
# '''Default applications'''<br />
## Description of what MIME-type is and ways Linux uses them.<br />
## Set default applications<br />
### Configure *.mimeapps.list files<br />
### Configure *.xml files<br />
### Use tools for configuration<br />
## Get information about MIME-types<br />
### in MIME-type database<br />
### using tools<br />
## Start default applications by<br />
### using utilities<br />
### configuring other applications to use tools for starting default applications<br />
## Troubleshooting of *.desktop files if associated program doesn't start correct<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 13:52, 20 May 2016 (UTC)).<br />
<br />
:I went through the article until the [[Default_applications#Utilities_to_manage_MIME_types]] section, please have a look, thanks. I like your above TOC layout a lot. I have started to implement it in a similar manner ([https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=435829&oldid=435824]) until the section I got today. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:00, 20 May 2016 (UTC)<br />
<br />
:: You did great, but I didn't described completely when I used word "misconfiguration" in section "Variables in .desktop files that affect application launch", I meant that not all variables in "Exec" can be combined in the same *.desktop file or in the same "Exec"(in some *.desktop files I found more then one "Exec" that belongs to each new section that related to description in variable Actions, for each Action own Exec in the new section within same *.desktop file), e.g. to open file and to open device can't be in the same *.desktop file with "Exec" but standard changes so I didn't wrote about all details only that "misconfigured" Exec can affect start or be shown in the menu. For the section about tools I don't know what is good and how much I should write about each tool or in subsections, e.g. xdg-open may be need more details but article is not about xdg-utils but too much examples not good. May be it can be different between subsections (in one more examples and in another less or no examples, e.g. as it look like now). May be also add a section about file managers as in suggestion: [[Talk:Default_applications#Futher_improvement]]? Add information about GUI launchers that each DE is using? Add some "ERROR" template about that sections about tools is not complete and must be extended or something in that style (it is very messy in that part) because I think that it can take long time until it will be completed? I don't know how much time I will have to put on wiki but I will do my best to "finish"(until I have some ideas and time left) this article and also may be add some more info to [[Desktop entries]]. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 23:57, 20 May 2016 (UTC)).<br />
<br />
::: Glad you are generally ok with my changes yesterday, if you see something wrong later - just change or tell me. Don't worry about time. The article is in a much better state already thanks to your expertise and careful work! If you want, you can also leave it to me to go over the [[Default applications#Utilities to manage MIME types]] section first, and see afterwards what of your ideas you want to implement as soon as you have time/want to work on it further. <br />
::: For the "Variables in .desktop files that affect application launch" section: yes I think I understand. Perhaps one of us has an idea later how to improve it without mentioning too many exceptional cases, it is a complicated topic. I think it should stay in Troubleshooting though, like you put it above in the TOC. <br />
::: For command output: I don't think we should mention much more about GUI tools/filemanagers of particular DE/WM. That should be left to the DE/WM (e.g. [[GNOME#Default applications]], [[Xfce#Menu]]), so that this article can stay more general. For more see my reply below to Kynikos. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:15, 21 May 2016 (UTC)<br />
<br />
I haven't followed this discussion closely, but after merging [[xdg-open]] I do think that at least some examples from the [https://wiki.archlinux.org/index.php?title=Xdg-open&oldid=435329#Configuration xdg-open#Configuration] section should be restored here, because for example the tables in [[Default_applications#Detect_MIME-type]] are quite informative, but at a glance it doesn't even look like they're talking about actual commands :) — [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 09:37, 21 May 2016 (UTC)<br />
<br />
:Yes, we all agree on this I think (see Andy's above reply). I think for now it is pretty simple to add back more command output, because Andy had actually [https://wiki.archlinux.org/index.php?title=Default_applications&diff=435514&oldid=435466 written] a meaningful command example before. In my view it should suffice for now to add back the commands leading to the [[Default_applications#Detect_MIME-type]] tables for now and then see how it works out. <br />
:Btw, can you name a couple of specifics for the top-level style template you put? I'd like to fix them on the next go through. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:15, 21 May 2016 (UTC)<br />
<br />
:: Is it OK to have a section with additional practical examples for other tools too as I started in [[Default applications#Extended practical examples]], without any cryptic descriptions (instead ''Type/Extension'' use ''video/flv'')? I don't see a better way of adding more examples without destroying logical layout of other sections. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:39, 21 May 2016 (UTC)).<br />
<br />
:::Thanks Andy, your solution works for me.<br />
:::@Indigo, I've [https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=436018&oldid=435979 fixed] several formatting/punctuation non-compliances, however I've left the values in the tables almost untouched for the moment; in theory options and variables should all be shown with [[Template:ic]], and I'm not sure under which [[Help:Style/Formatting and punctuation]] category we could consider MIME types to belong.<br />
:::– [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 05:46, 22 May 2016 (UTC)<br />
<br />
:::: Thanks for fixing, Kynikos. It was actually my confusion when I used [[Template:ic]] for ''.desktop'' extension et al. When I did so, I recalled Lahwaacz had reminded me to something similar a good year ago, but got misled trying to find it again in the style guide ^^ <br />
:::: For the MIME types: I don't think we can fix these 100%. I'd say they can be either [[Help:Style/Formatting_and_punctuation#Configuration_parameters.2C_variables.2C_options.2C_properties...|properties]] or (e.g. for custom x-* ones) [[Help:Style/Formatting and punctuation#File content]]. So, monospace in my view when mentiioned in text, but I'd like to keep them normal text in the tables. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 11:43, 23 May 2016 (UTC)<br />
<br />
== <s>About tag: "Reason: Lacks clarity, content tacked on" </s>==<br />
<br />
What is more missing or must be rewritten to remove tag about: "Reason: Lacks clarity, content tacked on" that is in section "MIME types and desktop entries"<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 09:47, 16 May 2016 (UTC))<br />
<br />
: I have removed <nowiki>"{{Style|Lacks clarity, content tacked on}}"</nowiki> and closed this discussion. If I was wrong then explain please what is still missing. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:25, 18 May 2016 (UTC)).<br />
<br />
== <s>Remove section ''Default locations of the mimeapps.list_files'' ? </s> ==<br />
<br />
[[Default_applications#Default_locations_of_the_.2Amimeapps.list_files| this section]] is a RAW copy from [https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html#file freedesktop.org]. It is better to have a link to it instead. What do you think, is it good if I remove it? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:44, 17 May 2016 (UTC)).<br />
: 8 vs 10 fields, 2 more fields in table in this wiki. this should stay I missed the difference that 2 global system path is only here. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:18, 17 May 2016 (UTC)).<br />
<br />
<br />
== "Reason: The MIME database is located at" ==<br />
<br />
Read here: [https://specifications.freedesktop.org/desktop-entry-spec/0.9.5/ar01s07.html]. "XDG MIME-type database" is in the {{ic|/usr/share/mime}} but {{ic|mimeinfo.cache}} is located in other folders and updates automatically after update or installation of new programs: {{hc|find /usr/ -type f -name "mimeinfo.cache"|<br />
/usr/local/share/applications/mimeinfo.cache<br />
/usr/share/applications/mimeinfo.cache}} <br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:05, 23 May 2016 (UTC)).<br />
<br />
:The section title is "Shared MIME-info database", there are two links to [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176] and the {{ic|update-mime-database.hook}} updates the database in {{ic|/usr/share/mime/}}. The {{ic|mimeinfo.cache}} files are different database handled by {{ic|update-desktop-database.hook}}. Also, there is an incomplete sentence around the first link. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 17:26, 23 May 2016 (UTC)<br />
<br />
:: Yes, you are right, it must be rewritten and corrected. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 22:21, 23 May 2016 (UTC)).<br />
<br />
== "Reason: The following comparison table either conflicts" ==<br />
<br />
The table contains just a list of packages and files to give the user an overview of packages that contains preset MIME-type files or a human readable description of MIME-types.<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:19, 23 May 2016 (UTC)).<br />
<br />
:{{ic|/etc/gnome/defaults.list}} does not contain any human-readable descriptions, but GNOME's default applications associations. {{ic|/etc/mime.types}} is a plain list of (some) MIME types and completely unrelated to the standard being described on the page. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 17:44, 23 May 2016 (UTC)<br />
<br />
:: The [[Wikipedia:Media_type#mime.types|mime.types]] is used as fallback by browsers to detect mime.type by extension, but also by some tools that are used to detect type of the file.<br />
{{hc|file /etc/gnome/defaults.list /usr/share/applications/defaults.list|<br />
/etc/gnome/defaults.list: ASCII text<br />
/usr/share/applications/defaults.list: symbolic link to /etc/gnome/defaults.list}}<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:26, 23 May 2016 (UTC)).<br />
:: Where should the table be placed, create new section? So far as it is not a binary data in the file it is readable, if has patterns then can be used tools like ''grep'', and it is a good basic description of some "1st parts" of MIME-type in this wiki now. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 20:14, 23 May 2016 (UTC)).<br />
<br />
:::Why do you want to show the {{AUR|gnome-defaults-list}} package at all? It doesn't matter that {{ic|/etc/gnome/defaults.list}} is a text file, I just don't see why it's so useful for showing and its relation to the other two packages. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 20:34, 23 May 2016 (UTC)<br />
<br />
:::: I want to show users that it is more than one "default" place where is possible to find files that has some kind of description about MIME-types, even if it is old but is still available online. Why limit article only to modern from official repositories if something is still available in AUR? And it also written only few word about "defaults.list" but may be someone want to know more it? It is just a little more information for curious users. I haven't found a better place for the table yet but I wish it will be somewhere in the Article, only left to find a section for it. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 22:34, 23 May 2016 (UTC)).<br />
:::: I will add some more path to default "text" files, into the table, that contains mime-types. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 22:40, 23 May 2016 (UTC)).</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Talk:XDG_MIME_Applications&diff=436190Talk:XDG MIME Applications2016-05-23T22:35:18Z<p>Andy Crowd: /* "Reason: The following comparison table either conflicts" */ re:</p>
<hr />
<div>== Futher improvement ==<br />
<br />
Would be great to see such detailed explanation for KDE too. --[[User:AlexanderR|AlexanderR]] 23:57, 22 January 2012 (EST)<br />
<br />
It might be worth to mention that Enlightenment's file browser (in version e19) still uses the depreciated defaults.list file. --[[User:Drtebi|Drtebi]] ([[User talk:Drtebi|talk]]) 09:01, 25 December 2014 (UTC)<br />
<br />
: This can be placed in section "File managers" as a subsection for "Application launchers" (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 14:16, 20 May 2016 (UTC)).<br />
<br />
== <s>Clean up and Merging</s> ==<br />
<br />
This article is very difficult to read and understand. Also it provides redundant information which is better described within other wiki pages. <br />
<br />
* All *.desktop file related sections can be deleted and/or merged to the [[https://wiki.archlinux.org/index.php/Desktop_entries Desktop Entries]] article<br />
* All xdg-open related sections can be deleted and/or moved to the [[https://wiki.archlinux.org/index.php/Xdg-open xdg-open]] article<br />
<br />
After cleaning up and linking to those 'renewed' sections, this article should be rewritten in a way, that the reader understands the basics: <br />
<br />
* Which ways of defining default applications are available<br />
* Which ways are recommended for DEs, WMs or TTY environments<br />
* In which way does the system solve <br />
<br />
Following this, new sections describe different system environment setups. Hands-On examples or links end each environment section.<br />
<br />
{{unsigned|17:42, 21 March 2015|T.ask}}<br />
<br />
:Related discussion: [[Talk:xdg-open#About Merge]]. I think it would be simpler to recreate the article from scratch than try to fix it. -- [[User:Alad|Alad]] ([[User talk:Alad|talk]]) 18:05, 21 March 2015 (UTC)<br />
<br />
== <s>Maintaining settings for multiple desktop environments</s> ==<br />
<br />
Remove "This article or section needs expansion" in section "Maintaining settings for multiple desktop environments"?<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 10:27, 14 May 2016 (UTC)).<br />
:: I have renamed section and removed "tag" (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 09:43, 16 May 2016 (UTC)).<br />
<br />
== <s>about "Undo revision 434926"</s> ==<br />
<br />
# I have removed variables Categories and Keywords because they are not global as "NotShowIn" or "OnlyShowIn " or fixed as "Actions" and not affecting start up type as "Terminal", "DBusActivatable" or "MimeType".<br />
# The article is not directly related to *.desktop files but only on how MIME-types and *.desktop are related and affecting start up of programs in *.desktop. I could get a really big list of variables with {{ic|lsdesktopf --sud}} but this article is only about basics.<br />
* May be also add description about variables that begins with {{ic|X-}} are not general and supporting only by related desktop environments?<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 10:53, 14 May 2016 (UTC)).<br />
<br />
:I don't follow that. If the article is just about MIME type associations, why does the sentence above the table read "Common entries in *.desktop files that affects how application acts and '''shown in menu'''." and why do you add the link to the [https://specifications.freedesktop.org/menu-spec/latest/ menu specification] below it with [https://wiki.archlinux.org/index.php?title=Default_applications&diff=prev&oldid=434919]? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 11:32, 14 May 2016 (UTC)<br />
<br />
:: "Shown in menu" - I should explain more "shown in menu for default actions" in file manager, or removed it after I removed Keywords and Categories. This (freedesktop.org "[https://specifications.freedesktop.org/menu-spec/latest/ menu specification]".) I should also removed because it is not related to MIME-types.<br />
:: Or may be also remove variables: NoDisplay , NotShowIn , OnlyShowIn , TargetEnvironment? And leave only: Actions ,DBusActivatable ,MimeType ,StartupWMClass ,Terminal ,Type ?<br />
:: (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 12:05, 14 May 2016 (UTC)).<br />
<br />
:::Ok, I now understand why you removed "Categories" and "Keywords" and also which way you are working, but I do not agree yet: <br />
:::Whole desktop environments (e.g. [[MATE]]) were created because a lot of users prefer a traditional desktop with a menu tree for applications. A .desktop "Category" will sort an application into the correct position in the menu. That's a completely different way to work with the desktop than your way of using your desktop via right-click filemanager or MIME type assocations. <br />
:::(I appreciate your work for this article, but please stop editing it until is it clarified what content it is meant to contain. You editing out content I quote above is counter-productive. [https://wiki.archlinux.org/index.php?title=Default_applications&diff=next&oldid=434980]). <br />
:::In my view the article should be general, e.g. enable MATE users as well. What do you think (e.g. which article should MATE users get their info from)? <br />
:::--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:30, 14 May 2016 (UTC)<br />
<br />
:::: If the User questions is about why application isn't shown in a "Menu" then it should be in [[Desktop entries]] section but if the question is about MIME-type associations, correct start up of programs in *.desktop and variable: "Actions" related then it should be section about MIME-types. And may be give more description about variable '''Type'''. Here is output of unique '''Type''' that I found with my script:<br />
{{bc|1=Type=Application<br />
Type=MBTheme<br />
Type=MimeType<br />
Type=Service<br />
Type=XSession}} <br />
::::EDIT: Here is a big list of variables found only in my {{ic|/usr/share/applications}} directory: [[User:Andy Crowd/sandbox/Desktop users#List of variables | List of variables ]]<br />
:::: (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 14:22, 14 May 2016 (UTC)).<br />
<br />
::::: Ah, yes, that makes sense. I was reading too quick and did not follow through the link to [[Desktop entries]] via the [[Default applications#Maintaining settings for multiple desktop environments]] expansion template. <br />
::::: I agree now it makes sense to only have the .desktop variables in the table that relate to this article (MIME associations) and have undone my revert: [https://wiki.archlinux.org/index.php?title=Default_applications&diff=434996&oldid=434982] <br />
::::: There is [[Desktop entries#File example]] for the ones that affect how an application is put in the menu. Removing more (you mention NoDisplay, NotShowIn, OnlyShowIn, TargetEnvironment) makes sense too, but we should look first if something is useful to move to the other [[Desktop entries#File example]] list. <br />
::::: The two articles are very related and should crosslink each other in the intro, but that's another topic. <br />
::::: edit: I've added back [https://wiki.archlinux.org/index.php?title=Default_applications&diff=prev&oldid=435002], and [https://wiki.archlinux.org/index.php?title=Desktop_entries&type=revision&diff=435004&oldid=434032], [https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=435003&oldid=435002] to relate both articles. <br />
::::: Thanks for explaining! Ok to close this or other points related? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:06, 14 May 2016 (UTC)<br />
<br />
== Output examples by tools ==<br />
<br />
Almost for every output I use my lsdesktopf script or adding new functions to make need output, it feels like making of the useful advertisement. I am not sure if it is OK to write everywhere "See also:" "Use to show:" for my script that only shows everything to stdout or for other programs that manages mime-types in console and have some kind of output? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 21:27, 15 May 2016 (UTC)).<br />
<br />
: I see what you mean, your tool is very useful for complex searches. You can of course use a [[Template:Tip]] in a place where you think ''lfdesktopf'' is particularly handy for readers. Two further ideas: (1) You could change the second ''lsdesktopf'' example you provide in [[Desktop_entries#List_or_search_in_.2A.desktop_files]] for the tool to one that handling MIME-type information relevant here. (2) We still also have [[Xdg-open]], which is more about tools to configure. It has [[Xdg-open#Usage]] examples about searching MIME type, which can be crosslinked as examples too. <br />
: Apart from a tip, I would not use much more examples for tools in this article at the current time. First, it should be decided what happens to [[Xdg-open]]. After [[Talk:Xdg-open#Move_suggestion]] and [[Talk:Xdg-open#About_Merge]] are clear, we should have a place where some more useful tool command examples (incl. ''mimeo'' and ''lsdesktopf'') can be put. <br />
: Ok? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 16:43, 16 May 2016 (UTC)<br />
<br />
:: I am done with the 1st advice. But in [[Xdg-open#xdg-open replacements | xdg-open replacements]] can be moved to [[Default applications#Utilities to manage MIME types|Utilities to manage MIME types]], but I must rewrite section "Utilities to manage MIME types" in style as table in "xdg-open replacements" for some tools that is not there yet, I can't provide so detailed info about missing yet. Other parts I haven't decided where I can put, but it can be minimized very much. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:56, 16 May 2016 (UTC)).<br />
<br />
::: Alright, nice. I think it is simpler to convert all tools to [[Template:App]], as suggested in the style template, and drop the table. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:34, 17 May 2016 (UTC)<br />
<br />
:::: I think that it is better with table because it is comparison of tools and not just description with a link as in [[Template:App]]. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 04:39, 18 May 2016 (UTC)).<br />
<br />
::::: Fair enough, I've merged into the table. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:06, 18 May 2016 (UTC)<br />
<br />
:::::: After I will test all ''command line'' tools in table I will probably rewrite it in a table if I will find some bigger difference or similarity. Many programs are prioritizing *.xml instead of mimeapps*. It will be a big list of short examples for a while until I will short it down. And one more thing---- It is good to have a separator between examples but not section names, is it good if I will use bold text of tool names instead? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 16:17, 18 May 2016 (UTC)).<br />
<br />
::::::: We can't have examples for too many different tools, so I think one example section and bold as separator is a good idea. By the way: Why do you use ''xdg-mine'' for the first examples in [[Default_applications#Examples_of_usage]]? If they are needed here, they should be crosslinked to [[Xdg-open#Configuration]]. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 19:05, 18 May 2016 (UTC)<br />
<br />
:::::: I have edited table but it is so Ugly code inside, may be make new or it other was to make it look good. It might be also an alternative to have One More Table with Columns: Type(Launcher,Both,Setting,Incl. Tool),GUI(Yes,No),Prioritize Order(*.xml,file,other) (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:13, 18 May 2016 (UTC)).<br />
<br />
::::::: We can remake the table in simpler format. I can help, but not today. I also have to catch-up with all the great work you have already put into the article; I'll do that one of the next days. <br />
::::::: The new columns "Type" and "GUI" read good. One question from me: What do you mean by '''prioritize order'''(*.xml,file,other)? To my understanding, the *.xml files are part of the packages and should not be user modified (see [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923467984]). The new pacman hook does the automatic work for [https://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec/#index2h3 update-mime-database] according to what the applications provide in the .xml specs. It is ok to mention the *.xml files, because they are part of the logic. However, to my understanding the configuration of the correct {{ic|mimeapps.list}} should be the focus in his article, because this is where the user choice (app per mime type) is configured. <br />
::::::: So, what do you mean by "prioritize" ? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 19:03, 18 May 2016 (UTC)<br />
<br />
:::::::: I have created an example table at the bottom that shows "prioritize order", *.xml = that it detects MIME-type by extension, Magic = if no description about extension is found in *.xml (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:59, 18 May 2016 (UTC)).<br />
<br />
::::::::: I see and like how you are progressing with new ideas about the section and now also understand what you mean with "prioritize" (great you also adopted the archived AUR packages). The example you provide in [https://wiki.archlinux.org/index.php?title=Default_applications&curid=11760&diff=435514&oldid=435466] sounds like a ''xdg-mime'' bug to me actually - or was it a text that you renamed to foo-file.jpg to show the effect? Other than that I don't have more input at current. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 17:57, 19 May 2016 (UTC)<br />
<br />
Just try examples with and without any extension or with wrong extension, if you have DE installed and necessary tools. I just added extension to "foo-file". (The discussion is too tight now so I start with a new begin.) (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:07, 19 May 2016 (UTC)).<br />
<br />
: I think that I am done with all related to article name sections. I will not use many outputs per tool, only basic and little configuration.<br />
# '''Default applications'''<br />
## Description of what MIME-type is and ways Linux uses them.<br />
## Set default applications<br />
### Configure *.mimeapps.list files<br />
### Configure *.xml files<br />
### Use tools for configuration<br />
## Get information about MIME-types<br />
### in MIME-type database<br />
### using tools<br />
## Start default applications by<br />
### using utilities<br />
### configuring other applications to use tools for starting default applications<br />
## Troubleshooting of *.desktop files if associated program doesn't start correct<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 13:52, 20 May 2016 (UTC)).<br />
<br />
:I went through the article until the [[Default_applications#Utilities_to_manage_MIME_types]] section, please have a look, thanks. I like your above TOC layout a lot. I have started to implement it in a similar manner ([https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=435829&oldid=435824]) until the section I got today. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:00, 20 May 2016 (UTC)<br />
<br />
:: You did great, but I didn't described completely when I used word "misconfiguration" in section "Variables in .desktop files that affect application launch", I meant that not all variables in "Exec" can be combined in the same *.desktop file or in the same "Exec"(in some *.desktop files I found more then one "Exec" that belongs to each new section that related to description in variable Actions, for each Action own Exec in the new section within same *.desktop file), e.g. to open file and to open device can't be in the same *.desktop file with "Exec" but standard changes so I didn't wrote about all details only that "misconfigured" Exec can affect start or be shown in the menu. For the section about tools I don't know what is good and how much I should write about each tool or in subsections, e.g. xdg-open may be need more details but article is not about xdg-utils but too much examples not good. May be it can be different between subsections (in one more examples and in another less or no examples, e.g. as it look like now). May be also add a section about file managers as in suggestion: [[Talk:Default_applications#Futher_improvement]]? Add information about GUI launchers that each DE is using? Add some "ERROR" template about that sections about tools is not complete and must be extended or something in that style (it is very messy in that part) because I think that it can take long time until it will be completed? I don't know how much time I will have to put on wiki but I will do my best to "finish"(until I have some ideas and time left) this article and also may be add some more info to [[Desktop entries]]. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 23:57, 20 May 2016 (UTC)).<br />
<br />
::: Glad you are generally ok with my changes yesterday, if you see something wrong later - just change or tell me. Don't worry about time. The article is in a much better state already thanks to your expertise and careful work! If you want, you can also leave it to me to go over the [[Default applications#Utilities to manage MIME types]] section first, and see afterwards what of your ideas you want to implement as soon as you have time/want to work on it further. <br />
::: For the "Variables in .desktop files that affect application launch" section: yes I think I understand. Perhaps one of us has an idea later how to improve it without mentioning too many exceptional cases, it is a complicated topic. I think it should stay in Troubleshooting though, like you put it above in the TOC. <br />
::: For command output: I don't think we should mention much more about GUI tools/filemanagers of particular DE/WM. That should be left to the DE/WM (e.g. [[GNOME#Default applications]], [[Xfce#Menu]]), so that this article can stay more general. For more see my reply below to Kynikos. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:15, 21 May 2016 (UTC)<br />
<br />
I haven't followed this discussion closely, but after merging [[xdg-open]] I do think that at least some examples from the [https://wiki.archlinux.org/index.php?title=Xdg-open&oldid=435329#Configuration xdg-open#Configuration] section should be restored here, because for example the tables in [[Default_applications#Detect_MIME-type]] are quite informative, but at a glance it doesn't even look like they're talking about actual commands :) — [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 09:37, 21 May 2016 (UTC)<br />
<br />
:Yes, we all agree on this I think (see Andy's above reply). I think for now it is pretty simple to add back more command output, because Andy had actually [https://wiki.archlinux.org/index.php?title=Default_applications&diff=435514&oldid=435466 written] a meaningful command example before. In my view it should suffice for now to add back the commands leading to the [[Default_applications#Detect_MIME-type]] tables for now and then see how it works out. <br />
:Btw, can you name a couple of specifics for the top-level style template you put? I'd like to fix them on the next go through. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:15, 21 May 2016 (UTC)<br />
<br />
:: Is it OK to have a section with additional practical examples for other tools too as I started in [[Default applications#Extended practical examples]], without any cryptic descriptions (instead ''Type/Extension'' use ''video/flv'')? I don't see a better way of adding more examples without destroying logical layout of other sections. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:39, 21 May 2016 (UTC)).<br />
<br />
:::Thanks Andy, your solution works for me.<br />
:::@Indigo, I've [https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=436018&oldid=435979 fixed] several formatting/punctuation non-compliances, however I've left the values in the tables almost untouched for the moment; in theory options and variables should all be shown with [[Template:ic]], and I'm not sure under which [[Help:Style/Formatting and punctuation]] category we could consider MIME types to belong.<br />
:::– [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 05:46, 22 May 2016 (UTC)<br />
<br />
:::: Thanks for fixing, Kynikos. It was actually my confusion when I used [[Template:ic]] for ''.desktop'' extension et al. When I did so, I recalled Lahwaacz had reminded me to something similar a good year ago, but got misled trying to find it again in the style guide ^^ <br />
:::: For the MIME types: I don't think we can fix these 100%. I'd say they can be either [[Help:Style/Formatting_and_punctuation#Configuration_parameters.2C_variables.2C_options.2C_properties...|properties]] or (e.g. for custom x-* ones) [[Help:Style/Formatting and punctuation#File content]]. So, monospace in my view when mentiioned in text, but I'd like to keep them normal text in the tables. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 11:43, 23 May 2016 (UTC)<br />
<br />
== <s>About tag: "Reason: Lacks clarity, content tacked on" </s>==<br />
<br />
What is more missing or must be rewritten to remove tag about: "Reason: Lacks clarity, content tacked on" that is in section "MIME types and desktop entries"<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 09:47, 16 May 2016 (UTC))<br />
<br />
: I have removed <nowiki>"{{Style|Lacks clarity, content tacked on}}"</nowiki> and closed this discussion. If I was wrong then explain please what is still missing. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:25, 18 May 2016 (UTC)).<br />
<br />
== <s>Remove section ''Default locations of the mimeapps.list_files'' ? </s> ==<br />
<br />
[[Default_applications#Default_locations_of_the_.2Amimeapps.list_files| this section]] is a RAW copy from [https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html#file freedesktop.org]. It is better to have a link to it instead. What do you think, is it good if I remove it? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:44, 17 May 2016 (UTC)).<br />
: 8 vs 10 fields, 2 more fields in table in this wiki. this should stay I missed the difference that 2 global system path is only here. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:18, 17 May 2016 (UTC)).<br />
<br />
<br />
== "Reason: The MIME database is located at" ==<br />
<br />
Read here: [https://specifications.freedesktop.org/desktop-entry-spec/0.9.5/ar01s07.html]. "XDG MIME-type database" is in the {{ic|/usr/share/mime}} but {{ic|mimeinfo.cache}} is located in other folders and updates automatically after update or installation of new programs: {{hc|find /usr/ -type f -name "mimeinfo.cache"|<br />
/usr/local/share/applications/mimeinfo.cache<br />
/usr/share/applications/mimeinfo.cache}} <br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:05, 23 May 2016 (UTC)).<br />
<br />
:The section title is "Shared MIME-info database", there are two links to [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176] and the {{ic|update-mime-database.hook}} updates the database in {{ic|/usr/share/mime/}}. The {{ic|mimeinfo.cache}} files are different database handled by {{ic|update-desktop-database.hook}}. Also, there is an incomplete sentence around the first link. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 17:26, 23 May 2016 (UTC)<br />
<br />
:: Yes, you are right, it must be rewritten and corrected. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 22:21, 23 May 2016 (UTC)).<br />
<br />
== "Reason: The following comparison table either conflicts" ==<br />
<br />
The table contains just a list of packages and files to give the user an overview of packages that contains preset MIME-type files or a human readable description of MIME-types.<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:19, 23 May 2016 (UTC)).<br />
<br />
:{{ic|/etc/gnome/defaults.list}} does not contain any human-readable descriptions, but GNOME's default applications associations. {{ic|/etc/mime.types}} is a plain list of (some) MIME types and completely unrelated to the standard being described on the page. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 17:44, 23 May 2016 (UTC)<br />
<br />
:: The [[Wikipedia:Media_type#mime.types|mime.types]] is used as fallback by browsers to detect mime.type by extension, but also by some tools that are used to detect type of the file.<br />
{{hc|file /etc/gnome/defaults.list /usr/share/applications/defaults.list|<br />
/etc/gnome/defaults.list: ASCII text<br />
/usr/share/applications/defaults.list: symbolic link to /etc/gnome/defaults.list}}<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:26, 23 May 2016 (UTC)).<br />
:: Where should the table be placed, create new section? So far as it is not a binary data in the file it is readable, if has patterns then can be used tools like ''grep'', and it is a good basic description of some "1st parts" of MIME-type in this wiki now. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 20:14, 23 May 2016 (UTC)).<br />
<br />
:::Why do you want to show the {{AUR|gnome-defaults-list}} package at all? It doesn't matter that {{ic|/etc/gnome/defaults.list}} is a text file, I just don't see why it's so useful for showing and its relation to the other two packages. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 20:34, 23 May 2016 (UTC)<br />
<br />
:::: I want to show users that it is more than one "default" place where is possible to find files that has some kind of description about MIME-types, even if it is old but is still available online. Why limit article only to modern from official repositories if something is still available in AUR? And it also written only few word about "defaults.list" but may be someone want to know more it? It is just a little more information for curious users. I haven't found a better place for the table yet but I wish it will be somewhere in the Article, only left to find a section for it. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 22:34, 23 May 2016 (UTC)).</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Talk:XDG_MIME_Applications&diff=436189Talk:XDG MIME Applications2016-05-23T22:21:32Z<p>Andy Crowd: /* "Reason: The MIME database is located at" */ re:</p>
<hr />
<div>== Futher improvement ==<br />
<br />
Would be great to see such detailed explanation for KDE too. --[[User:AlexanderR|AlexanderR]] 23:57, 22 January 2012 (EST)<br />
<br />
It might be worth to mention that Enlightenment's file browser (in version e19) still uses the depreciated defaults.list file. --[[User:Drtebi|Drtebi]] ([[User talk:Drtebi|talk]]) 09:01, 25 December 2014 (UTC)<br />
<br />
: This can be placed in section "File managers" as a subsection for "Application launchers" (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 14:16, 20 May 2016 (UTC)).<br />
<br />
== <s>Clean up and Merging</s> ==<br />
<br />
This article is very difficult to read and understand. Also it provides redundant information which is better described within other wiki pages. <br />
<br />
* All *.desktop file related sections can be deleted and/or merged to the [[https://wiki.archlinux.org/index.php/Desktop_entries Desktop Entries]] article<br />
* All xdg-open related sections can be deleted and/or moved to the [[https://wiki.archlinux.org/index.php/Xdg-open xdg-open]] article<br />
<br />
After cleaning up and linking to those 'renewed' sections, this article should be rewritten in a way, that the reader understands the basics: <br />
<br />
* Which ways of defining default applications are available<br />
* Which ways are recommended for DEs, WMs or TTY environments<br />
* In which way does the system solve <br />
<br />
Following this, new sections describe different system environment setups. Hands-On examples or links end each environment section.<br />
<br />
{{unsigned|17:42, 21 March 2015|T.ask}}<br />
<br />
:Related discussion: [[Talk:xdg-open#About Merge]]. I think it would be simpler to recreate the article from scratch than try to fix it. -- [[User:Alad|Alad]] ([[User talk:Alad|talk]]) 18:05, 21 March 2015 (UTC)<br />
<br />
== <s>Maintaining settings for multiple desktop environments</s> ==<br />
<br />
Remove "This article or section needs expansion" in section "Maintaining settings for multiple desktop environments"?<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 10:27, 14 May 2016 (UTC)).<br />
:: I have renamed section and removed "tag" (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 09:43, 16 May 2016 (UTC)).<br />
<br />
== <s>about "Undo revision 434926"</s> ==<br />
<br />
# I have removed variables Categories and Keywords because they are not global as "NotShowIn" or "OnlyShowIn " or fixed as "Actions" and not affecting start up type as "Terminal", "DBusActivatable" or "MimeType".<br />
# The article is not directly related to *.desktop files but only on how MIME-types and *.desktop are related and affecting start up of programs in *.desktop. I could get a really big list of variables with {{ic|lsdesktopf --sud}} but this article is only about basics.<br />
* May be also add description about variables that begins with {{ic|X-}} are not general and supporting only by related desktop environments?<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 10:53, 14 May 2016 (UTC)).<br />
<br />
:I don't follow that. If the article is just about MIME type associations, why does the sentence above the table read "Common entries in *.desktop files that affects how application acts and '''shown in menu'''." and why do you add the link to the [https://specifications.freedesktop.org/menu-spec/latest/ menu specification] below it with [https://wiki.archlinux.org/index.php?title=Default_applications&diff=prev&oldid=434919]? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 11:32, 14 May 2016 (UTC)<br />
<br />
:: "Shown in menu" - I should explain more "shown in menu for default actions" in file manager, or removed it after I removed Keywords and Categories. This (freedesktop.org "[https://specifications.freedesktop.org/menu-spec/latest/ menu specification]".) I should also removed because it is not related to MIME-types.<br />
:: Or may be also remove variables: NoDisplay , NotShowIn , OnlyShowIn , TargetEnvironment? And leave only: Actions ,DBusActivatable ,MimeType ,StartupWMClass ,Terminal ,Type ?<br />
:: (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 12:05, 14 May 2016 (UTC)).<br />
<br />
:::Ok, I now understand why you removed "Categories" and "Keywords" and also which way you are working, but I do not agree yet: <br />
:::Whole desktop environments (e.g. [[MATE]]) were created because a lot of users prefer a traditional desktop with a menu tree for applications. A .desktop "Category" will sort an application into the correct position in the menu. That's a completely different way to work with the desktop than your way of using your desktop via right-click filemanager or MIME type assocations. <br />
:::(I appreciate your work for this article, but please stop editing it until is it clarified what content it is meant to contain. You editing out content I quote above is counter-productive. [https://wiki.archlinux.org/index.php?title=Default_applications&diff=next&oldid=434980]). <br />
:::In my view the article should be general, e.g. enable MATE users as well. What do you think (e.g. which article should MATE users get their info from)? <br />
:::--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:30, 14 May 2016 (UTC)<br />
<br />
:::: If the User questions is about why application isn't shown in a "Menu" then it should be in [[Desktop entries]] section but if the question is about MIME-type associations, correct start up of programs in *.desktop and variable: "Actions" related then it should be section about MIME-types. And may be give more description about variable '''Type'''. Here is output of unique '''Type''' that I found with my script:<br />
{{bc|1=Type=Application<br />
Type=MBTheme<br />
Type=MimeType<br />
Type=Service<br />
Type=XSession}} <br />
::::EDIT: Here is a big list of variables found only in my {{ic|/usr/share/applications}} directory: [[User:Andy Crowd/sandbox/Desktop users#List of variables | List of variables ]]<br />
:::: (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 14:22, 14 May 2016 (UTC)).<br />
<br />
::::: Ah, yes, that makes sense. I was reading too quick and did not follow through the link to [[Desktop entries]] via the [[Default applications#Maintaining settings for multiple desktop environments]] expansion template. <br />
::::: I agree now it makes sense to only have the .desktop variables in the table that relate to this article (MIME associations) and have undone my revert: [https://wiki.archlinux.org/index.php?title=Default_applications&diff=434996&oldid=434982] <br />
::::: There is [[Desktop entries#File example]] for the ones that affect how an application is put in the menu. Removing more (you mention NoDisplay, NotShowIn, OnlyShowIn, TargetEnvironment) makes sense too, but we should look first if something is useful to move to the other [[Desktop entries#File example]] list. <br />
::::: The two articles are very related and should crosslink each other in the intro, but that's another topic. <br />
::::: edit: I've added back [https://wiki.archlinux.org/index.php?title=Default_applications&diff=prev&oldid=435002], and [https://wiki.archlinux.org/index.php?title=Desktop_entries&type=revision&diff=435004&oldid=434032], [https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=435003&oldid=435002] to relate both articles. <br />
::::: Thanks for explaining! Ok to close this or other points related? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:06, 14 May 2016 (UTC)<br />
<br />
== Output examples by tools ==<br />
<br />
Almost for every output I use my lsdesktopf script or adding new functions to make need output, it feels like making of the useful advertisement. I am not sure if it is OK to write everywhere "See also:" "Use to show:" for my script that only shows everything to stdout or for other programs that manages mime-types in console and have some kind of output? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 21:27, 15 May 2016 (UTC)).<br />
<br />
: I see what you mean, your tool is very useful for complex searches. You can of course use a [[Template:Tip]] in a place where you think ''lfdesktopf'' is particularly handy for readers. Two further ideas: (1) You could change the second ''lsdesktopf'' example you provide in [[Desktop_entries#List_or_search_in_.2A.desktop_files]] for the tool to one that handling MIME-type information relevant here. (2) We still also have [[Xdg-open]], which is more about tools to configure. It has [[Xdg-open#Usage]] examples about searching MIME type, which can be crosslinked as examples too. <br />
: Apart from a tip, I would not use much more examples for tools in this article at the current time. First, it should be decided what happens to [[Xdg-open]]. After [[Talk:Xdg-open#Move_suggestion]] and [[Talk:Xdg-open#About_Merge]] are clear, we should have a place where some more useful tool command examples (incl. ''mimeo'' and ''lsdesktopf'') can be put. <br />
: Ok? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 16:43, 16 May 2016 (UTC)<br />
<br />
:: I am done with the 1st advice. But in [[Xdg-open#xdg-open replacements | xdg-open replacements]] can be moved to [[Default applications#Utilities to manage MIME types|Utilities to manage MIME types]], but I must rewrite section "Utilities to manage MIME types" in style as table in "xdg-open replacements" for some tools that is not there yet, I can't provide so detailed info about missing yet. Other parts I haven't decided where I can put, but it can be minimized very much. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:56, 16 May 2016 (UTC)).<br />
<br />
::: Alright, nice. I think it is simpler to convert all tools to [[Template:App]], as suggested in the style template, and drop the table. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:34, 17 May 2016 (UTC)<br />
<br />
:::: I think that it is better with table because it is comparison of tools and not just description with a link as in [[Template:App]]. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 04:39, 18 May 2016 (UTC)).<br />
<br />
::::: Fair enough, I've merged into the table. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:06, 18 May 2016 (UTC)<br />
<br />
:::::: After I will test all ''command line'' tools in table I will probably rewrite it in a table if I will find some bigger difference or similarity. Many programs are prioritizing *.xml instead of mimeapps*. It will be a big list of short examples for a while until I will short it down. And one more thing---- It is good to have a separator between examples but not section names, is it good if I will use bold text of tool names instead? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 16:17, 18 May 2016 (UTC)).<br />
<br />
::::::: We can't have examples for too many different tools, so I think one example section and bold as separator is a good idea. By the way: Why do you use ''xdg-mine'' for the first examples in [[Default_applications#Examples_of_usage]]? If they are needed here, they should be crosslinked to [[Xdg-open#Configuration]]. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 19:05, 18 May 2016 (UTC)<br />
<br />
:::::: I have edited table but it is so Ugly code inside, may be make new or it other was to make it look good. It might be also an alternative to have One More Table with Columns: Type(Launcher,Both,Setting,Incl. Tool),GUI(Yes,No),Prioritize Order(*.xml,file,other) (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:13, 18 May 2016 (UTC)).<br />
<br />
::::::: We can remake the table in simpler format. I can help, but not today. I also have to catch-up with all the great work you have already put into the article; I'll do that one of the next days. <br />
::::::: The new columns "Type" and "GUI" read good. One question from me: What do you mean by '''prioritize order'''(*.xml,file,other)? To my understanding, the *.xml files are part of the packages and should not be user modified (see [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923467984]). The new pacman hook does the automatic work for [https://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec/#index2h3 update-mime-database] according to what the applications provide in the .xml specs. It is ok to mention the *.xml files, because they are part of the logic. However, to my understanding the configuration of the correct {{ic|mimeapps.list}} should be the focus in his article, because this is where the user choice (app per mime type) is configured. <br />
::::::: So, what do you mean by "prioritize" ? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 19:03, 18 May 2016 (UTC)<br />
<br />
:::::::: I have created an example table at the bottom that shows "prioritize order", *.xml = that it detects MIME-type by extension, Magic = if no description about extension is found in *.xml (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:59, 18 May 2016 (UTC)).<br />
<br />
::::::::: I see and like how you are progressing with new ideas about the section and now also understand what you mean with "prioritize" (great you also adopted the archived AUR packages). The example you provide in [https://wiki.archlinux.org/index.php?title=Default_applications&curid=11760&diff=435514&oldid=435466] sounds like a ''xdg-mime'' bug to me actually - or was it a text that you renamed to foo-file.jpg to show the effect? Other than that I don't have more input at current. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 17:57, 19 May 2016 (UTC)<br />
<br />
Just try examples with and without any extension or with wrong extension, if you have DE installed and necessary tools. I just added extension to "foo-file". (The discussion is too tight now so I start with a new begin.) (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:07, 19 May 2016 (UTC)).<br />
<br />
: I think that I am done with all related to article name sections. I will not use many outputs per tool, only basic and little configuration.<br />
# '''Default applications'''<br />
## Description of what MIME-type is and ways Linux uses them.<br />
## Set default applications<br />
### Configure *.mimeapps.list files<br />
### Configure *.xml files<br />
### Use tools for configuration<br />
## Get information about MIME-types<br />
### in MIME-type database<br />
### using tools<br />
## Start default applications by<br />
### using utilities<br />
### configuring other applications to use tools for starting default applications<br />
## Troubleshooting of *.desktop files if associated program doesn't start correct<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 13:52, 20 May 2016 (UTC)).<br />
<br />
:I went through the article until the [[Default_applications#Utilities_to_manage_MIME_types]] section, please have a look, thanks. I like your above TOC layout a lot. I have started to implement it in a similar manner ([https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=435829&oldid=435824]) until the section I got today. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:00, 20 May 2016 (UTC)<br />
<br />
:: You did great, but I didn't described completely when I used word "misconfiguration" in section "Variables in .desktop files that affect application launch", I meant that not all variables in "Exec" can be combined in the same *.desktop file or in the same "Exec"(in some *.desktop files I found more then one "Exec" that belongs to each new section that related to description in variable Actions, for each Action own Exec in the new section within same *.desktop file), e.g. to open file and to open device can't be in the same *.desktop file with "Exec" but standard changes so I didn't wrote about all details only that "misconfigured" Exec can affect start or be shown in the menu. For the section about tools I don't know what is good and how much I should write about each tool or in subsections, e.g. xdg-open may be need more details but article is not about xdg-utils but too much examples not good. May be it can be different between subsections (in one more examples and in another less or no examples, e.g. as it look like now). May be also add a section about file managers as in suggestion: [[Talk:Default_applications#Futher_improvement]]? Add information about GUI launchers that each DE is using? Add some "ERROR" template about that sections about tools is not complete and must be extended or something in that style (it is very messy in that part) because I think that it can take long time until it will be completed? I don't know how much time I will have to put on wiki but I will do my best to "finish"(until I have some ideas and time left) this article and also may be add some more info to [[Desktop entries]]. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 23:57, 20 May 2016 (UTC)).<br />
<br />
::: Glad you are generally ok with my changes yesterday, if you see something wrong later - just change or tell me. Don't worry about time. The article is in a much better state already thanks to your expertise and careful work! If you want, you can also leave it to me to go over the [[Default applications#Utilities to manage MIME types]] section first, and see afterwards what of your ideas you want to implement as soon as you have time/want to work on it further. <br />
::: For the "Variables in .desktop files that affect application launch" section: yes I think I understand. Perhaps one of us has an idea later how to improve it without mentioning too many exceptional cases, it is a complicated topic. I think it should stay in Troubleshooting though, like you put it above in the TOC. <br />
::: For command output: I don't think we should mention much more about GUI tools/filemanagers of particular DE/WM. That should be left to the DE/WM (e.g. [[GNOME#Default applications]], [[Xfce#Menu]]), so that this article can stay more general. For more see my reply below to Kynikos. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:15, 21 May 2016 (UTC)<br />
<br />
I haven't followed this discussion closely, but after merging [[xdg-open]] I do think that at least some examples from the [https://wiki.archlinux.org/index.php?title=Xdg-open&oldid=435329#Configuration xdg-open#Configuration] section should be restored here, because for example the tables in [[Default_applications#Detect_MIME-type]] are quite informative, but at a glance it doesn't even look like they're talking about actual commands :) — [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 09:37, 21 May 2016 (UTC)<br />
<br />
:Yes, we all agree on this I think (see Andy's above reply). I think for now it is pretty simple to add back more command output, because Andy had actually [https://wiki.archlinux.org/index.php?title=Default_applications&diff=435514&oldid=435466 written] a meaningful command example before. In my view it should suffice for now to add back the commands leading to the [[Default_applications#Detect_MIME-type]] tables for now and then see how it works out. <br />
:Btw, can you name a couple of specifics for the top-level style template you put? I'd like to fix them on the next go through. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:15, 21 May 2016 (UTC)<br />
<br />
:: Is it OK to have a section with additional practical examples for other tools too as I started in [[Default applications#Extended practical examples]], without any cryptic descriptions (instead ''Type/Extension'' use ''video/flv'')? I don't see a better way of adding more examples without destroying logical layout of other sections. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:39, 21 May 2016 (UTC)).<br />
<br />
:::Thanks Andy, your solution works for me.<br />
:::@Indigo, I've [https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=436018&oldid=435979 fixed] several formatting/punctuation non-compliances, however I've left the values in the tables almost untouched for the moment; in theory options and variables should all be shown with [[Template:ic]], and I'm not sure under which [[Help:Style/Formatting and punctuation]] category we could consider MIME types to belong.<br />
:::– [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 05:46, 22 May 2016 (UTC)<br />
<br />
:::: Thanks for fixing, Kynikos. It was actually my confusion when I used [[Template:ic]] for ''.desktop'' extension et al. When I did so, I recalled Lahwaacz had reminded me to something similar a good year ago, but got misled trying to find it again in the style guide ^^ <br />
:::: For the MIME types: I don't think we can fix these 100%. I'd say they can be either [[Help:Style/Formatting_and_punctuation#Configuration_parameters.2C_variables.2C_options.2C_properties...|properties]] or (e.g. for custom x-* ones) [[Help:Style/Formatting and punctuation#File content]]. So, monospace in my view when mentiioned in text, but I'd like to keep them normal text in the tables. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 11:43, 23 May 2016 (UTC)<br />
<br />
== <s>About tag: "Reason: Lacks clarity, content tacked on" </s>==<br />
<br />
What is more missing or must be rewritten to remove tag about: "Reason: Lacks clarity, content tacked on" that is in section "MIME types and desktop entries"<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 09:47, 16 May 2016 (UTC))<br />
<br />
: I have removed <nowiki>"{{Style|Lacks clarity, content tacked on}}"</nowiki> and closed this discussion. If I was wrong then explain please what is still missing. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:25, 18 May 2016 (UTC)).<br />
<br />
== <s>Remove section ''Default locations of the mimeapps.list_files'' ? </s> ==<br />
<br />
[[Default_applications#Default_locations_of_the_.2Amimeapps.list_files| this section]] is a RAW copy from [https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html#file freedesktop.org]. It is better to have a link to it instead. What do you think, is it good if I remove it? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:44, 17 May 2016 (UTC)).<br />
: 8 vs 10 fields, 2 more fields in table in this wiki. this should stay I missed the difference that 2 global system path is only here. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:18, 17 May 2016 (UTC)).<br />
<br />
<br />
== "Reason: The MIME database is located at" ==<br />
<br />
Read here: [https://specifications.freedesktop.org/desktop-entry-spec/0.9.5/ar01s07.html]. "XDG MIME-type database" is in the {{ic|/usr/share/mime}} but {{ic|mimeinfo.cache}} is located in other folders and updates automatically after update or installation of new programs: {{hc|find /usr/ -type f -name "mimeinfo.cache"|<br />
/usr/local/share/applications/mimeinfo.cache<br />
/usr/share/applications/mimeinfo.cache}} <br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:05, 23 May 2016 (UTC)).<br />
<br />
:The section title is "Shared MIME-info database", there are two links to [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176] and the {{ic|update-mime-database.hook}} updates the database in {{ic|/usr/share/mime/}}. The {{ic|mimeinfo.cache}} files are different database handled by {{ic|update-desktop-database.hook}}. Also, there is an incomplete sentence around the first link. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 17:26, 23 May 2016 (UTC)<br />
<br />
:: Yes, you are right, it must be rewritten and corrected. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 22:21, 23 May 2016 (UTC)).<br />
<br />
== "Reason: The following comparison table either conflicts" ==<br />
<br />
The table contains just a list of packages and files to give the user an overview of packages that contains preset MIME-type files or a human readable description of MIME-types.<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:19, 23 May 2016 (UTC)).<br />
<br />
:{{ic|/etc/gnome/defaults.list}} does not contain any human-readable descriptions, but GNOME's default applications associations. {{ic|/etc/mime.types}} is a plain list of (some) MIME types and completely unrelated to the standard being described on the page. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 17:44, 23 May 2016 (UTC)<br />
<br />
:: The [[Wikipedia:Media_type#mime.types|mime.types]] is used as fallback by browsers to detect mime.type by extension, but also by some tools that are used to detect type of the file.<br />
{{hc|file /etc/gnome/defaults.list /usr/share/applications/defaults.list|<br />
/etc/gnome/defaults.list: ASCII text<br />
/usr/share/applications/defaults.list: symbolic link to /etc/gnome/defaults.list}}<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:26, 23 May 2016 (UTC)).<br />
:: Where should the table be placed, create new section? So far as it is not a binary data in the file it is readable, if has patterns then can be used tools like ''grep'', and it is a good basic description of some "1st parts" of MIME-type in this wiki now. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 20:14, 23 May 2016 (UTC)).<br />
<br />
:::Why do you want to show the {{AUR|gnome-defaults-list}} package at all? It doesn't matter that {{ic|/etc/gnome/defaults.list}} is a text file, I just don't see why it's so useful for showing and its relation to the other two packages. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 20:34, 23 May 2016 (UTC)</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=XDG_MIME_Applications&diff=436185XDG MIME Applications2016-05-23T20:21:27Z<p>Andy Crowd: /* Shared MIME-info database */ removed not completed sentence with link</p>
<hr />
<div>[[Category:Desktop environments]]<br />
[[ja:デフォルトアプリケーション]]<br />
[[ru:Changing filetype association via MIME]]<br />
[[zh-cn:Default applications]]<br />
{{Related articles start}}<br />
{{Related|Desktop entries}}<br />
{{Related|Desktop environment}}<br />
{{Related|Window manager}}<br />
{{Related articles end}}<br />
<br />
The type of a data file is usually, but not necessarily, denoted by the extension of the file name, for example ''.html'' or ''.jpeg''. A second way to determine the data type is via the so-called "magic bytes" at the start of the file. Both ways determine the MIME-type of the data. <br />
<br />
Each application installed to a system provides information about the MIME-types it can handle via the [[Desktop entries]], but frequently there is more than one application able to handle data of a certain MIME-type. This article describes how the ''default applications'' to handle a MIME-type can be configured. <br />
<br />
Note that while Arch Linux does not provide custom presets for default applications, the [[desktop environment]] you install may do so. Some desktop environments also provide a GUI or a file-manager which enables to interactively configure default applications for certain file extensions. If this suffices for your system usage, you may not need to configure anything further. <br />
<br />
The scope of this article is the freedesktop [https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html Association between MIME types and applications] specification. <br />
<br />
== MIME types and desktop entries ==<br />
<br />
MIME-types are specified by two slash ({{ic|/}}) parts: ''Type/Extension'', for example {{ic|video/x-ms-wmv}}. The second part of the MIME-type is expanding faster, for example with new applications or data encoding standards. <br />
<br />
The default applications to open a MIME-type are usually stored in [[#Default mimeapps.list paths|mimeapps.list]] files, but some programs store MIME-type associations in their own custom configuration files. If a MIME-type association is not found in the default configuration, the program should look for the first match of the MIME-type in ''.desktop'' files. <br />
<br />
Description of some MIME-type first part and examples of second parts:<br />
<br />
{| class="wikitable"<br />
! Type of MIME (1st part) !! Description !! Examples of extension (2nd part)<br />
|-<br />
|application || Files with binary content such, e.g.: documents,archives,... || epub+zip, ereader, excel, gbr, gzip<br />
|-<br />
|audio || Audio files that that can be played by a music player or audio editor || flac, m4a, midi<br />
|-<br />
|chemical || Chemical information, molecular and other chemical data || x-cif, x-cml, x-daylight-smiles, x-gamess-input, x-gamess-output, x-gaussian-checkpoint, x-gaussian-cube, x-gaussian-log, x-mopac-out, x-pdb, x-qchem-output, x-xyz<br />
|-<br />
|image || Image files that can be opened by image editor or image viewer || bmp, crw, g3fax, gif, jp2, jpeg, jpeg2000, jpg<br />
|-<br />
|inode || Can be opened by a file manager || blockdevice, chardevice, directory, fifo, mount-point, socket, symlink<br />
|-<br />
|message || Message protocols || delivery-status, disposition-notification, external-body, news, partial, rfc822, x-gnu-rmail<br />
|-<br />
|misc || Streaming meta data || ultravox<br />
|-<br />
|text || Text documents that can be viewed (e.g. with command ''less'') or opened with a text editor || html, javascript, mathml, mml, plain<br />
|-<br />
|video || Video files that can be played or edited with a video editor || flv, mp2t, mp4<br />
|-<br />
|x-content || Content on disks such as e.g. Audio,Video,Image or blank disk || audio-cdda, audio-player, blank-bd, blank-cd, blank-dvd, blank-hddvd, image-picturecd, video-dvd, video-svcd, video-vcd<br />
|-<br />
|x-scheme-handler || Internet protocol || ftp, geo, ghelp, help, http, https, hwplay, icy, icyx, info, irc, magnet, mailto, man, mms, mmsh, net, pnm, rtmp, rtp, rtsp, skype, uvox, vnc, xmpp<br />
|-<br />
|x-epoc || SISX package ||x-sisx-app<br />
|-<br />
|multipart || Multi-part mime messages ||alternative, appledouble, digest, encrypted, mixed, related, report, signed, x-mixed-replace<br />
|-<br />
|model || such as 3D model || x-kpovmodeler, vrml, x-modelica<br />
|}<br />
<br />
For the description of MIME-types you can search in XDG database:<br />
$ grep -e 'mime-type type=' -e '<comment>' /usr/share/mime/packages/freedesktop.org.xml<br />
<br />
{{Tip|To see all MIME extensions in the system's ''.desktop'' files that belongs to a MIME-type you can use {{AUR|lsdesktopf}}, for example {{ic|lsdesktopf --gm -gx video}}.}} <br />
<br />
If you ever require to create a custom association of a new file extension to a MIME-type, see the <br />
[http://standards.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html Association between MIME types and applications] standard.<br />
<br />
=== Default mimeapps.list paths ===<br />
<br />
The {{ic|mimeapps.list}} file stores the configuration for the default application to open a MIME-type. <br />
There are different locations for it: <br />
* system-wide, <br />
* per-user, <br />
* custom locations used by some programs.<br />
<br />
The {{ic|''$desktop''}} in the following list denotes the name of the related desktop environment or window manager. The search order of paths is: <br />
<br />
{| class="wikitable"<br />
! Path !! Usage<br />
|-<br />
| {{ic|$HOME/.config/''$desktop''-mimeapps.list}} || user overrides, desktop-specific<br />
|-<br />
| {{ic|$HOME/.config/mimeapps.list}} || user overrides<br />
|-<br />
| {{ic|/etc/xdg/''$desktop''-mimeapps.list}} || sysadmin and vendor overrides, desktop-specific<br />
|-<br />
| {{ic|/etc/xdg/mimeapps.list}} || sysadmin and vendor overrides<br />
|-<br />
| {{ic|$HOME/.local/share/applications/''$desktop''-mimeapps.list}} || for compatibility but now deprecated, desktop-specific<br />
|-<br />
| {{ic|$HOME/.local/share/applications/mimeapps.list}} || for compatibility but now deprecated<br />
|-<br />
| {{ic|/usr/local/share/applications/''$desktop''-mimeapps.list}}<br>{{ic|/usr/share/applications/$desktop-mimeapps.list}} || distribution-provided defaults, desktop-specific<br />
|-<br />
| {{ic|/usr/local/share/applications/mimeapps.list}}<br>{{ic|/usr/share/applications/mimeapps.list}} || distribution-provided defaults<br />
|}<br />
<br />
=== Description of the mimeapps.list file ===<br />
<br />
The file contains two main sections for default and additional alternatives to open files of a MIME-type. The second and the third section ({{ic|[Removed Associations]}}) are optional.<br />
<br />
Example:<br />
<br />
[Default Applications]<br />
mimetype1=default1.desktop<br />
<br />
Defined additional associations of applications to MIME-types:<br />
[Added Associations]<br />
mimetype1=foo1.desktop;foo2.desktop;foo3.desktop;<br />
mimetype2=foo4.desktop;<br />
<br />
Removed associations of applications with MIME-types (blacklisting a MIME-type association of an application in its {{ic|.desktop}} file):<br />
[Removed Associations]<br />
mimetype1=foo5.desktop<br />
<br />
Multiple ''.desktop'' files for a single MIME-type must be semicolon-separated. Not supported entries are ignored in {{ic|mimeapps.list}}. The DE/WM then searches for the first match to the needed MIME-type them in the default path for ''.desktop'' files. <br />
<br />
{{Tip|To get a quick overview of how many and which ''.desktop'' files can be associated with a certain MIME-type, you can use the {{AUR|lsdesktopf}} utility, e.g. {{ic|lsdesktopf --gen-mimeapps}}.}}<br />
<br />
{{Note|Arch Linux itself does not provide system-wide presets for associations, but other distributions and specific desktop environments may do so via packaged {{ic|mimeapps.list}} files, or the older and deprecated {{ic|defaults.list}} files. Hence, your choice of desktop environment, or none, will also affect how your default applications are associated.}}<br />
<br />
There are available additional preset MIME-type descriptions for a various desktop environments.<br />
<br />
{{Accuracy|The following comparison table either conflicts with the previous note or the items should not be compared at all. {{ic|defaults.list}} sets default applications associations, AFAIK the others don't. {{Pkg|shared-mime-info}} is required by many desktop-independent packages.}}<br />
<br />
{| class="wikitable"<br />
! Package name !! Description !! Files<br />
|-<br />
| {{AUR|gnome-defaults-list}} || Ubuntu defaults || {{ic|/etc/gnome/defaults.list}} <br> {{ic|/usr/share/applications/defaults.list}}<br />
|-<br />
| {{Pkg|mime-types}} || Additional list of MIME-types || {{ic|/etc/mime.types}}<br />
|-<br />
| {{Pkg|shared-mime-info}}|| XDG MIME-type database is a part of the package||| {{ic|/usr/share/mime/packages/freedesktop.org.xml}}<br />
|}<br />
<br />
== Shared MIME-info database ==<br />
<br />
{{Accuracy|The shared MIME-info database is located at {{ic|/usr/share/mime}}, not {{ic|/usr/share/applications}}.}}<br />
<br />
In background to the {{ic|mimeapps.list}} files, the system holds a database of MIME-type information registered via the installed applications' ''.desktop'' files. <br />
When an application is installed, updated or removed, a [[pacman]] hook automatically updates the database, located in the {{ic|mimeinfo.cache}} in the {{ic|/usr/local/share/applications}} and {{ic|/usr/share/applications}} directories. These files keep track of which MIME-types are associated with which ''.desktop'' files overall. <br />
<br />
{{Warning|The database files are not meant to be edited directly.}}<br />
<br />
Application specific configuration is stored in ''.xml'' files and further files of the [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176 shared MIME-info database], stored in ''.keys'' and ''.mime'' files that are located in {{ic|/usr/share/mime-info/}}.<br />
<br />
Global directories for the ''.xml'' files are:<br />
<br />
/usr/share/mimelnk/application/<br />
/usr/share/mime/packages/ <br />
<br />
{{Warning|Above should not be modified, for user-specific configuration see below.}}<br />
<br />
Any user-specific ''.xml'' configuration may be stored in:<br />
~/.local/share/mime/packages/<br />
<br />
=== Example: .xml and related .desktop configuration ===<br />
<br />
Create and edit {{ic|~/.local/share/mime/packages/application-x-foobar.xml}}:<br />
<br />
{{bc|1=<br />
<?xml version="1.0" encoding="UTF-8"?><br />
<nowiki><mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"></nowiki><br />
'''<mime-type type="application/x-foobar">'''<br />
<comment>foo file</comment><br />
<icon name="application-x-foobar"/><br />
<glob-deleteall/><br />
'''<glob pattern="*.foo"/>'''<br />
</mime-type><br />
</mime-info><br />
}}<br />
<br />
Create a related {{ic|~/.local/share/applications/foobar.desktop}} file:<br />
<br />
{{bc|1=<br />
[Desktop Entry]<br />
Name=Foobar<br />
Exec=/usr/bin/foobar<br />
'''MimeType=application/x-foobar'''<br />
Icon=foobar<br />
Terminal=false<br />
Type=Application<br />
Categories=AudioVideo;Player;Video;<br />
Comment=<br />
}}<br />
<br />
The {{ic|Categories}} variable contains information about the DE/WM ''menu'' where the application is placed.<br />
<br />
Now update the application and mime database with:<br />
<br />
$ update-desktop-database ~/.local/share/applications<br />
$ update-mime-database ~/.local/share/mime<br />
<br />
Programs that use MIME-types, such as file managers, should now open {{ic|*.foo}} files with foobar (you may need to restart your file manager to see the change.)<br />
<br />
See also [[Environment variables#Examples]] about global variables that can be used in start-up scripts to set default applications for specific actions.<br />
<br />
== Utilities to manage MIME types ==<br />
<br />
Many of the file managers has options to set up and configure associations of mime types with programs. <br />
<br />
It can be done by using:<br />
<br />
* Preferences for selected file<br />
* File manager configuration menu<br />
* External program for a specific file manager<br />
<br />
Other utilities to manage MIME-types are: <br />
<br />
{| class="wikitable"<br />
! Name/Package !! Method !! Based on !! xdg-utils replacement !! Configuration file<br />
|-<br />
| {{Pkg|mime-editor}} || MIME-type || Utility for [http://rox.sourceforge.net/desktop/home.html ROX] applications || ||<br />
|-<br />
| {{AUR|ayr}} || MIME-type <br> name <br> regex || {{Pkg|file}} <br> {{Pkg|perl-file-mimeinfo}}, etc|| || {{ic|mimeapps.list}} <br> {{ic|defaults.list}}<br />
|-<br />
| {{AUR|busking-git}} || regex || {{Pkg|perl-file-mimeinfo}} || yes || custom<br />
|-<br />
| {{AUR|linopen}} || || {{Pkg|file}} || || custom<br />
|-<br />
| {{AUR|mimeo}} || MIME-type <br> regex || {{Pkg|file}} || {{AUR|xdg-utils-mimeo}} ||{{ic|mimeapps.list}} <br> {{ic|defaults.list}} <br> custom is optional<br />
|-<br />
| {{AUR|mimi-git}} || || {{Pkg|file}} || yes || custom<br />
|-<br />
| {{ic|rifle}} <br> part of {{Pkg|ranger}} || MIME-type <br> name <br> regex || || || custom<br />
|-<br />
| {{AUR|sx-open}} || regex || {{Pkg|file}} <br> bash regex || yes || custom<br />
|-<br />
| {{AUR|whippet}} || MIME-type <br> name <br> regex || SQLite database <br> {{Pkg|file}} <br> {{Pkg|perl-file-mimeinfo}}, etc || || custom SQLite database <br> {{ic|mimeapps.list}}<br />
|-<br />
| {{Pkg|xdg-utils}} || || {{Pkg|file}} <br> {{Pkg|perl-file-mimeinfo}} || ||<br />
|}<br />
<br />
=== Examples of usage ===<br />
<br />
Here is a short description about how to use command line tools to show MIME-type of a file or set preferred program as default to open MIME-type.<br />
<br />
==== Detect MIME-type ====<br />
<br />
Tools detecting MIME-type by reading meta-data from header of the file or detecting by magic number that is in two bytes identifier in the begin of the file. See [[Wikipedia:File format#File header|File header]].<br />
<br />
Many programs are using command ''file'' to detect correct MIME-type. For detection it uses compiled database that is stored in the {{ic|/usr/share/misc/magic/}} directory. It has many options to determinate correct MIME-type and for showing output.<br />
<br />
In Linux it is two standards to detect MIME-type that can affect which program will start and open the file, e.g. extension is associated with one program but content is associated with another MIME-type. The simplest way to see what is your system prioritizes is by renaming file extension and check again with tools that can use custom [[#Associate file extensions with applications MIME-type|*.xml]] configuration files.<br />
<br />
Here is examples of utility ''xdg-mime'' that first checking association of extension in [[#Associate file extensions with applications MIME-type|*.xml]] configuration files.<br />
{| class="wikitable"<br />
! Without extension !! With extension <br />
|-<br />
|xdg-mime query filetype ''foo-file'' || xdg-mime query filetype ''foo-file''.''jpg''<br />
|-<br />
! application/vnd.oasis.opendocument.text || image/jpeg<br />
|-<br />
|}<br />
<br />
Comparison functionality of the tools <br />
<br />
Here is shown options only for simple or multiple checks of a file, for more options read their own documentation.<br />
{| class="wikitable"<br />
! Tool !! Option !! Detection order !! Functionality !! Type !! Interface<br />
|-<br />
|file || ''(has many)'' || Magic(Byte/Pattern) || Show only || binary || terminal<br />
|-<br />
|xdg-mime || query filetype || *.xml -> Magic || Show / Set || binary || terminal<br />
|-<br />
|mimetype || -i ''(*.xml)'' -M ''(Magic)'' || *.xml -> Magic || Show only || script || terminal<br />
|-<br />
|mimeo || -m || *.xml -> Magic || Show / Set / Launch || script || terminal<br />
|}<br />
<br />
==== Set use of MIME-type by default ====<br />
<br />
Comparison functionality of the tools <br />
<br />
Here is shown options only for single file associations, for more options read their own documentation.<br />
<br />
{| class="wikitable"<br />
! Tool !! Option !! Functionality !! Type !! Interface<br />
|-<br />
|xdg-mime || default ''*.desktop'' Type1/Extension1 Type2/Extension2 || Show / Set || binary || terminal<br />
|-<br />
|mimeo || --prefer 'regex:^Type/(Extension'''1'''<nowiki> |</nowiki>Extension?'''2''')$' ''*.desktop'' || Show / Set / Launch || script || terminal<br />
|-<br />
|mimeopen || --ask-default ''(interactive)'' || Set / Launch || script || terminal<br />
|}<br />
<br />
=== Application launchers ===<br />
<br />
{{App|xdg-open|Starting applications from command line, has basic functionality.|https://www.freedesktop.org/wiki/Software/xdg-utils/|{{Pkg|xdg-utils}}}}<br />
<br />
''xdg-open'' uses {{Pkg|perl-file-mimeinfo}} as a fallback ("generic") method if no [[desktop environment]] is detected. It is a desktop-independent tool. Many applications invoke the {{ic|xdg-open}} command internally. Inside a [[desktop environment]] it passes the arguments to desktop supported environment's file-opener applications (e.g. ''gvfs-open'', ''kde-open'', or ''exo-open''). When no desktop environment is detected the ''xdg-open'' will use its own configuration files.<br />
<br />
{{App|mimeopen|Starting applications from command line. It can use custom database and prompt user to chose default application from a list of detected relevant and offers to chose own alternative.|https://metacpan.org/release/File-MimeInfo|{{Pkg|perl-file-mimeinfo}}}}<br />
<br />
Example of the prompt:<br />
<br />
{{hc| mimeopen -d /path/to/foo-file|<br />
Please choose a default application for files of type ''Type''/''Extension''<br />
1) notepad (wine-extension-txt)<br />
2) Leafpad (leafpad)<br />
3) OpenOffice.org Writer (writer)<br />
4) gVim (gvim)<br />
5) Other...<br />
}}<br />
Your answer becomes the default handler for that type of file. Mimeopen is installed as {{ic|/usr/bin/vendor_perl/mimeopen}}.<br />
<br />
If you run ''xdg-open'' without a desktop environment, you should also install {{Pkg|perl-file-mimeinfo}}, or {{AUR|xdg-utils-mimeo}} and {{AUR|mimeo}} from the [[AUR]] for a faster alternative.<br />
<br />
==== Miscellaneous ====<br />
<br />
The [http://linux.die.net/man/4/mailcap mailcap] file.<br />
<br />
{{Expansion|When using {{AUR|run-mailcap}}, ''xdg-open'' may refer to it.[http://cgit.freedesktop.org/xdg/xdg-utils/tree/scripts/xdg-open.in#n266] It should then clearly not be combined with the below file to prevent endless loops.}}<br />
<br />
The ''.mailcap'' file format is used by mail programs such as {{Pkg|mutt}} and {{Pkg|sylpheed}}. To have those programs use ''xdg-open'', edit {{ic|~/.mailcap}}:<br />
<br />
{{hc|~/.mailcap|<br />
*/*; xdg-open "%s"<br />
}}<br />
<br />
=== Extended practical examples ===<br />
<br />
==== xdg-open ====<br />
<br />
''xdg-mime'' modifies the local file {{ic|~/.config/mimeapps.list}} and {{ic|~/.local/share/applications/mimeapps.list}} (deprecated).<br />
<br />
To '''query''' the mime type used by an existing file, use <br />
$ xdg-mime query ''filetype'' ''file.ext''<br />
<br />
To change an associated desktop entry by setting [[Thunar]] as the default file browser:<br />
<br />
$ xdg-mime default Thunar.desktop inode/directory<br />
Note that you should not specify the complete path, but only the name of the ''.desktop'' file.<br />
<br />
This command can take multiple mime-types, allowing related files to be handled by the same program. The example below associates [[Emacs]] to all known source files:<br />
$ xdg-mime default emacs.desktop $(grep '^text/x-*' /usr/share/mime/types)<br />
<br />
===== Set the default browser =====<br />
<br />
To set the default application for {{ic|http(s)://}} internet protocols:<br />
<br />
$ xdg-mime default midori.desktop x-scheme-handler/http<br />
$ xdg-mime default midori.desktop x-scheme-handler/https<br />
<br />
As an alternative try:<br />
<br />
$ xdg-settings set default-web-browser netsurf.desktop<br />
<br />
To verify if the URLs opens correctly:<br />
<br />
$ xdg-open <nowiki>https://archlinux.org</nowiki><br />
<br />
To associate ''.html'' files with the {{Pkg|netsurf}} web-browser:<br />
<br />
$ xdg-mime default netsurf.desktop text/html<br />
<br />
== Troubleshooting == <br />
<br />
=== Variables in .desktop files that affect application launch ===<br />
<br />
Desktop environments and file managers supporting the specifications launch programs according to definition in the ''.desktop'' files. See [[Desktop entries#Application entry]]. <br />
<br />
Usually, configuration of the packaged ''.desktop'' files is not required, but it may not be bug-free. Even if an application containing necessary MIME-type description in the ''.desktop'' file {{ic|MimeType}} variable that is used for association, it can fail to start correctly, not start at all or start without opening a file. <br />
<br />
This may happen, for example, if the {{ic|Exec}} variable is missing internal options needed for how to open a file, or how the application is shown in the menu. The {{ic|Exec}} variable usually begins with {{ic|%}}; for its currently supported options, see [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables exec-variables].<br />
<br />
The following table lists the main variable entries of ''.desktop'' files that affect how an application starts, if it has a MIME-type associated with it. <br />
<br />
{| class="wikitable"<br />
! Variable names !! Example 1 content !! Example 2 content !! Description<br />
|-<br />
| DBusActivatable || DBusActivatable=true || DBusActivatable=false || Application interact with [https://www.freedesktop.org/wiki/Software/dbus/ D-Bus]. <br> See also configuration: [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#dbus D-Bus].<br />
|-<br />
| MimeType || MimeType=application/vnd.oasis.opendocument.text || MimeType=application/vnd.sun.xml.math || List of MIME types supported by application<br />
|-<br />
| StartupWMClass || StartupWMClass=google-chrome || StartupWMClass=xpad || Associate windows with the owning application<br />
|-<br />
| Terminal || Terminal=true || Terminal=false || Start in default terminal<br />
|}</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Talk:XDG_MIME_Applications&diff=436184Talk:XDG MIME Applications2016-05-23T20:14:14Z<p>Andy Crowd: /* "Reason: The following comparison table either conflicts" */ re: added more questions</p>
<hr />
<div>== Futher improvement ==<br />
<br />
Would be great to see such detailed explanation for KDE too. --[[User:AlexanderR|AlexanderR]] 23:57, 22 January 2012 (EST)<br />
<br />
It might be worth to mention that Enlightenment's file browser (in version e19) still uses the depreciated defaults.list file. --[[User:Drtebi|Drtebi]] ([[User talk:Drtebi|talk]]) 09:01, 25 December 2014 (UTC)<br />
<br />
: This can be placed in section "File managers" as a subsection for "Application launchers" (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 14:16, 20 May 2016 (UTC)).<br />
<br />
== <s>Clean up and Merging</s> ==<br />
<br />
This article is very difficult to read and understand. Also it provides redundant information which is better described within other wiki pages. <br />
<br />
* All *.desktop file related sections can be deleted and/or merged to the [[https://wiki.archlinux.org/index.php/Desktop_entries Desktop Entries]] article<br />
* All xdg-open related sections can be deleted and/or moved to the [[https://wiki.archlinux.org/index.php/Xdg-open xdg-open]] article<br />
<br />
After cleaning up and linking to those 'renewed' sections, this article should be rewritten in a way, that the reader understands the basics: <br />
<br />
* Which ways of defining default applications are available<br />
* Which ways are recommended for DEs, WMs or TTY environments<br />
* In which way does the system solve <br />
<br />
Following this, new sections describe different system environment setups. Hands-On examples or links end each environment section.<br />
<br />
{{unsigned|17:42, 21 March 2015|T.ask}}<br />
<br />
:Related discussion: [[Talk:xdg-open#About Merge]]. I think it would be simpler to recreate the article from scratch than try to fix it. -- [[User:Alad|Alad]] ([[User talk:Alad|talk]]) 18:05, 21 March 2015 (UTC)<br />
<br />
== <s>Maintaining settings for multiple desktop environments</s> ==<br />
<br />
Remove "This article or section needs expansion" in section "Maintaining settings for multiple desktop environments"?<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 10:27, 14 May 2016 (UTC)).<br />
:: I have renamed section and removed "tag" (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 09:43, 16 May 2016 (UTC)).<br />
<br />
== <s>about "Undo revision 434926"</s> ==<br />
<br />
# I have removed variables Categories and Keywords because they are not global as "NotShowIn" or "OnlyShowIn " or fixed as "Actions" and not affecting start up type as "Terminal", "DBusActivatable" or "MimeType".<br />
# The article is not directly related to *.desktop files but only on how MIME-types and *.desktop are related and affecting start up of programs in *.desktop. I could get a really big list of variables with {{ic|lsdesktopf --sud}} but this article is only about basics.<br />
* May be also add description about variables that begins with {{ic|X-}} are not general and supporting only by related desktop environments?<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 10:53, 14 May 2016 (UTC)).<br />
<br />
:I don't follow that. If the article is just about MIME type associations, why does the sentence above the table read "Common entries in *.desktop files that affects how application acts and '''shown in menu'''." and why do you add the link to the [https://specifications.freedesktop.org/menu-spec/latest/ menu specification] below it with [https://wiki.archlinux.org/index.php?title=Default_applications&diff=prev&oldid=434919]? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 11:32, 14 May 2016 (UTC)<br />
<br />
:: "Shown in menu" - I should explain more "shown in menu for default actions" in file manager, or removed it after I removed Keywords and Categories. This (freedesktop.org "[https://specifications.freedesktop.org/menu-spec/latest/ menu specification]".) I should also removed because it is not related to MIME-types.<br />
:: Or may be also remove variables: NoDisplay , NotShowIn , OnlyShowIn , TargetEnvironment? And leave only: Actions ,DBusActivatable ,MimeType ,StartupWMClass ,Terminal ,Type ?<br />
:: (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 12:05, 14 May 2016 (UTC)).<br />
<br />
:::Ok, I now understand why you removed "Categories" and "Keywords" and also which way you are working, but I do not agree yet: <br />
:::Whole desktop environments (e.g. [[MATE]]) were created because a lot of users prefer a traditional desktop with a menu tree for applications. A .desktop "Category" will sort an application into the correct position in the menu. That's a completely different way to work with the desktop than your way of using your desktop via right-click filemanager or MIME type assocations. <br />
:::(I appreciate your work for this article, but please stop editing it until is it clarified what content it is meant to contain. You editing out content I quote above is counter-productive. [https://wiki.archlinux.org/index.php?title=Default_applications&diff=next&oldid=434980]). <br />
:::In my view the article should be general, e.g. enable MATE users as well. What do you think (e.g. which article should MATE users get their info from)? <br />
:::--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:30, 14 May 2016 (UTC)<br />
<br />
:::: If the User questions is about why application isn't shown in a "Menu" then it should be in [[Desktop entries]] section but if the question is about MIME-type associations, correct start up of programs in *.desktop and variable: "Actions" related then it should be section about MIME-types. And may be give more description about variable '''Type'''. Here is output of unique '''Type''' that I found with my script:<br />
{{bc|1=Type=Application<br />
Type=MBTheme<br />
Type=MimeType<br />
Type=Service<br />
Type=XSession}} <br />
::::EDIT: Here is a big list of variables found only in my {{ic|/usr/share/applications}} directory: [[User:Andy Crowd/sandbox/Desktop users#List of variables | List of variables ]]<br />
:::: (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 14:22, 14 May 2016 (UTC)).<br />
<br />
::::: Ah, yes, that makes sense. I was reading too quick and did not follow through the link to [[Desktop entries]] via the [[Default applications#Maintaining settings for multiple desktop environments]] expansion template. <br />
::::: I agree now it makes sense to only have the .desktop variables in the table that relate to this article (MIME associations) and have undone my revert: [https://wiki.archlinux.org/index.php?title=Default_applications&diff=434996&oldid=434982] <br />
::::: There is [[Desktop entries#File example]] for the ones that affect how an application is put in the menu. Removing more (you mention NoDisplay, NotShowIn, OnlyShowIn, TargetEnvironment) makes sense too, but we should look first if something is useful to move to the other [[Desktop entries#File example]] list. <br />
::::: The two articles are very related and should crosslink each other in the intro, but that's another topic. <br />
::::: edit: I've added back [https://wiki.archlinux.org/index.php?title=Default_applications&diff=prev&oldid=435002], and [https://wiki.archlinux.org/index.php?title=Desktop_entries&type=revision&diff=435004&oldid=434032], [https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=435003&oldid=435002] to relate both articles. <br />
::::: Thanks for explaining! Ok to close this or other points related? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:06, 14 May 2016 (UTC)<br />
<br />
== Output examples by tools ==<br />
<br />
Almost for every output I use my lsdesktopf script or adding new functions to make need output, it feels like making of the useful advertisement. I am not sure if it is OK to write everywhere "See also:" "Use to show:" for my script that only shows everything to stdout or for other programs that manages mime-types in console and have some kind of output? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 21:27, 15 May 2016 (UTC)).<br />
<br />
: I see what you mean, your tool is very useful for complex searches. You can of course use a [[Template:Tip]] in a place where you think ''lfdesktopf'' is particularly handy for readers. Two further ideas: (1) You could change the second ''lsdesktopf'' example you provide in [[Desktop_entries#List_or_search_in_.2A.desktop_files]] for the tool to one that handling MIME-type information relevant here. (2) We still also have [[Xdg-open]], which is more about tools to configure. It has [[Xdg-open#Usage]] examples about searching MIME type, which can be crosslinked as examples too. <br />
: Apart from a tip, I would not use much more examples for tools in this article at the current time. First, it should be decided what happens to [[Xdg-open]]. After [[Talk:Xdg-open#Move_suggestion]] and [[Talk:Xdg-open#About_Merge]] are clear, we should have a place where some more useful tool command examples (incl. ''mimeo'' and ''lsdesktopf'') can be put. <br />
: Ok? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 16:43, 16 May 2016 (UTC)<br />
<br />
:: I am done with the 1st advice. But in [[Xdg-open#xdg-open replacements | xdg-open replacements]] can be moved to [[Default applications#Utilities to manage MIME types|Utilities to manage MIME types]], but I must rewrite section "Utilities to manage MIME types" in style as table in "xdg-open replacements" for some tools that is not there yet, I can't provide so detailed info about missing yet. Other parts I haven't decided where I can put, but it can be minimized very much. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:56, 16 May 2016 (UTC)).<br />
<br />
::: Alright, nice. I think it is simpler to convert all tools to [[Template:App]], as suggested in the style template, and drop the table. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:34, 17 May 2016 (UTC)<br />
<br />
:::: I think that it is better with table because it is comparison of tools and not just description with a link as in [[Template:App]]. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 04:39, 18 May 2016 (UTC)).<br />
<br />
::::: Fair enough, I've merged into the table. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:06, 18 May 2016 (UTC)<br />
<br />
:::::: After I will test all ''command line'' tools in table I will probably rewrite it in a table if I will find some bigger difference or similarity. Many programs are prioritizing *.xml instead of mimeapps*. It will be a big list of short examples for a while until I will short it down. And one more thing---- It is good to have a separator between examples but not section names, is it good if I will use bold text of tool names instead? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 16:17, 18 May 2016 (UTC)).<br />
<br />
::::::: We can't have examples for too many different tools, so I think one example section and bold as separator is a good idea. By the way: Why do you use ''xdg-mine'' for the first examples in [[Default_applications#Examples_of_usage]]? If they are needed here, they should be crosslinked to [[Xdg-open#Configuration]]. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 19:05, 18 May 2016 (UTC)<br />
<br />
:::::: I have edited table but it is so Ugly code inside, may be make new or it other was to make it look good. It might be also an alternative to have One More Table with Columns: Type(Launcher,Both,Setting,Incl. Tool),GUI(Yes,No),Prioritize Order(*.xml,file,other) (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:13, 18 May 2016 (UTC)).<br />
<br />
::::::: We can remake the table in simpler format. I can help, but not today. I also have to catch-up with all the great work you have already put into the article; I'll do that one of the next days. <br />
::::::: The new columns "Type" and "GUI" read good. One question from me: What do you mean by '''prioritize order'''(*.xml,file,other)? To my understanding, the *.xml files are part of the packages and should not be user modified (see [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923467984]). The new pacman hook does the automatic work for [https://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec/#index2h3 update-mime-database] according to what the applications provide in the .xml specs. It is ok to mention the *.xml files, because they are part of the logic. However, to my understanding the configuration of the correct {{ic|mimeapps.list}} should be the focus in his article, because this is where the user choice (app per mime type) is configured. <br />
::::::: So, what do you mean by "prioritize" ? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 19:03, 18 May 2016 (UTC)<br />
<br />
:::::::: I have created an example table at the bottom that shows "prioritize order", *.xml = that it detects MIME-type by extension, Magic = if no description about extension is found in *.xml (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:59, 18 May 2016 (UTC)).<br />
<br />
::::::::: I see and like how you are progressing with new ideas about the section and now also understand what you mean with "prioritize" (great you also adopted the archived AUR packages). The example you provide in [https://wiki.archlinux.org/index.php?title=Default_applications&curid=11760&diff=435514&oldid=435466] sounds like a ''xdg-mime'' bug to me actually - or was it a text that you renamed to foo-file.jpg to show the effect? Other than that I don't have more input at current. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 17:57, 19 May 2016 (UTC)<br />
<br />
Just try examples with and without any extension or with wrong extension, if you have DE installed and necessary tools. I just added extension to "foo-file". (The discussion is too tight now so I start with a new begin.) (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:07, 19 May 2016 (UTC)).<br />
<br />
: I think that I am done with all related to article name sections. I will not use many outputs per tool, only basic and little configuration.<br />
# '''Default applications'''<br />
## Description of what MIME-type is and ways Linux uses them.<br />
## Set default applications<br />
### Configure *.mimeapps.list files<br />
### Configure *.xml files<br />
### Use tools for configuration<br />
## Get information about MIME-types<br />
### in MIME-type database<br />
### using tools<br />
## Start default applications by<br />
### using utilities<br />
### configuring other applications to use tools for starting default applications<br />
## Troubleshooting of *.desktop files if associated program doesn't start correct<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 13:52, 20 May 2016 (UTC)).<br />
<br />
:I went through the article until the [[Default_applications#Utilities_to_manage_MIME_types]] section, please have a look, thanks. I like your above TOC layout a lot. I have started to implement it in a similar manner ([https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=435829&oldid=435824]) until the section I got today. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:00, 20 May 2016 (UTC)<br />
<br />
:: You did great, but I didn't described completely when I used word "misconfiguration" in section "Variables in .desktop files that affect application launch", I meant that not all variables in "Exec" can be combined in the same *.desktop file or in the same "Exec"(in some *.desktop files I found more then one "Exec" that belongs to each new section that related to description in variable Actions, for each Action own Exec in the new section within same *.desktop file), e.g. to open file and to open device can't be in the same *.desktop file with "Exec" but standard changes so I didn't wrote about all details only that "misconfigured" Exec can affect start or be shown in the menu. For the section about tools I don't know what is good and how much I should write about each tool or in subsections, e.g. xdg-open may be need more details but article is not about xdg-utils but too much examples not good. May be it can be different between subsections (in one more examples and in another less or no examples, e.g. as it look like now). May be also add a section about file managers as in suggestion: [[Talk:Default_applications#Futher_improvement]]? Add information about GUI launchers that each DE is using? Add some "ERROR" template about that sections about tools is not complete and must be extended or something in that style (it is very messy in that part) because I think that it can take long time until it will be completed? I don't know how much time I will have to put on wiki but I will do my best to "finish"(until I have some ideas and time left) this article and also may be add some more info to [[Desktop entries]]. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 23:57, 20 May 2016 (UTC)).<br />
<br />
::: Glad you are generally ok with my changes yesterday, if you see something wrong later - just change or tell me. Don't worry about time. The article is in a much better state already thanks to your expertise and careful work! If you want, you can also leave it to me to go over the [[Default applications#Utilities to manage MIME types]] section first, and see afterwards what of your ideas you want to implement as soon as you have time/want to work on it further. <br />
::: For the "Variables in .desktop files that affect application launch" section: yes I think I understand. Perhaps one of us has an idea later how to improve it without mentioning too many exceptional cases, it is a complicated topic. I think it should stay in Troubleshooting though, like you put it above in the TOC. <br />
::: For command output: I don't think we should mention much more about GUI tools/filemanagers of particular DE/WM. That should be left to the DE/WM (e.g. [[GNOME#Default applications]], [[Xfce#Menu]]), so that this article can stay more general. For more see my reply below to Kynikos. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:15, 21 May 2016 (UTC)<br />
<br />
I haven't followed this discussion closely, but after merging [[xdg-open]] I do think that at least some examples from the [https://wiki.archlinux.org/index.php?title=Xdg-open&oldid=435329#Configuration xdg-open#Configuration] section should be restored here, because for example the tables in [[Default_applications#Detect_MIME-type]] are quite informative, but at a glance it doesn't even look like they're talking about actual commands :) — [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 09:37, 21 May 2016 (UTC)<br />
<br />
:Yes, we all agree on this I think (see Andy's above reply). I think for now it is pretty simple to add back more command output, because Andy had actually [https://wiki.archlinux.org/index.php?title=Default_applications&diff=435514&oldid=435466 written] a meaningful command example before. In my view it should suffice for now to add back the commands leading to the [[Default_applications#Detect_MIME-type]] tables for now and then see how it works out. <br />
:Btw, can you name a couple of specifics for the top-level style template you put? I'd like to fix them on the next go through. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:15, 21 May 2016 (UTC)<br />
<br />
:: Is it OK to have a section with additional practical examples for other tools too as I started in [[Default applications#Extended practical examples]], without any cryptic descriptions (instead ''Type/Extension'' use ''video/flv'')? I don't see a better way of adding more examples without destroying logical layout of other sections. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:39, 21 May 2016 (UTC)).<br />
<br />
:::Thanks Andy, your solution works for me.<br />
:::@Indigo, I've [https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=436018&oldid=435979 fixed] several formatting/punctuation non-compliances, however I've left the values in the tables almost untouched for the moment; in theory options and variables should all be shown with [[Template:ic]], and I'm not sure under which [[Help:Style/Formatting and punctuation]] category we could consider MIME types to belong.<br />
:::– [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 05:46, 22 May 2016 (UTC)<br />
<br />
:::: Thanks for fixing, Kynikos. It was actually my confusion when I used [[Template:ic]] for ''.desktop'' extension et al. When I did so, I recalled Lahwaacz had reminded me to something similar a good year ago, but got misled trying to find it again in the style guide ^^ <br />
:::: For the MIME types: I don't think we can fix these 100%. I'd say they can be either [[Help:Style/Formatting_and_punctuation#Configuration_parameters.2C_variables.2C_options.2C_properties...|properties]] or (e.g. for custom x-* ones) [[Help:Style/Formatting and punctuation#File content]]. So, monospace in my view when mentiioned in text, but I'd like to keep them normal text in the tables. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 11:43, 23 May 2016 (UTC)<br />
<br />
== <s>About tag: "Reason: Lacks clarity, content tacked on" </s>==<br />
<br />
What is more missing or must be rewritten to remove tag about: "Reason: Lacks clarity, content tacked on" that is in section "MIME types and desktop entries"<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 09:47, 16 May 2016 (UTC))<br />
<br />
: I have removed <nowiki>"{{Style|Lacks clarity, content tacked on}}"</nowiki> and closed this discussion. If I was wrong then explain please what is still missing. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:25, 18 May 2016 (UTC)).<br />
<br />
== <s>Remove section ''Default locations of the mimeapps.list_files'' ? </s> ==<br />
<br />
[[Default_applications#Default_locations_of_the_.2Amimeapps.list_files| this section]] is a RAW copy from [https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html#file freedesktop.org]. It is better to have a link to it instead. What do you think, is it good if I remove it? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:44, 17 May 2016 (UTC)).<br />
: 8 vs 10 fields, 2 more fields in table in this wiki. this should stay I missed the difference that 2 global system path is only here. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:18, 17 May 2016 (UTC)).<br />
<br />
<br />
== "Reason: The MIME database is located at" ==<br />
<br />
Read here: [https://specifications.freedesktop.org/desktop-entry-spec/0.9.5/ar01s07.html]. "XDG MIME-type database" is in the {{ic|/usr/share/mime}} but {{ic|mimeinfo.cache}} is located in other folders and updates automatically after update or installation of new programs: {{hc|find /usr/ -type f -name "mimeinfo.cache"|<br />
/usr/local/share/applications/mimeinfo.cache<br />
/usr/share/applications/mimeinfo.cache}} <br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:05, 23 May 2016 (UTC)).<br />
<br />
:The section title is "Shared MIME-info database", there are two links to [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176] and the {{ic|update-mime-database.hook}} updates the database in {{ic|/usr/share/mime/}}. The {{ic|mimeinfo.cache}} files are different database handled by {{ic|update-desktop-database.hook}}. Also, there is an incomplete sentence around the first link. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 17:26, 23 May 2016 (UTC)<br />
<br />
== "Reason: The following comparison table either conflicts" ==<br />
<br />
The table contains just a list of packages and files to give the user an overview of packages that contains preset MIME-type files or a human readable description of MIME-types.<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:19, 23 May 2016 (UTC)).<br />
<br />
:{{ic|/etc/gnome/defaults.list}} does not contain any human-readable descriptions, but GNOME's default applications associations. {{ic|/etc/mime.types}} is a plain list of (some) MIME types and completely unrelated to the standard being described on the page. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 17:44, 23 May 2016 (UTC)<br />
<br />
:: The [[Wikipedia:Media_type#mime.types|mime.types]] is used as fallback by browsers to detect mime.type by extension, but also by some tools that are used to detect type of the file.<br />
{{hc|file /etc/gnome/defaults.list /usr/share/applications/defaults.list|<br />
/etc/gnome/defaults.list: ASCII text<br />
/usr/share/applications/defaults.list: symbolic link to /etc/gnome/defaults.list}}<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:26, 23 May 2016 (UTC)).<br />
:: Where should the table be placed, create new section? So far as it is not a binary data in the file it is readable, if has patterns then can be used tools like ''grep'', and it is a good basic description of some "1st parts" of MIME-type in this wiki now. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 20:14, 23 May 2016 (UTC)).</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Talk:XDG_MIME_Applications&diff=436182Talk:XDG MIME Applications2016-05-23T18:27:14Z<p>Andy Crowd: /* "Reason: The following comparison table either conflicts" */ re:</p>
<hr />
<div>== Futher improvement ==<br />
<br />
Would be great to see such detailed explanation for KDE too. --[[User:AlexanderR|AlexanderR]] 23:57, 22 January 2012 (EST)<br />
<br />
It might be worth to mention that Enlightenment's file browser (in version e19) still uses the depreciated defaults.list file. --[[User:Drtebi|Drtebi]] ([[User talk:Drtebi|talk]]) 09:01, 25 December 2014 (UTC)<br />
<br />
: This can be placed in section "File managers" as a subsection for "Application launchers" (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 14:16, 20 May 2016 (UTC)).<br />
<br />
== <s>Clean up and Merging</s> ==<br />
<br />
This article is very difficult to read and understand. Also it provides redundant information which is better described within other wiki pages. <br />
<br />
* All *.desktop file related sections can be deleted and/or merged to the [[https://wiki.archlinux.org/index.php/Desktop_entries Desktop Entries]] article<br />
* All xdg-open related sections can be deleted and/or moved to the [[https://wiki.archlinux.org/index.php/Xdg-open xdg-open]] article<br />
<br />
After cleaning up and linking to those 'renewed' sections, this article should be rewritten in a way, that the reader understands the basics: <br />
<br />
* Which ways of defining default applications are available<br />
* Which ways are recommended for DEs, WMs or TTY environments<br />
* In which way does the system solve <br />
<br />
Following this, new sections describe different system environment setups. Hands-On examples or links end each environment section.<br />
<br />
{{unsigned|17:42, 21 March 2015|T.ask}}<br />
<br />
:Related discussion: [[Talk:xdg-open#About Merge]]. I think it would be simpler to recreate the article from scratch than try to fix it. -- [[User:Alad|Alad]] ([[User talk:Alad|talk]]) 18:05, 21 March 2015 (UTC)<br />
<br />
== <s>Maintaining settings for multiple desktop environments</s> ==<br />
<br />
Remove "This article or section needs expansion" in section "Maintaining settings for multiple desktop environments"?<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 10:27, 14 May 2016 (UTC)).<br />
:: I have renamed section and removed "tag" (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 09:43, 16 May 2016 (UTC)).<br />
<br />
== <s>about "Undo revision 434926"</s> ==<br />
<br />
# I have removed variables Categories and Keywords because they are not global as "NotShowIn" or "OnlyShowIn " or fixed as "Actions" and not affecting start up type as "Terminal", "DBusActivatable" or "MimeType".<br />
# The article is not directly related to *.desktop files but only on how MIME-types and *.desktop are related and affecting start up of programs in *.desktop. I could get a really big list of variables with {{ic|lsdesktopf --sud}} but this article is only about basics.<br />
* May be also add description about variables that begins with {{ic|X-}} are not general and supporting only by related desktop environments?<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 10:53, 14 May 2016 (UTC)).<br />
<br />
:I don't follow that. If the article is just about MIME type associations, why does the sentence above the table read "Common entries in *.desktop files that affects how application acts and '''shown in menu'''." and why do you add the link to the [https://specifications.freedesktop.org/menu-spec/latest/ menu specification] below it with [https://wiki.archlinux.org/index.php?title=Default_applications&diff=prev&oldid=434919]? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 11:32, 14 May 2016 (UTC)<br />
<br />
:: "Shown in menu" - I should explain more "shown in menu for default actions" in file manager, or removed it after I removed Keywords and Categories. This (freedesktop.org "[https://specifications.freedesktop.org/menu-spec/latest/ menu specification]".) I should also removed because it is not related to MIME-types.<br />
:: Or may be also remove variables: NoDisplay , NotShowIn , OnlyShowIn , TargetEnvironment? And leave only: Actions ,DBusActivatable ,MimeType ,StartupWMClass ,Terminal ,Type ?<br />
:: (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 12:05, 14 May 2016 (UTC)).<br />
<br />
:::Ok, I now understand why you removed "Categories" and "Keywords" and also which way you are working, but I do not agree yet: <br />
:::Whole desktop environments (e.g. [[MATE]]) were created because a lot of users prefer a traditional desktop with a menu tree for applications. A .desktop "Category" will sort an application into the correct position in the menu. That's a completely different way to work with the desktop than your way of using your desktop via right-click filemanager or MIME type assocations. <br />
:::(I appreciate your work for this article, but please stop editing it until is it clarified what content it is meant to contain. You editing out content I quote above is counter-productive. [https://wiki.archlinux.org/index.php?title=Default_applications&diff=next&oldid=434980]). <br />
:::In my view the article should be general, e.g. enable MATE users as well. What do you think (e.g. which article should MATE users get their info from)? <br />
:::--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:30, 14 May 2016 (UTC)<br />
<br />
:::: If the User questions is about why application isn't shown in a "Menu" then it should be in [[Desktop entries]] section but if the question is about MIME-type associations, correct start up of programs in *.desktop and variable: "Actions" related then it should be section about MIME-types. And may be give more description about variable '''Type'''. Here is output of unique '''Type''' that I found with my script:<br />
{{bc|1=Type=Application<br />
Type=MBTheme<br />
Type=MimeType<br />
Type=Service<br />
Type=XSession}} <br />
::::EDIT: Here is a big list of variables found only in my {{ic|/usr/share/applications}} directory: [[User:Andy Crowd/sandbox/Desktop users#List of variables | List of variables ]]<br />
:::: (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 14:22, 14 May 2016 (UTC)).<br />
<br />
::::: Ah, yes, that makes sense. I was reading too quick and did not follow through the link to [[Desktop entries]] via the [[Default applications#Maintaining settings for multiple desktop environments]] expansion template. <br />
::::: I agree now it makes sense to only have the .desktop variables in the table that relate to this article (MIME associations) and have undone my revert: [https://wiki.archlinux.org/index.php?title=Default_applications&diff=434996&oldid=434982] <br />
::::: There is [[Desktop entries#File example]] for the ones that affect how an application is put in the menu. Removing more (you mention NoDisplay, NotShowIn, OnlyShowIn, TargetEnvironment) makes sense too, but we should look first if something is useful to move to the other [[Desktop entries#File example]] list. <br />
::::: The two articles are very related and should crosslink each other in the intro, but that's another topic. <br />
::::: edit: I've added back [https://wiki.archlinux.org/index.php?title=Default_applications&diff=prev&oldid=435002], and [https://wiki.archlinux.org/index.php?title=Desktop_entries&type=revision&diff=435004&oldid=434032], [https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=435003&oldid=435002] to relate both articles. <br />
::::: Thanks for explaining! Ok to close this or other points related? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:06, 14 May 2016 (UTC)<br />
<br />
== Output examples by tools ==<br />
<br />
Almost for every output I use my lsdesktopf script or adding new functions to make need output, it feels like making of the useful advertisement. I am not sure if it is OK to write everywhere "See also:" "Use to show:" for my script that only shows everything to stdout or for other programs that manages mime-types in console and have some kind of output? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 21:27, 15 May 2016 (UTC)).<br />
<br />
: I see what you mean, your tool is very useful for complex searches. You can of course use a [[Template:Tip]] in a place where you think ''lfdesktopf'' is particularly handy for readers. Two further ideas: (1) You could change the second ''lsdesktopf'' example you provide in [[Desktop_entries#List_or_search_in_.2A.desktop_files]] for the tool to one that handling MIME-type information relevant here. (2) We still also have [[Xdg-open]], which is more about tools to configure. It has [[Xdg-open#Usage]] examples about searching MIME type, which can be crosslinked as examples too. <br />
: Apart from a tip, I would not use much more examples for tools in this article at the current time. First, it should be decided what happens to [[Xdg-open]]. After [[Talk:Xdg-open#Move_suggestion]] and [[Talk:Xdg-open#About_Merge]] are clear, we should have a place where some more useful tool command examples (incl. ''mimeo'' and ''lsdesktopf'') can be put. <br />
: Ok? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 16:43, 16 May 2016 (UTC)<br />
<br />
:: I am done with the 1st advice. But in [[Xdg-open#xdg-open replacements | xdg-open replacements]] can be moved to [[Default applications#Utilities to manage MIME types|Utilities to manage MIME types]], but I must rewrite section "Utilities to manage MIME types" in style as table in "xdg-open replacements" for some tools that is not there yet, I can't provide so detailed info about missing yet. Other parts I haven't decided where I can put, but it can be minimized very much. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:56, 16 May 2016 (UTC)).<br />
<br />
::: Alright, nice. I think it is simpler to convert all tools to [[Template:App]], as suggested in the style template, and drop the table. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:34, 17 May 2016 (UTC)<br />
<br />
:::: I think that it is better with table because it is comparison of tools and not just description with a link as in [[Template:App]]. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 04:39, 18 May 2016 (UTC)).<br />
<br />
::::: Fair enough, I've merged into the table. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:06, 18 May 2016 (UTC)<br />
<br />
:::::: After I will test all ''command line'' tools in table I will probably rewrite it in a table if I will find some bigger difference or similarity. Many programs are prioritizing *.xml instead of mimeapps*. It will be a big list of short examples for a while until I will short it down. And one more thing---- It is good to have a separator between examples but not section names, is it good if I will use bold text of tool names instead? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 16:17, 18 May 2016 (UTC)).<br />
<br />
::::::: We can't have examples for too many different tools, so I think one example section and bold as separator is a good idea. By the way: Why do you use ''xdg-mine'' for the first examples in [[Default_applications#Examples_of_usage]]? If they are needed here, they should be crosslinked to [[Xdg-open#Configuration]]. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 19:05, 18 May 2016 (UTC)<br />
<br />
:::::: I have edited table but it is so Ugly code inside, may be make new or it other was to make it look good. It might be also an alternative to have One More Table with Columns: Type(Launcher,Both,Setting,Incl. Tool),GUI(Yes,No),Prioritize Order(*.xml,file,other) (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:13, 18 May 2016 (UTC)).<br />
<br />
::::::: We can remake the table in simpler format. I can help, but not today. I also have to catch-up with all the great work you have already put into the article; I'll do that one of the next days. <br />
::::::: The new columns "Type" and "GUI" read good. One question from me: What do you mean by '''prioritize order'''(*.xml,file,other)? To my understanding, the *.xml files are part of the packages and should not be user modified (see [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923467984]). The new pacman hook does the automatic work for [https://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec/#index2h3 update-mime-database] according to what the applications provide in the .xml specs. It is ok to mention the *.xml files, because they are part of the logic. However, to my understanding the configuration of the correct {{ic|mimeapps.list}} should be the focus in his article, because this is where the user choice (app per mime type) is configured. <br />
::::::: So, what do you mean by "prioritize" ? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 19:03, 18 May 2016 (UTC)<br />
<br />
:::::::: I have created an example table at the bottom that shows "prioritize order", *.xml = that it detects MIME-type by extension, Magic = if no description about extension is found in *.xml (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:59, 18 May 2016 (UTC)).<br />
<br />
::::::::: I see and like how you are progressing with new ideas about the section and now also understand what you mean with "prioritize" (great you also adopted the archived AUR packages). The example you provide in [https://wiki.archlinux.org/index.php?title=Default_applications&curid=11760&diff=435514&oldid=435466] sounds like a ''xdg-mime'' bug to me actually - or was it a text that you renamed to foo-file.jpg to show the effect? Other than that I don't have more input at current. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 17:57, 19 May 2016 (UTC)<br />
<br />
Just try examples with and without any extension or with wrong extension, if you have DE installed and necessary tools. I just added extension to "foo-file". (The discussion is too tight now so I start with a new begin.) (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:07, 19 May 2016 (UTC)).<br />
<br />
: I think that I am done with all related to article name sections. I will not use many outputs per tool, only basic and little configuration.<br />
# '''Default applications'''<br />
## Description of what MIME-type is and ways Linux uses them.<br />
## Set default applications<br />
### Configure *.mimeapps.list files<br />
### Configure *.xml files<br />
### Use tools for configuration<br />
## Get information about MIME-types<br />
### in MIME-type database<br />
### using tools<br />
## Start default applications by<br />
### using utilities<br />
### configuring other applications to use tools for starting default applications<br />
## Troubleshooting of *.desktop files if associated program doesn't start correct<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 13:52, 20 May 2016 (UTC)).<br />
<br />
:I went through the article until the [[Default_applications#Utilities_to_manage_MIME_types]] section, please have a look, thanks. I like your above TOC layout a lot. I have started to implement it in a similar manner ([https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=435829&oldid=435824]) until the section I got today. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:00, 20 May 2016 (UTC)<br />
<br />
:: You did great, but I didn't described completely when I used word "misconfiguration" in section "Variables in .desktop files that affect application launch", I meant that not all variables in "Exec" can be combined in the same *.desktop file or in the same "Exec"(in some *.desktop files I found more then one "Exec" that belongs to each new section that related to description in variable Actions, for each Action own Exec in the new section within same *.desktop file), e.g. to open file and to open device can't be in the same *.desktop file with "Exec" but standard changes so I didn't wrote about all details only that "misconfigured" Exec can affect start or be shown in the menu. For the section about tools I don't know what is good and how much I should write about each tool or in subsections, e.g. xdg-open may be need more details but article is not about xdg-utils but too much examples not good. May be it can be different between subsections (in one more examples and in another less or no examples, e.g. as it look like now). May be also add a section about file managers as in suggestion: [[Talk:Default_applications#Futher_improvement]]? Add information about GUI launchers that each DE is using? Add some "ERROR" template about that sections about tools is not complete and must be extended or something in that style (it is very messy in that part) because I think that it can take long time until it will be completed? I don't know how much time I will have to put on wiki but I will do my best to "finish"(until I have some ideas and time left) this article and also may be add some more info to [[Desktop entries]]. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 23:57, 20 May 2016 (UTC)).<br />
<br />
::: Glad you are generally ok with my changes yesterday, if you see something wrong later - just change or tell me. Don't worry about time. The article is in a much better state already thanks to your expertise and careful work! If you want, you can also leave it to me to go over the [[Default applications#Utilities to manage MIME types]] section first, and see afterwards what of your ideas you want to implement as soon as you have time/want to work on it further. <br />
::: For the "Variables in .desktop files that affect application launch" section: yes I think I understand. Perhaps one of us has an idea later how to improve it without mentioning too many exceptional cases, it is a complicated topic. I think it should stay in Troubleshooting though, like you put it above in the TOC. <br />
::: For command output: I don't think we should mention much more about GUI tools/filemanagers of particular DE/WM. That should be left to the DE/WM (e.g. [[GNOME#Default applications]], [[Xfce#Menu]]), so that this article can stay more general. For more see my reply below to Kynikos. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:15, 21 May 2016 (UTC)<br />
<br />
I haven't followed this discussion closely, but after merging [[xdg-open]] I do think that at least some examples from the [https://wiki.archlinux.org/index.php?title=Xdg-open&oldid=435329#Configuration xdg-open#Configuration] section should be restored here, because for example the tables in [[Default_applications#Detect_MIME-type]] are quite informative, but at a glance it doesn't even look like they're talking about actual commands :) — [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 09:37, 21 May 2016 (UTC)<br />
<br />
:Yes, we all agree on this I think (see Andy's above reply). I think for now it is pretty simple to add back more command output, because Andy had actually [https://wiki.archlinux.org/index.php?title=Default_applications&diff=435514&oldid=435466 written] a meaningful command example before. In my view it should suffice for now to add back the commands leading to the [[Default_applications#Detect_MIME-type]] tables for now and then see how it works out. <br />
:Btw, can you name a couple of specifics for the top-level style template you put? I'd like to fix them on the next go through. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:15, 21 May 2016 (UTC)<br />
<br />
:: Is it OK to have a section with additional practical examples for other tools too as I started in [[Default applications#Extended practical examples]], without any cryptic descriptions (instead ''Type/Extension'' use ''video/flv'')? I don't see a better way of adding more examples without destroying logical layout of other sections. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:39, 21 May 2016 (UTC)).<br />
<br />
:::Thanks Andy, your solution works for me.<br />
:::@Indigo, I've [https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=436018&oldid=435979 fixed] several formatting/punctuation non-compliances, however I've left the values in the tables almost untouched for the moment; in theory options and variables should all be shown with [[Template:ic]], and I'm not sure under which [[Help:Style/Formatting and punctuation]] category we could consider MIME types to belong.<br />
:::– [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 05:46, 22 May 2016 (UTC)<br />
<br />
:::: Thanks for fixing, Kynikos. It was actually my confusion when I used [[Template:ic]] for ''.desktop'' extension et al. When I did so, I recalled Lahwaacz had reminded me to something similar a good year ago, but got misled trying to find it again in the style guide ^^ <br />
:::: For the MIME types: I don't think we can fix these 100%. I'd say they can be either [[Help:Style/Formatting_and_punctuation#Configuration_parameters.2C_variables.2C_options.2C_properties...|properties]] or (e.g. for custom x-* ones) [[Help:Style/Formatting and punctuation#File content]]. So, monospace in my view when mentiioned in text, but I'd like to keep them normal text in the tables. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 11:43, 23 May 2016 (UTC)<br />
<br />
== <s>About tag: "Reason: Lacks clarity, content tacked on" </s>==<br />
<br />
What is more missing or must be rewritten to remove tag about: "Reason: Lacks clarity, content tacked on" that is in section "MIME types and desktop entries"<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 09:47, 16 May 2016 (UTC))<br />
<br />
: I have removed <nowiki>"{{Style|Lacks clarity, content tacked on}}"</nowiki> and closed this discussion. If I was wrong then explain please what is still missing. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:25, 18 May 2016 (UTC)).<br />
<br />
== <s>Remove section ''Default locations of the mimeapps.list_files'' ? </s> ==<br />
<br />
[[Default_applications#Default_locations_of_the_.2Amimeapps.list_files| this section]] is a RAW copy from [https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html#file freedesktop.org]. It is better to have a link to it instead. What do you think, is it good if I remove it? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:44, 17 May 2016 (UTC)).<br />
: 8 vs 10 fields, 2 more fields in table in this wiki. this should stay I missed the difference that 2 global system path is only here. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:18, 17 May 2016 (UTC)).<br />
<br />
<br />
== "Reason: The MIME database is located at" ==<br />
<br />
Read here: [https://specifications.freedesktop.org/desktop-entry-spec/0.9.5/ar01s07.html]. "XDG MIME-type database" is in the {{ic|/usr/share/mime}} but {{ic|mimeinfo.cache}} is located in other folders and updates automatically after update or installation of new programs: {{hc|find /usr/ -type f -name "mimeinfo.cache"|<br />
/usr/local/share/applications/mimeinfo.cache<br />
/usr/share/applications/mimeinfo.cache}} <br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:05, 23 May 2016 (UTC)).<br />
<br />
:The section title is "Shared MIME-info database", there are two links to [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176] and the {{ic|update-mime-database.hook}} updates the database in {{ic|/usr/share/mime/}}. The {{ic|mimeinfo.cache}} files are different database handled by {{ic|update-desktop-database.hook}}. Also, there is an incomplete sentence around the first link. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 17:26, 23 May 2016 (UTC)<br />
<br />
== "Reason: The following comparison table either conflicts" ==<br />
<br />
The table contains just a list of packages and files to give the user an overview of packages that contains preset MIME-type files or a human readable description of MIME-types.<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:19, 23 May 2016 (UTC)).<br />
<br />
:{{ic|/etc/gnome/defaults.list}} does not contain any human-readable descriptions, but GNOME's default applications associations. {{ic|/etc/mime.types}} is a plain list of (some) MIME types and completely unrelated to the standard being described on the page. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 17:44, 23 May 2016 (UTC)<br />
<br />
:: The [[Wikipedia:Media_type#mime.types|mime.types]] is used as fallback by browsers to detect mime.type by extension, but also by some tools that are used to detect type of the file.<br />
{{hc|file /etc/gnome/defaults.list /usr/share/applications/defaults.list|<br />
/etc/gnome/defaults.list: ASCII text<br />
/usr/share/applications/defaults.list: symbolic link to /etc/gnome/defaults.list}}<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:26, 23 May 2016 (UTC)).</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Talk:XDG_MIME_Applications&diff=436177Talk:XDG MIME Applications2016-05-23T17:19:41Z<p>Andy Crowd: re: "Reason: The following comparison table either conflicts"</p>
<hr />
<div>== Futher improvement ==<br />
<br />
Would be great to see such detailed explanation for KDE too. --[[User:AlexanderR|AlexanderR]] 23:57, 22 January 2012 (EST)<br />
<br />
It might be worth to mention that Enlightenment's file browser (in version e19) still uses the depreciated defaults.list file. --[[User:Drtebi|Drtebi]] ([[User talk:Drtebi|talk]]) 09:01, 25 December 2014 (UTC)<br />
<br />
: This can be placed in section "File managers" as a subsection for "Application launchers" (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 14:16, 20 May 2016 (UTC)).<br />
<br />
== <s>Clean up and Merging</s> ==<br />
<br />
This article is very difficult to read and understand. Also it provides redundant information which is better described within other wiki pages. <br />
<br />
* All *.desktop file related sections can be deleted and/or merged to the [[https://wiki.archlinux.org/index.php/Desktop_entries Desktop Entries]] article<br />
* All xdg-open related sections can be deleted and/or moved to the [[https://wiki.archlinux.org/index.php/Xdg-open xdg-open]] article<br />
<br />
After cleaning up and linking to those 'renewed' sections, this article should be rewritten in a way, that the reader understands the basics: <br />
<br />
* Which ways of defining default applications are available<br />
* Which ways are recommended for DEs, WMs or TTY environments<br />
* In which way does the system solve <br />
<br />
Following this, new sections describe different system environment setups. Hands-On examples or links end each environment section.<br />
<br />
{{unsigned|17:42, 21 March 2015|T.ask}}<br />
<br />
:Related discussion: [[Talk:xdg-open#About Merge]]. I think it would be simpler to recreate the article from scratch than try to fix it. -- [[User:Alad|Alad]] ([[User talk:Alad|talk]]) 18:05, 21 March 2015 (UTC)<br />
<br />
== <s>Maintaining settings for multiple desktop environments</s> ==<br />
<br />
Remove "This article or section needs expansion" in section "Maintaining settings for multiple desktop environments"?<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 10:27, 14 May 2016 (UTC)).<br />
:: I have renamed section and removed "tag" (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 09:43, 16 May 2016 (UTC)).<br />
<br />
== <s>about "Undo revision 434926"</s> ==<br />
<br />
# I have removed variables Categories and Keywords because they are not global as "NotShowIn" or "OnlyShowIn " or fixed as "Actions" and not affecting start up type as "Terminal", "DBusActivatable" or "MimeType".<br />
# The article is not directly related to *.desktop files but only on how MIME-types and *.desktop are related and affecting start up of programs in *.desktop. I could get a really big list of variables with {{ic|lsdesktopf --sud}} but this article is only about basics.<br />
* May be also add description about variables that begins with {{ic|X-}} are not general and supporting only by related desktop environments?<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 10:53, 14 May 2016 (UTC)).<br />
<br />
:I don't follow that. If the article is just about MIME type associations, why does the sentence above the table read "Common entries in *.desktop files that affects how application acts and '''shown in menu'''." and why do you add the link to the [https://specifications.freedesktop.org/menu-spec/latest/ menu specification] below it with [https://wiki.archlinux.org/index.php?title=Default_applications&diff=prev&oldid=434919]? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 11:32, 14 May 2016 (UTC)<br />
<br />
:: "Shown in menu" - I should explain more "shown in menu for default actions" in file manager, or removed it after I removed Keywords and Categories. This (freedesktop.org "[https://specifications.freedesktop.org/menu-spec/latest/ menu specification]".) I should also removed because it is not related to MIME-types.<br />
:: Or may be also remove variables: NoDisplay , NotShowIn , OnlyShowIn , TargetEnvironment? And leave only: Actions ,DBusActivatable ,MimeType ,StartupWMClass ,Terminal ,Type ?<br />
:: (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 12:05, 14 May 2016 (UTC)).<br />
<br />
:::Ok, I now understand why you removed "Categories" and "Keywords" and also which way you are working, but I do not agree yet: <br />
:::Whole desktop environments (e.g. [[MATE]]) were created because a lot of users prefer a traditional desktop with a menu tree for applications. A .desktop "Category" will sort an application into the correct position in the menu. That's a completely different way to work with the desktop than your way of using your desktop via right-click filemanager or MIME type assocations. <br />
:::(I appreciate your work for this article, but please stop editing it until is it clarified what content it is meant to contain. You editing out content I quote above is counter-productive. [https://wiki.archlinux.org/index.php?title=Default_applications&diff=next&oldid=434980]). <br />
:::In my view the article should be general, e.g. enable MATE users as well. What do you think (e.g. which article should MATE users get their info from)? <br />
:::--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:30, 14 May 2016 (UTC)<br />
<br />
:::: If the User questions is about why application isn't shown in a "Menu" then it should be in [[Desktop entries]] section but if the question is about MIME-type associations, correct start up of programs in *.desktop and variable: "Actions" related then it should be section about MIME-types. And may be give more description about variable '''Type'''. Here is output of unique '''Type''' that I found with my script:<br />
{{bc|1=Type=Application<br />
Type=MBTheme<br />
Type=MimeType<br />
Type=Service<br />
Type=XSession}} <br />
::::EDIT: Here is a big list of variables found only in my {{ic|/usr/share/applications}} directory: [[User:Andy Crowd/sandbox/Desktop users#List of variables | List of variables ]]<br />
:::: (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 14:22, 14 May 2016 (UTC)).<br />
<br />
::::: Ah, yes, that makes sense. I was reading too quick and did not follow through the link to [[Desktop entries]] via the [[Default applications#Maintaining settings for multiple desktop environments]] expansion template. <br />
::::: I agree now it makes sense to only have the .desktop variables in the table that relate to this article (MIME associations) and have undone my revert: [https://wiki.archlinux.org/index.php?title=Default_applications&diff=434996&oldid=434982] <br />
::::: There is [[Desktop entries#File example]] for the ones that affect how an application is put in the menu. Removing more (you mention NoDisplay, NotShowIn, OnlyShowIn, TargetEnvironment) makes sense too, but we should look first if something is useful to move to the other [[Desktop entries#File example]] list. <br />
::::: The two articles are very related and should crosslink each other in the intro, but that's another topic. <br />
::::: edit: I've added back [https://wiki.archlinux.org/index.php?title=Default_applications&diff=prev&oldid=435002], and [https://wiki.archlinux.org/index.php?title=Desktop_entries&type=revision&diff=435004&oldid=434032], [https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=435003&oldid=435002] to relate both articles. <br />
::::: Thanks for explaining! Ok to close this or other points related? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:06, 14 May 2016 (UTC)<br />
<br />
== Output examples by tools ==<br />
<br />
Almost for every output I use my lsdesktopf script or adding new functions to make need output, it feels like making of the useful advertisement. I am not sure if it is OK to write everywhere "See also:" "Use to show:" for my script that only shows everything to stdout or for other programs that manages mime-types in console and have some kind of output? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 21:27, 15 May 2016 (UTC)).<br />
<br />
: I see what you mean, your tool is very useful for complex searches. You can of course use a [[Template:Tip]] in a place where you think ''lfdesktopf'' is particularly handy for readers. Two further ideas: (1) You could change the second ''lsdesktopf'' example you provide in [[Desktop_entries#List_or_search_in_.2A.desktop_files]] for the tool to one that handling MIME-type information relevant here. (2) We still also have [[Xdg-open]], which is more about tools to configure. It has [[Xdg-open#Usage]] examples about searching MIME type, which can be crosslinked as examples too. <br />
: Apart from a tip, I would not use much more examples for tools in this article at the current time. First, it should be decided what happens to [[Xdg-open]]. After [[Talk:Xdg-open#Move_suggestion]] and [[Talk:Xdg-open#About_Merge]] are clear, we should have a place where some more useful tool command examples (incl. ''mimeo'' and ''lsdesktopf'') can be put. <br />
: Ok? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 16:43, 16 May 2016 (UTC)<br />
<br />
:: I am done with the 1st advice. But in [[Xdg-open#xdg-open replacements | xdg-open replacements]] can be moved to [[Default applications#Utilities to manage MIME types|Utilities to manage MIME types]], but I must rewrite section "Utilities to manage MIME types" in style as table in "xdg-open replacements" for some tools that is not there yet, I can't provide so detailed info about missing yet. Other parts I haven't decided where I can put, but it can be minimized very much. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:56, 16 May 2016 (UTC)).<br />
<br />
::: Alright, nice. I think it is simpler to convert all tools to [[Template:App]], as suggested in the style template, and drop the table. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:34, 17 May 2016 (UTC)<br />
<br />
:::: I think that it is better with table because it is comparison of tools and not just description with a link as in [[Template:App]]. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 04:39, 18 May 2016 (UTC)).<br />
<br />
::::: Fair enough, I've merged into the table. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:06, 18 May 2016 (UTC)<br />
<br />
:::::: After I will test all ''command line'' tools in table I will probably rewrite it in a table if I will find some bigger difference or similarity. Many programs are prioritizing *.xml instead of mimeapps*. It will be a big list of short examples for a while until I will short it down. And one more thing---- It is good to have a separator between examples but not section names, is it good if I will use bold text of tool names instead? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 16:17, 18 May 2016 (UTC)).<br />
<br />
::::::: We can't have examples for too many different tools, so I think one example section and bold as separator is a good idea. By the way: Why do you use ''xdg-mine'' for the first examples in [[Default_applications#Examples_of_usage]]? If they are needed here, they should be crosslinked to [[Xdg-open#Configuration]]. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 19:05, 18 May 2016 (UTC)<br />
<br />
:::::: I have edited table but it is so Ugly code inside, may be make new or it other was to make it look good. It might be also an alternative to have One More Table with Columns: Type(Launcher,Both,Setting,Incl. Tool),GUI(Yes,No),Prioritize Order(*.xml,file,other) (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:13, 18 May 2016 (UTC)).<br />
<br />
::::::: We can remake the table in simpler format. I can help, but not today. I also have to catch-up with all the great work you have already put into the article; I'll do that one of the next days. <br />
::::::: The new columns "Type" and "GUI" read good. One question from me: What do you mean by '''prioritize order'''(*.xml,file,other)? To my understanding, the *.xml files are part of the packages and should not be user modified (see [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923467984]). The new pacman hook does the automatic work for [https://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec/#index2h3 update-mime-database] according to what the applications provide in the .xml specs. It is ok to mention the *.xml files, because they are part of the logic. However, to my understanding the configuration of the correct {{ic|mimeapps.list}} should be the focus in his article, because this is where the user choice (app per mime type) is configured. <br />
::::::: So, what do you mean by "prioritize" ? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 19:03, 18 May 2016 (UTC)<br />
<br />
:::::::: I have created an example table at the bottom that shows "prioritize order", *.xml = that it detects MIME-type by extension, Magic = if no description about extension is found in *.xml (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:59, 18 May 2016 (UTC)).<br />
<br />
::::::::: I see and like how you are progressing with new ideas about the section and now also understand what you mean with "prioritize" (great you also adopted the archived AUR packages). The example you provide in [https://wiki.archlinux.org/index.php?title=Default_applications&curid=11760&diff=435514&oldid=435466] sounds like a ''xdg-mime'' bug to me actually - or was it a text that you renamed to foo-file.jpg to show the effect? Other than that I don't have more input at current. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 17:57, 19 May 2016 (UTC)<br />
<br />
Just try examples with and without any extension or with wrong extension, if you have DE installed and necessary tools. I just added extension to "foo-file". (The discussion is too tight now so I start with a new begin.) (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:07, 19 May 2016 (UTC)).<br />
<br />
: I think that I am done with all related to article name sections. I will not use many outputs per tool, only basic and little configuration.<br />
# '''Default applications'''<br />
## Description of what MIME-type is and ways Linux uses them.<br />
## Set default applications<br />
### Configure *.mimeapps.list files<br />
### Configure *.xml files<br />
### Use tools for configuration<br />
## Get information about MIME-types<br />
### in MIME-type database<br />
### using tools<br />
## Start default applications by<br />
### using utilities<br />
### configuring other applications to use tools for starting default applications<br />
## Troubleshooting of *.desktop files if associated program doesn't start correct<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 13:52, 20 May 2016 (UTC)).<br />
<br />
:I went through the article until the [[Default_applications#Utilities_to_manage_MIME_types]] section, please have a look, thanks. I like your above TOC layout a lot. I have started to implement it in a similar manner ([https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=435829&oldid=435824]) until the section I got today. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:00, 20 May 2016 (UTC)<br />
<br />
:: You did great, but I didn't described completely when I used word "misconfiguration" in section "Variables in .desktop files that affect application launch", I meant that not all variables in "Exec" can be combined in the same *.desktop file or in the same "Exec"(in some *.desktop files I found more then one "Exec" that belongs to each new section that related to description in variable Actions, for each Action own Exec in the new section within same *.desktop file), e.g. to open file and to open device can't be in the same *.desktop file with "Exec" but standard changes so I didn't wrote about all details only that "misconfigured" Exec can affect start or be shown in the menu. For the section about tools I don't know what is good and how much I should write about each tool or in subsections, e.g. xdg-open may be need more details but article is not about xdg-utils but too much examples not good. May be it can be different between subsections (in one more examples and in another less or no examples, e.g. as it look like now). May be also add a section about file managers as in suggestion: [[Talk:Default_applications#Futher_improvement]]? Add information about GUI launchers that each DE is using? Add some "ERROR" template about that sections about tools is not complete and must be extended or something in that style (it is very messy in that part) because I think that it can take long time until it will be completed? I don't know how much time I will have to put on wiki but I will do my best to "finish"(until I have some ideas and time left) this article and also may be add some more info to [[Desktop entries]]. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 23:57, 20 May 2016 (UTC)).<br />
<br />
::: Glad you are generally ok with my changes yesterday, if you see something wrong later - just change or tell me. Don't worry about time. The article is in a much better state already thanks to your expertise and careful work! If you want, you can also leave it to me to go over the [[Default applications#Utilities to manage MIME types]] section first, and see afterwards what of your ideas you want to implement as soon as you have time/want to work on it further. <br />
::: For the "Variables in .desktop files that affect application launch" section: yes I think I understand. Perhaps one of us has an idea later how to improve it without mentioning too many exceptional cases, it is a complicated topic. I think it should stay in Troubleshooting though, like you put it above in the TOC. <br />
::: For command output: I don't think we should mention much more about GUI tools/filemanagers of particular DE/WM. That should be left to the DE/WM (e.g. [[GNOME#Default applications]], [[Xfce#Menu]]), so that this article can stay more general. For more see my reply below to Kynikos. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:15, 21 May 2016 (UTC)<br />
<br />
I haven't followed this discussion closely, but after merging [[xdg-open]] I do think that at least some examples from the [https://wiki.archlinux.org/index.php?title=Xdg-open&oldid=435329#Configuration xdg-open#Configuration] section should be restored here, because for example the tables in [[Default_applications#Detect_MIME-type]] are quite informative, but at a glance it doesn't even look like they're talking about actual commands :) — [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 09:37, 21 May 2016 (UTC)<br />
<br />
:Yes, we all agree on this I think (see Andy's above reply). I think for now it is pretty simple to add back more command output, because Andy had actually [https://wiki.archlinux.org/index.php?title=Default_applications&diff=435514&oldid=435466 written] a meaningful command example before. In my view it should suffice for now to add back the commands leading to the [[Default_applications#Detect_MIME-type]] tables for now and then see how it works out. <br />
:Btw, can you name a couple of specifics for the top-level style template you put? I'd like to fix them on the next go through. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:15, 21 May 2016 (UTC)<br />
<br />
:: Is it OK to have a section with additional practical examples for other tools too as I started in [[Default applications#Extended practical examples]], without any cryptic descriptions (instead ''Type/Extension'' use ''video/flv'')? I don't see a better way of adding more examples without destroying logical layout of other sections. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:39, 21 May 2016 (UTC)).<br />
<br />
:::Thanks Andy, your solution works for me.<br />
:::@Indigo, I've [https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=436018&oldid=435979 fixed] several formatting/punctuation non-compliances, however I've left the values in the tables almost untouched for the moment; in theory options and variables should all be shown with [[Template:ic]], and I'm not sure under which [[Help:Style/Formatting and punctuation]] category we could consider MIME types to belong.<br />
:::– [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 05:46, 22 May 2016 (UTC)<br />
<br />
:::: Thanks for fixing, Kynikos. It was actually my confusion when I used [[Template:ic]] for ''.desktop'' extension et al. When I did so, I recalled Lahwaacz had reminded me to something similar a good year ago, but got misled trying to find it again in the style guide ^^ <br />
:::: For the MIME types: I don't think we can fix these 100%. I'd say they can be either [[Help:Style/Formatting_and_punctuation#Configuration_parameters.2C_variables.2C_options.2C_properties...|properties]] or (e.g. for custom x-* ones) [[Help:Style/Formatting and punctuation#File content]]. So, monospace in my view when mentiioned in text, but I'd like to keep them normal text in the tables. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 11:43, 23 May 2016 (UTC)<br />
<br />
== <s>About tag: "Reason: Lacks clarity, content tacked on" </s>==<br />
<br />
What is more missing or must be rewritten to remove tag about: "Reason: Lacks clarity, content tacked on" that is in section "MIME types and desktop entries"<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 09:47, 16 May 2016 (UTC))<br />
<br />
: I have removed <nowiki>"{{Style|Lacks clarity, content tacked on}}"</nowiki> and closed this discussion. If I was wrong then explain please what is still missing. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:25, 18 May 2016 (UTC)).<br />
<br />
== <s>Remove section ''Default locations of the mimeapps.list_files'' ? </s> ==<br />
<br />
[[Default_applications#Default_locations_of_the_.2Amimeapps.list_files| this section]] is a RAW copy from [https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html#file freedesktop.org]. It is better to have a link to it instead. What do you think, is it good if I remove it? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:44, 17 May 2016 (UTC)).<br />
: 8 vs 10 fields, 2 more fields in table in this wiki. this should stay I missed the difference that 2 global system path is only here. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:18, 17 May 2016 (UTC)).<br />
<br />
<br />
== "Reason: The MIME database is located at" ==<br />
<br />
Read here: [https://specifications.freedesktop.org/desktop-entry-spec/0.9.5/ar01s07.html]. "XDG MIME-type database" is in the {{ic|/usr/share/mime}} but {{ic|mimeinfo.cache}} is located in other folders and updates automatically after update or installation of new programs: {{hc|find /usr/ -type f -name "mimeinfo.cache"|<br />
/usr/local/share/applications/mimeinfo.cache<br />
/usr/share/applications/mimeinfo.cache}} <br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:05, 23 May 2016 (UTC)).<br />
<br />
== "Reason: The following comparison table either conflicts" ==<br />
<br />
The table contains just a list of packages and files to give the user an overview of packages that contains preset MIME-type files or a human readable description of MIME-types.<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:19, 23 May 2016 (UTC)).</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=Talk:XDG_MIME_Applications&diff=436176Talk:XDG MIME Applications2016-05-23T17:05:48Z<p>Andy Crowd: The MIME database is located at /usr/share/mime, not /usr/share/applications. "The factual accuracy of this article or section is disputed."</p>
<hr />
<div>== Futher improvement ==<br />
<br />
Would be great to see such detailed explanation for KDE too. --[[User:AlexanderR|AlexanderR]] 23:57, 22 January 2012 (EST)<br />
<br />
It might be worth to mention that Enlightenment's file browser (in version e19) still uses the depreciated defaults.list file. --[[User:Drtebi|Drtebi]] ([[User talk:Drtebi|talk]]) 09:01, 25 December 2014 (UTC)<br />
<br />
: This can be placed in section "File managers" as a subsection for "Application launchers" (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 14:16, 20 May 2016 (UTC)).<br />
<br />
== <s>Clean up and Merging</s> ==<br />
<br />
This article is very difficult to read and understand. Also it provides redundant information which is better described within other wiki pages. <br />
<br />
* All *.desktop file related sections can be deleted and/or merged to the [[https://wiki.archlinux.org/index.php/Desktop_entries Desktop Entries]] article<br />
* All xdg-open related sections can be deleted and/or moved to the [[https://wiki.archlinux.org/index.php/Xdg-open xdg-open]] article<br />
<br />
After cleaning up and linking to those 'renewed' sections, this article should be rewritten in a way, that the reader understands the basics: <br />
<br />
* Which ways of defining default applications are available<br />
* Which ways are recommended for DEs, WMs or TTY environments<br />
* In which way does the system solve <br />
<br />
Following this, new sections describe different system environment setups. Hands-On examples or links end each environment section.<br />
<br />
{{unsigned|17:42, 21 March 2015|T.ask}}<br />
<br />
:Related discussion: [[Talk:xdg-open#About Merge]]. I think it would be simpler to recreate the article from scratch than try to fix it. -- [[User:Alad|Alad]] ([[User talk:Alad|talk]]) 18:05, 21 March 2015 (UTC)<br />
<br />
== <s>Maintaining settings for multiple desktop environments</s> ==<br />
<br />
Remove "This article or section needs expansion" in section "Maintaining settings for multiple desktop environments"?<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 10:27, 14 May 2016 (UTC)).<br />
:: I have renamed section and removed "tag" (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 09:43, 16 May 2016 (UTC)).<br />
<br />
== <s>about "Undo revision 434926"</s> ==<br />
<br />
# I have removed variables Categories and Keywords because they are not global as "NotShowIn" or "OnlyShowIn " or fixed as "Actions" and not affecting start up type as "Terminal", "DBusActivatable" or "MimeType".<br />
# The article is not directly related to *.desktop files but only on how MIME-types and *.desktop are related and affecting start up of programs in *.desktop. I could get a really big list of variables with {{ic|lsdesktopf --sud}} but this article is only about basics.<br />
* May be also add description about variables that begins with {{ic|X-}} are not general and supporting only by related desktop environments?<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 10:53, 14 May 2016 (UTC)).<br />
<br />
:I don't follow that. If the article is just about MIME type associations, why does the sentence above the table read "Common entries in *.desktop files that affects how application acts and '''shown in menu'''." and why do you add the link to the [https://specifications.freedesktop.org/menu-spec/latest/ menu specification] below it with [https://wiki.archlinux.org/index.php?title=Default_applications&diff=prev&oldid=434919]? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 11:32, 14 May 2016 (UTC)<br />
<br />
:: "Shown in menu" - I should explain more "shown in menu for default actions" in file manager, or removed it after I removed Keywords and Categories. This (freedesktop.org "[https://specifications.freedesktop.org/menu-spec/latest/ menu specification]".) I should also removed because it is not related to MIME-types.<br />
:: Or may be also remove variables: NoDisplay , NotShowIn , OnlyShowIn , TargetEnvironment? And leave only: Actions ,DBusActivatable ,MimeType ,StartupWMClass ,Terminal ,Type ?<br />
:: (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 12:05, 14 May 2016 (UTC)).<br />
<br />
:::Ok, I now understand why you removed "Categories" and "Keywords" and also which way you are working, but I do not agree yet: <br />
:::Whole desktop environments (e.g. [[MATE]]) were created because a lot of users prefer a traditional desktop with a menu tree for applications. A .desktop "Category" will sort an application into the correct position in the menu. That's a completely different way to work with the desktop than your way of using your desktop via right-click filemanager or MIME type assocations. <br />
:::(I appreciate your work for this article, but please stop editing it until is it clarified what content it is meant to contain. You editing out content I quote above is counter-productive. [https://wiki.archlinux.org/index.php?title=Default_applications&diff=next&oldid=434980]). <br />
:::In my view the article should be general, e.g. enable MATE users as well. What do you think (e.g. which article should MATE users get their info from)? <br />
:::--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:30, 14 May 2016 (UTC)<br />
<br />
:::: If the User questions is about why application isn't shown in a "Menu" then it should be in [[Desktop entries]] section but if the question is about MIME-type associations, correct start up of programs in *.desktop and variable: "Actions" related then it should be section about MIME-types. And may be give more description about variable '''Type'''. Here is output of unique '''Type''' that I found with my script:<br />
{{bc|1=Type=Application<br />
Type=MBTheme<br />
Type=MimeType<br />
Type=Service<br />
Type=XSession}} <br />
::::EDIT: Here is a big list of variables found only in my {{ic|/usr/share/applications}} directory: [[User:Andy Crowd/sandbox/Desktop users#List of variables | List of variables ]]<br />
:::: (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 14:22, 14 May 2016 (UTC)).<br />
<br />
::::: Ah, yes, that makes sense. I was reading too quick and did not follow through the link to [[Desktop entries]] via the [[Default applications#Maintaining settings for multiple desktop environments]] expansion template. <br />
::::: I agree now it makes sense to only have the .desktop variables in the table that relate to this article (MIME associations) and have undone my revert: [https://wiki.archlinux.org/index.php?title=Default_applications&diff=434996&oldid=434982] <br />
::::: There is [[Desktop entries#File example]] for the ones that affect how an application is put in the menu. Removing more (you mention NoDisplay, NotShowIn, OnlyShowIn, TargetEnvironment) makes sense too, but we should look first if something is useful to move to the other [[Desktop entries#File example]] list. <br />
::::: The two articles are very related and should crosslink each other in the intro, but that's another topic. <br />
::::: edit: I've added back [https://wiki.archlinux.org/index.php?title=Default_applications&diff=prev&oldid=435002], and [https://wiki.archlinux.org/index.php?title=Desktop_entries&type=revision&diff=435004&oldid=434032], [https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=435003&oldid=435002] to relate both articles. <br />
::::: Thanks for explaining! Ok to close this or other points related? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:06, 14 May 2016 (UTC)<br />
<br />
== Output examples by tools ==<br />
<br />
Almost for every output I use my lsdesktopf script or adding new functions to make need output, it feels like making of the useful advertisement. I am not sure if it is OK to write everywhere "See also:" "Use to show:" for my script that only shows everything to stdout or for other programs that manages mime-types in console and have some kind of output? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 21:27, 15 May 2016 (UTC)).<br />
<br />
: I see what you mean, your tool is very useful for complex searches. You can of course use a [[Template:Tip]] in a place where you think ''lfdesktopf'' is particularly handy for readers. Two further ideas: (1) You could change the second ''lsdesktopf'' example you provide in [[Desktop_entries#List_or_search_in_.2A.desktop_files]] for the tool to one that handling MIME-type information relevant here. (2) We still also have [[Xdg-open]], which is more about tools to configure. It has [[Xdg-open#Usage]] examples about searching MIME type, which can be crosslinked as examples too. <br />
: Apart from a tip, I would not use much more examples for tools in this article at the current time. First, it should be decided what happens to [[Xdg-open]]. After [[Talk:Xdg-open#Move_suggestion]] and [[Talk:Xdg-open#About_Merge]] are clear, we should have a place where some more useful tool command examples (incl. ''mimeo'' and ''lsdesktopf'') can be put. <br />
: Ok? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 16:43, 16 May 2016 (UTC)<br />
<br />
:: I am done with the 1st advice. But in [[Xdg-open#xdg-open replacements | xdg-open replacements]] can be moved to [[Default applications#Utilities to manage MIME types|Utilities to manage MIME types]], but I must rewrite section "Utilities to manage MIME types" in style as table in "xdg-open replacements" for some tools that is not there yet, I can't provide so detailed info about missing yet. Other parts I haven't decided where I can put, but it can be minimized very much. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:56, 16 May 2016 (UTC)).<br />
<br />
::: Alright, nice. I think it is simpler to convert all tools to [[Template:App]], as suggested in the style template, and drop the table. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:34, 17 May 2016 (UTC)<br />
<br />
:::: I think that it is better with table because it is comparison of tools and not just description with a link as in [[Template:App]]. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 04:39, 18 May 2016 (UTC)).<br />
<br />
::::: Fair enough, I've merged into the table. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:06, 18 May 2016 (UTC)<br />
<br />
:::::: After I will test all ''command line'' tools in table I will probably rewrite it in a table if I will find some bigger difference or similarity. Many programs are prioritizing *.xml instead of mimeapps*. It will be a big list of short examples for a while until I will short it down. And one more thing---- It is good to have a separator between examples but not section names, is it good if I will use bold text of tool names instead? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 16:17, 18 May 2016 (UTC)).<br />
<br />
::::::: We can't have examples for too many different tools, so I think one example section and bold as separator is a good idea. By the way: Why do you use ''xdg-mine'' for the first examples in [[Default_applications#Examples_of_usage]]? If they are needed here, they should be crosslinked to [[Xdg-open#Configuration]]. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 19:05, 18 May 2016 (UTC)<br />
<br />
:::::: I have edited table but it is so Ugly code inside, may be make new or it other was to make it look good. It might be also an alternative to have One More Table with Columns: Type(Launcher,Both,Setting,Incl. Tool),GUI(Yes,No),Prioritize Order(*.xml,file,other) (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:13, 18 May 2016 (UTC)).<br />
<br />
::::::: We can remake the table in simpler format. I can help, but not today. I also have to catch-up with all the great work you have already put into the article; I'll do that one of the next days. <br />
::::::: The new columns "Type" and "GUI" read good. One question from me: What do you mean by '''prioritize order'''(*.xml,file,other)? To my understanding, the *.xml files are part of the packages and should not be user modified (see [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923467984]). The new pacman hook does the automatic work for [https://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec/#index2h3 update-mime-database] according to what the applications provide in the .xml specs. It is ok to mention the *.xml files, because they are part of the logic. However, to my understanding the configuration of the correct {{ic|mimeapps.list}} should be the focus in his article, because this is where the user choice (app per mime type) is configured. <br />
::::::: So, what do you mean by "prioritize" ? --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 19:03, 18 May 2016 (UTC)<br />
<br />
:::::::: I have created an example table at the bottom that shows "prioritize order", *.xml = that it detects MIME-type by extension, Magic = if no description about extension is found in *.xml (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:59, 18 May 2016 (UTC)).<br />
<br />
::::::::: I see and like how you are progressing with new ideas about the section and now also understand what you mean with "prioritize" (great you also adopted the archived AUR packages). The example you provide in [https://wiki.archlinux.org/index.php?title=Default_applications&curid=11760&diff=435514&oldid=435466] sounds like a ''xdg-mime'' bug to me actually - or was it a text that you renamed to foo-file.jpg to show the effect? Other than that I don't have more input at current. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 17:57, 19 May 2016 (UTC)<br />
<br />
Just try examples with and without any extension or with wrong extension, if you have DE installed and necessary tools. I just added extension to "foo-file". (The discussion is too tight now so I start with a new begin.) (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:07, 19 May 2016 (UTC)).<br />
<br />
: I think that I am done with all related to article name sections. I will not use many outputs per tool, only basic and little configuration.<br />
# '''Default applications'''<br />
## Description of what MIME-type is and ways Linux uses them.<br />
## Set default applications<br />
### Configure *.mimeapps.list files<br />
### Configure *.xml files<br />
### Use tools for configuration<br />
## Get information about MIME-types<br />
### in MIME-type database<br />
### using tools<br />
## Start default applications by<br />
### using utilities<br />
### configuring other applications to use tools for starting default applications<br />
## Troubleshooting of *.desktop files if associated program doesn't start correct<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 13:52, 20 May 2016 (UTC)).<br />
<br />
:I went through the article until the [[Default_applications#Utilities_to_manage_MIME_types]] section, please have a look, thanks. I like your above TOC layout a lot. I have started to implement it in a similar manner ([https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=435829&oldid=435824]) until the section I got today. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 18:00, 20 May 2016 (UTC)<br />
<br />
:: You did great, but I didn't described completely when I used word "misconfiguration" in section "Variables in .desktop files that affect application launch", I meant that not all variables in "Exec" can be combined in the same *.desktop file or in the same "Exec"(in some *.desktop files I found more then one "Exec" that belongs to each new section that related to description in variable Actions, for each Action own Exec in the new section within same *.desktop file), e.g. to open file and to open device can't be in the same *.desktop file with "Exec" but standard changes so I didn't wrote about all details only that "misconfigured" Exec can affect start or be shown in the menu. For the section about tools I don't know what is good and how much I should write about each tool or in subsections, e.g. xdg-open may be need more details but article is not about xdg-utils but too much examples not good. May be it can be different between subsections (in one more examples and in another less or no examples, e.g. as it look like now). May be also add a section about file managers as in suggestion: [[Talk:Default_applications#Futher_improvement]]? Add information about GUI launchers that each DE is using? Add some "ERROR" template about that sections about tools is not complete and must be extended or something in that style (it is very messy in that part) because I think that it can take long time until it will be completed? I don't know how much time I will have to put on wiki but I will do my best to "finish"(until I have some ideas and time left) this article and also may be add some more info to [[Desktop entries]]. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 23:57, 20 May 2016 (UTC)).<br />
<br />
::: Glad you are generally ok with my changes yesterday, if you see something wrong later - just change or tell me. Don't worry about time. The article is in a much better state already thanks to your expertise and careful work! If you want, you can also leave it to me to go over the [[Default applications#Utilities to manage MIME types]] section first, and see afterwards what of your ideas you want to implement as soon as you have time/want to work on it further. <br />
::: For the "Variables in .desktop files that affect application launch" section: yes I think I understand. Perhaps one of us has an idea later how to improve it without mentioning too many exceptional cases, it is a complicated topic. I think it should stay in Troubleshooting though, like you put it above in the TOC. <br />
::: For command output: I don't think we should mention much more about GUI tools/filemanagers of particular DE/WM. That should be left to the DE/WM (e.g. [[GNOME#Default applications]], [[Xfce#Menu]]), so that this article can stay more general. For more see my reply below to Kynikos. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:15, 21 May 2016 (UTC)<br />
<br />
I haven't followed this discussion closely, but after merging [[xdg-open]] I do think that at least some examples from the [https://wiki.archlinux.org/index.php?title=Xdg-open&oldid=435329#Configuration xdg-open#Configuration] section should be restored here, because for example the tables in [[Default_applications#Detect_MIME-type]] are quite informative, but at a glance it doesn't even look like they're talking about actual commands :) — [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 09:37, 21 May 2016 (UTC)<br />
<br />
:Yes, we all agree on this I think (see Andy's above reply). I think for now it is pretty simple to add back more command output, because Andy had actually [https://wiki.archlinux.org/index.php?title=Default_applications&diff=435514&oldid=435466 written] a meaningful command example before. In my view it should suffice for now to add back the commands leading to the [[Default_applications#Detect_MIME-type]] tables for now and then see how it works out. <br />
:Btw, can you name a couple of specifics for the top-level style template you put? I'd like to fix them on the next go through. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 12:15, 21 May 2016 (UTC)<br />
<br />
:: Is it OK to have a section with additional practical examples for other tools too as I started in [[Default applications#Extended practical examples]], without any cryptic descriptions (instead ''Type/Extension'' use ''video/flv'')? I don't see a better way of adding more examples without destroying logical layout of other sections. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:39, 21 May 2016 (UTC)).<br />
<br />
:::Thanks Andy, your solution works for me.<br />
:::@Indigo, I've [https://wiki.archlinux.org/index.php?title=Default_applications&type=revision&diff=436018&oldid=435979 fixed] several formatting/punctuation non-compliances, however I've left the values in the tables almost untouched for the moment; in theory options and variables should all be shown with [[Template:ic]], and I'm not sure under which [[Help:Style/Formatting and punctuation]] category we could consider MIME types to belong.<br />
:::– [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 05:46, 22 May 2016 (UTC)<br />
<br />
:::: Thanks for fixing, Kynikos. It was actually my confusion when I used [[Template:ic]] for ''.desktop'' extension et al. When I did so, I recalled Lahwaacz had reminded me to something similar a good year ago, but got misled trying to find it again in the style guide ^^ <br />
:::: For the MIME types: I don't think we can fix these 100%. I'd say they can be either [[Help:Style/Formatting_and_punctuation#Configuration_parameters.2C_variables.2C_options.2C_properties...|properties]] or (e.g. for custom x-* ones) [[Help:Style/Formatting and punctuation#File content]]. So, monospace in my view when mentiioned in text, but I'd like to keep them normal text in the tables. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 11:43, 23 May 2016 (UTC)<br />
<br />
== <s>About tag: "Reason: Lacks clarity, content tacked on" </s>==<br />
<br />
What is more missing or must be rewritten to remove tag about: "Reason: Lacks clarity, content tacked on" that is in section "MIME types and desktop entries"<br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 09:47, 16 May 2016 (UTC))<br />
<br />
: I have removed <nowiki>"{{Style|Lacks clarity, content tacked on}}"</nowiki> and closed this discussion. If I was wrong then explain please what is still missing. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:25, 18 May 2016 (UTC)).<br />
<br />
== <s>Remove section ''Default locations of the mimeapps.list_files'' ? </s> ==<br />
<br />
[[Default_applications#Default_locations_of_the_.2Amimeapps.list_files| this section]] is a RAW copy from [https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html#file freedesktop.org]. It is better to have a link to it instead. What do you think, is it good if I remove it? (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 18:44, 17 May 2016 (UTC)).<br />
: 8 vs 10 fields, 2 more fields in table in this wiki. this should stay I missed the difference that 2 global system path is only here. (Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 19:18, 17 May 2016 (UTC)).<br />
<br />
<br />
== "Reason: The MIME database is located at" ==<br />
<br />
Read here: [https://specifications.freedesktop.org/desktop-entry-spec/0.9.5/ar01s07.html]. "XDG MIME-type database" is in the {{ic|/usr/share/mime}} but {{ic|mimeinfo.cache}} is located in other folders and updates automatically after update or installation of new programs: {{hc|find /usr/ -type f -name "mimeinfo.cache"|<br />
/usr/local/share/applications/mimeinfo.cache<br />
/usr/share/applications/mimeinfo.cache}} <br />
(Andy Crowd - [[wikipedia:蔡依林|蔡依林]] 17:05, 23 May 2016 (UTC)).</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=XDG_MIME_Applications&diff=436133XDG MIME Applications2016-05-23T07:52:26Z<p>Andy Crowd: /* Description of the mimeapps.list file */ added "shared-mime-info" package into the table with path to XDG database</p>
<hr />
<div>[[Category:Desktop environments]]<br />
[[ja:デフォルトアプリケーション]]<br />
[[ru:Changing filetype association via MIME]]<br />
[[zh-cn:Default applications]]<br />
{{Related articles start}}<br />
{{Related|Desktop entries}}<br />
{{Related|Desktop environment}}<br />
{{Related|Window manager}}<br />
{{Related articles end}}<br />
<br />
The type of a data file is usually, but not necessarily, denoted by the extension of the file name, for example ''.html'' or ''.jpeg''. A second way to determine the data type is via the so-called "magic bytes" at the start of the file. Both ways determine the MIME-type of the data. <br />
<br />
Each application installed to a [[desktop environment]] provides information about the MIME-types it can handle via the [[Desktop entries]], but frequently there is more than one application able to handle data of a certain MIME-type. This article describes how the ''default applications'' to handle a MIME-type can be configured. <br />
<br />
Note that while Arch Linux does not provide custom presets for default applications, the [[desktop environment]] you install may do so. Some desktop environments also provide a GUI or a file-manager which enables to interactively configure default applications for certain file extensions. If this suffices for your system usage, you may not need to configure anything further. <br />
<br />
The scope of this article is the freedesktop [https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html Association between MIME types and applications] specification. <br />
<br />
== MIME types and desktop entries ==<br />
<br />
MIME-types are specified by two slash ({{ic|/}}) parts: ''Type/Extension'', for example {{ic|video/x-ms-wmv}}. The second part of the MIME-type is expanding faster, for example with new applications or data encoding standards. <br />
<br />
The default applications to open a MIME-type are usually stored in [[#Default mimeapps.list paths|mimeapps.list]] files, but some of the desktop environments and file managers store MIME-type associations in own custom configuration files. If a MIME-type association is not found in the default configuration, the desktop environment will look for the first match of the MIME-type in ''.desktop'' files. <br />
<br />
Description of some MIME-type first part and examples of second parts:<br />
<br />
{| class="wikitable"<br />
! Type of MIME ( 1st part ) !! Description !! Examples of extension (2nd part)<br />
|-<br />
|application || Files with binary content such, e.g.: documents,archives,... || epub+zip, ereader, excel, gbr, gzip<br />
|-<br />
|audio || Audio files that that can be played by a music player or audio editor || flac, m4a, midi<br />
|-<br />
|chemical || Chemical information, molecular and other chemical data || x-cif, x-cml, x-daylight-smiles, x-gamess-input, x-gamess-output, x-gaussian-checkpoint, x-gaussian-cube, x-gaussian-log, x-mopac-out, x-pdb, x-qchem-output, x-xyz<br />
|-<br />
|image || Image files that can be opened by image editor or image viewer || bmp, crw, g3fax, gif, jp2, jpeg, jpeg2000, jpg<br />
|-<br />
|inode || Can be opened by a file manager || blockdevice, chardevice, directory, fifo, mount-point, socket, symlink<br />
|-<br />
|message || Message protocols || delivery-status, disposition-notification, external-body, news, partial, rfc822, x-gnu-rmail<br />
|-<br />
|misc || Streaming meta data || ultravox<br />
|-<br />
|text || Text documents that can be viewed (e.g. with command ''less'') or opened with a text editor || html, javascript, mathml, mml, plain<br />
|-<br />
|video || Video files that can be played or edited with a video editor || flv, mp2t, mp4<br />
|-<br />
|x-content || Content on disks such as e.g. Audio,Video,Image or blank disk || audio-cdda, audio-player, blank-bd, blank-cd, blank-dvd, blank-hddvd, image-picturecd, video-dvd, video-svcd, video-vcd<br />
|-<br />
|x-scheme-handler || Internet protocol || ftp, geo, ghelp, help, http, https, hwplay, icy, icyx, info, irc, magnet, mailto, man, mms, mmsh, net, pnm, rtmp, rtp, rtsp, skype, uvox, vnc, xmpp<br />
|-<br />
|x-epoc || SISX package ||x-sisx-app<br />
|-<br />
|multipart || Multi-part mime messages ||alternative, appledouble, digest, encrypted, mixed, related, report, signed, x-mixed-replace<br />
|-<br />
|model || such as 3D model || x-kpovmodeler, vrml, x-modelica<br />
|}<br />
<br />
For the description of MIME-types you can search in XDG database:<br />
$ grep -e 'mime-type type=' -e '<comment>' /usr/share/mime/packages/freedesktop.org.xml<br />
<br />
{{Tip|To see all MIME extensions in the system's ''.desktop'' files that belongs to a MIME-type you can use {{AUR|lsdesktopf}}, for example {{ic|lsdesktopf --gm -gx video}}.}} <br />
<br />
If you ever require to create a custom association of a new file extension to a MIME-type, see the <br />
[http://standards.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html Association between MIME types and applications] standard.<br />
<br />
== Set default applications == <br />
<br />
=== Default mimeapps.list paths ===<br />
<br />
The {{ic|mimeapps.list}} file stores the configuration for the default application to open a MIME-type. <br />
There are different locations for it: <br />
* system-wide, <br />
* per-user, <br />
* custom locations some [[desktop environment]]s or [[window managers]] may use. <br />
<br />
The {{ic|''$desktop''}} denotes the name of the related DE or WM in the following list. The search order of paths is: <br />
<br />
{| class="wikitable"<br />
! Path !! Usage<br />
|-<br />
| {{ic|$HOME/.config/''$desktop''-mimeapps.list}} || user overrides, desktop-specific<br />
|-<br />
| {{ic|$HOME/.config/mimeapps.list}} || user overrides<br />
|-<br />
| {{ic|/etc/xdg/''$desktop''-mimeapps.list}} || sysadmin and vendor overrides, desktop-specific<br />
|-<br />
| {{ic|/etc/xdg/mimeapps.list}} || sysadmin and vendor overrides<br />
|-<br />
| {{ic|$HOME/.local/share/applications/''$desktop''-mimeapps.list}} || for compatibility but now deprecated, desktop-specific<br />
|-<br />
| {{ic|$HOME/.local/share/applications/mimeapps.list}} || for compatibility but now deprecated<br />
|-<br />
| {{ic|/usr/local/share/applications/''$desktop''-mimeapps.list}}<br>{{ic|/usr/share/applications/$desktop-mimeapps.list}} || distribution-provided defaults, desktop-specific<br />
|-<br />
| {{ic|/usr/local/share/applications/mimeapps.list}}<br>{{ic|/usr/share/applications/mimeapps.list}} || distribution-provided defaults<br />
|}<br />
<br />
=== Description of the mimeapps.list file ===<br />
<br />
The file contains two main sections for default and additional alternatives to open files of a MIME-type. The second and the third section ({{ic|[Removed Associations]}}) are optional.<br />
<br />
Example:<br />
<br />
[Default Applications]<br />
mimetype1=default1.desktop<br />
<br />
Defined additional associations of applications to MIME-types:<br />
[Added Associations]<br />
mimetype1=foo1.desktop;foo2.desktop;foo3.desktop;<br />
mimetype2=foo4.desktop;<br />
<br />
Removed associations of applications with MIME-types (blacklisting a MIME-type association of an application in its {{ic|.desktop}} file):<br />
[Removed Associations]<br />
mimetype1=foo5.desktop<br />
<br />
Multiple ''.desktop'' files for a single MIME-type must be semicolon-separated. Not supported entries are ignored in {{ic|mimeapps.list}}. The DE/WM then searches for the first match to the needed MIME-type them in the default path for ''.desktop'' files. <br />
<br />
{{Tip|To get a quick overview of how many and which ''.desktop'' files can be associated with a certain MIME-type, you can use the {{AUR|lsdesktopf}} utility, e.g. {{ic|lsdesktopf --gen-mimeapps}}.}}<br />
<br />
{{Note|Arch Linux itself does not provide system-wide presets for associations, but other distributions and specific desktop environments may do so via packaged {{ic|mimeapps.list}} files, or the older and deprecated {{ic|defaults.list}} files. Hence, your choice of desktop environment, or none, will also affect how your default applications are associated.}}<br />
<br />
There are available additional preset MIME-type descriptions for a various desktop environments.<br />
<br />
{| class="wikitable"<br />
! Package name !! Description !! Files<br />
|-<br />
| {{AUR|gnome-defaults-list}} || Ubuntu defaults || {{ic|/etc/gnome/defaults.list}} <br> {{ic|/usr/share/applications/defaults.list}}<br />
|-<br />
| {{Pkg|mime-types}} || Additional list of MIME-types || {{ic|/etc/mime.types}}<br />
|-<br />
| {{Pkg|shared-mime-info}}|| XDG MIME-type database is a part of the package||| {{ic|/usr/share/mime/packages/freedesktop.org.xml}}<br />
|}<br />
<br />
=== Shared MIME-info database ===<br />
<br />
In background to the {{ic|mimeapps.list}} files, the system holds a database of MIME-type information registered via the installed applications' ''.desktop'' files. The [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176 Shared MIME-info Database]. <br />
When an application is installed, updated or removed, a [[pacman]] hook automatically updates the database, located in the {{ic|mimeinfo.cache}} in the {{ic|/usr/local/share/applications}} and {{ic|/usr/share/applications}} directories. These files keep track of which MIME-types are associated with which ''.desktop'' files overall. <br />
<br />
{{Warning|The database files are not meant to be edited directly.}}<br />
<br />
Application specific configuration is stored in ''.xml'' files and further files of the [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176 shared MIME-info database], stored in ''.keys'' and ''.mime'' files that are located in {{ic|/usr/share/mime-info/}}.<br />
<br />
Global directories for the ''.xml'' files are:<br />
<br />
/usr/share/mimelnk/application/<br />
/usr/share/mime/packages/ <br />
<br />
{{Warning|Above should not be modified, for user-specific configuration see below.}}<br />
<br />
Any user-specific ''.xml'' configuration may be stored in:<br />
~/.local/share/mime/packages/<br />
<br />
==== Example: .xml and related .desktop configuration ====<br />
<br />
Create and edit {{ic|~/.local/share/mime/packages/application-x-foobar.xml}}:<br />
<br />
{{bc|1=<br />
<?xml version="1.0" encoding="UTF-8"?><br />
<nowiki><mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"></nowiki><br />
'''<mime-type type="application/x-foobar">'''<br />
<comment>foo file</comment><br />
<icon name="application-x-foobar"/><br />
<glob-deleteall/><br />
'''<glob pattern="*.foo"/>'''<br />
</mime-type><br />
</mime-info><br />
}}<br />
<br />
Create a related {{ic|~/.local/share/applications/foobar.desktop}} file:<br />
<br />
{{bc|1=<br />
[Desktop Entry]<br />
Name=Foobar<br />
Exec=/usr/bin/foobar<br />
'''MimeType=application/x-foobar'''<br />
Icon=foobar<br />
Terminal=false<br />
Type=Application<br />
Categories=AudioVideo;Player;Video;<br />
Comment=<br />
}}<br />
<br />
The {{ic|Categories}} variable contains information about the DE/WM ''menu'' where the application is placed.<br />
<br />
Now update the application and mime database with:<br />
<br />
$ update-desktop-database ~/.local/share/applications<br />
$ update-mime-database ~/.local/share/mime<br />
<br />
Programs that use MIME-types, such as file managers, should now open {{ic|*.foo}} files with foobar (you may need to restart your file manager to see the change.)<br />
<br />
See also [[Environment variables#Examples]] about global variables that can be used in start-up scripts to set default applications for specific actions.<br />
<br />
== Utilities to manage MIME types ==<br />
<br />
Many of the file managers has options to set up and configure associations of mime types with programs. <br />
<br />
It can be done by using:<br />
<br />
* Preferences for selected file<br />
* File manager configuration menu<br />
* External program for a specific file manager<br />
<br />
Other utilities to manage MIME-types are: <br />
<br />
{| class="wikitable"<br />
! Name/Package !! Method !! Based on !! xdg-utils replacement !! Configuration file<br />
|-<br />
| {{Pkg|mime-editor}} || MIME-type || Utility for [http://rox.sourceforge.net/desktop/home.html ROX] applications || ||<br />
|-<br />
| {{AUR|ayr}} || MIME-type <br> name <br> regex || {{Pkg|file}} <br> {{Pkg|perl-file-mimeinfo}}, etc|| || {{ic|mimeapps.list}} <br> {{ic|defaults.list}}<br />
|-<br />
| {{AUR|busking-git}} || regex || {{Pkg|perl-file-mimeinfo}} || YES || custom<br />
|-<br />
| {{AUR|linopen}} || || {{Pkg|file}} || || custom<br />
|-<br />
| {{AUR|mimeo}} || MIME-type <br> regex || {{Pkg|file}} || {{AUR|xdg-utils-mimeo}} ||{{ic|mimeapps.list}} <br> {{ic|defaults.list}} <br> custom is optional<br />
|-<br />
| {{AUR|mimi-git}} || || {{Pkg|file}} || YES || custom<br />
|-<br />
| {{ic|rifle}} <br> part of {{Pkg|ranger}} || MIME-type <br> name <br> regex || || || custom<br />
|-<br />
| {{AUR|sx-open}} || regex || {{Pkg|file}} <br> bash regex || YES || custom<br />
|-<br />
| {{AUR|whippet}} || MIME-type <br> name <br> regex || SQLite database <br> {{Pkg|file}} <br> {{Pkg|perl-file-mimeinfo}}, etc || || custom SQLite database <br> {{ic|mimeapps.list}}<br />
|-<br />
| {{Pkg|xdg-utils}} || || {{Pkg|file}} <br> {{Pkg|perl-file-mimeinfo}} || ||<br />
|}<br />
<br />
{{Note|Packages that replacing ''xdg-utils'' can be symbolically linked to ''xdg-open'' in the user's {{ic|$PATH}} above {{ic|/usr/bin}}, but some applications hard-code the absolute path {{ic|/usr/bin/xdg-open}}. In this case, install {{AUR|xdg-utils-no-open}} from the [[AUR]] and copy the replacement to {{ic|/usr/bin/xdg-open}}.}}<br />
<br />
=== Examples of usage ===<br />
<br />
Here is a short description about how to use command line tools to show MIME-type of a file or set preferred program as default to open MIME-type.<br />
<br />
==== Detect MIME-type ====<br />
<br />
Tools detecting MIME-type by reading meta-data from header of the file or detecting by magic number that is in two bytes identifier in the begin of the file. See [[Wikipedia:File format#File header|File header]].<br />
<br />
Many programs are using command ''file'' to detect correct MIME-type. For detection it uses compiled database that is stored in the {{ic|/usr/share/misc/magic/}} directory. It has many options to determinate correct MIME-type and for showing output.<br />
<br />
In Linux it is two standards to detect MIME-type that can affect which program will start and open the file, e.g. extension is associated with one program but content is associated with another MIME-type. The simplest way to see what is your system prioritizes is by renaming file extension and check again with tools that can use custom [[#Associate file extensions with applications MIME-type|*.xml]] configuration files.<br />
<br />
Here is examples of utility ''xdg-mime'' that first checking association of extension in [[#Associate file extensions with applications MIME-type|*.xml]] configuration files.<br />
{| class="wikitable"<br />
! Without extension !! With extension <br />
|-<br />
|xdg-mime query filetype ''foo-file'' || xdg-mime query filetype ''foo-file''.''jpg''<br />
|-<br />
! application/vnd.oasis.opendocument.text || image/jpeg<br />
|-<br />
|}<br />
<br />
Comparison functionality of the tools <br />
<br />
Here is shown options only for simple or multiple checks of a file, for more options read their own documentation.<br />
{| class="wikitable"<br />
! Name of the tool !! Option !! Detection order !! Functionality !! Type !! Interface<br />
|-<br />
|file || ''(has many)'' || Magic(Byte/Pattern) || Show only || binary || terminal<br />
|-<br />
|xdg-mime || query filetype || *.xml -> Magic || Show / Set || binary || terminal<br />
|-<br />
|mimetype || -i ''(*.xml)'' -M ''(Magic)'' || *.xml -> Magic || Show only || script || terminal<br />
|-<br />
|mimeo || -m || *.xml -> Magic || Show / Set / Launch || script || terminal<br />
|}<br />
<br />
==== Set use of MIME-type by default ====<br />
<br />
Comparison functionality of the tools <br />
<br />
Here is shown options only for single file associations, for more options read their own documentation.<br />
<br />
{| class="wikitable"<br />
! Name of the tool !! Option !! Functionality !! Type !! Interface<br />
|-<br />
|xdg-mime || default ''*.desktop'' Type1/Extension1 Type2/Extension2 || Show / Set || binary || terminal<br />
|-<br />
|mimeo || --prefer 'regex:^Type/(Extension'''1'''<nowiki> |</nowiki>Extension?'''2''')$' ''*.desktop'' || Show / Set / Launch || script || terminal<br />
|-<br />
|mimeopen || --ask-default ''(interactive)'' || Set / Launch || script || terminal<br />
|}<br />
<br />
=== Application launchers ===<br />
<br />
{{App|[[xdg-open]]|Starting applications from command line, has basic functionality.|https://www.freedesktop.org/wiki/Software/xdg-utils/|{{Pkg|xdg-utils}}}}<br />
<br />
''xdg-open'' uses {{Pkg|perl-file-mimeinfo}} as a fallback ("generic") method if no [[desktop environment]] is detected. It is a desktop-independent tool. Many applications invoke the {{ic|xdg-open}} command internally. Inside a [[desktop environment]] it passes the arguments to desktop supported environment's file-opener applications (e.g. ''gvfs-open'', ''kde-open'', or ''exo-open''). When no desktop environment is detected the ''xdg-open'' will use its own configuration files.<br />
<br />
{{App|mimeopen|Starting applications from command line. It can use custom database and prompt user to chose default application from a list of detected relevant and offers to chose own alternative.|https://metacpan.org/release/File-MimeInfo|{{Pkg|perl-file-mimeinfo}}}}<br />
<br />
Example of the prompt:<br />
<br />
{{hc| mimeopen -d /path/to/foo-file|<br />
Please choose a default application for files of type ''Type''/''Extension''<br />
1) notepad (wine-extension-txt)<br />
2) Leafpad (leafpad)<br />
3) OpenOffice.org Writer (writer)<br />
4) gVim (gvim)<br />
5) Other...<br />
}}<br />
Your answer becomes the default handler for that type of file. Mimeopen is installed as {{ic|/usr/bin/vendor_perl/mimeopen}}.<br />
<br />
If you run ''xdg-open'' without a desktop environment, you should also install {{Pkg|perl-file-mimeinfo}}, or {{AUR|xdg-utils-mimeo}} and {{AUR|mimeo}} from the [[AUR]] for a faster alternative.<br />
<br />
==== Miscellaneous ====<br />
<br />
The [http://linux.die.net/man/4/mailcap mailcap] file.<br />
<br />
{{Expansion|When using {{AUR|run-mailcap}}, ''xdg-open'' may refer to it.[http://cgit.freedesktop.org/xdg/xdg-utils/tree/scripts/xdg-open.in#n266] It should then clearly not be combined with the below file to prevent endless loops.}}<br />
<br />
The ''.mailcap'' file format is used by mail programs such as {{Pkg|mutt}} and {{Pkg|sylpheed}}. To have those programs use ''xdg-open'', edit {{ic|~/.mailcap}}:<br />
<br />
{{hc|~/.mailcap|<br />
*/*; xdg-open "%s"<br />
}}<br />
<br />
=== Extended practical examples ===<br />
<br />
==== xdg-open ====<br />
<br />
''xdg-mime'' modifies the local file {{ic|~/.config/mimeapps.list}} and {{ic|~/.local/share/applications/mimeapps.list}} (deprecated).<br />
<br />
To '''query''' the mime type used by an existing file, use <br />
$ xdg-mime query ''filetype'' ''file.ext''<br />
<br />
To change an associated desktop entry by setting [[Thunar]] as the default file browser:<br />
<br />
$ xdg-mime default Thunar.desktop inode/directory<br />
Note that you should not specify the complete path, but only the name of the ''.desktop'' file.<br />
<br />
This command can take multiple mime-types, allowing related files to be handled by the same program. The example below associates [[Emacs]] to all known source files:<br />
$ xdg-mime default emacs.desktop $(grep '^text/x-*' /usr/share/mime/types)<br />
<br />
===== Set the default browser =====<br />
<br />
To set the default application for {{ic|http(s)://}} internet protocols:<br />
<br />
$ xdg-mime default midori.desktop x-scheme-handler/http<br />
$ xdg-mime default midori.desktop x-scheme-handler/https<br />
<br />
As an alternative try:<br />
<br />
$ xdg-settings set default-web-browser netsurf.desktop<br />
<br />
To verify if the URLs opens correctly:<br />
<br />
$ xdg-open <nowiki>https://archlinux.org</nowiki><br />
<br />
To associate ''.html'' files with the {{Pkg|netsurf}} web-browser:<br />
<br />
$ xdg-mime default netsurf.desktop text/html<br />
<br />
== Troubleshooting == <br />
<br />
=== Variables in .desktop files that affect application launch ===<br />
<br />
Desktop environments and file managers supporting the specifications launch programs according to definition in the ''.desktop'' files. See [[Desktop entries#Application entry]]. <br />
<br />
Usually, configuration of the packaged ''.desktop'' files is not required, but it may not be bug-free. Even if an application containing necessary MIME-type description in the ''.desktop'' file {{ic|MimeType}} variable that is used for association, it can fail to start correctly, not start at all or start without opening a file. <br />
<br />
This may happen, for example, if the {{ic|Exec}} variable is missing internal options needed for how to open a file, or how the application is shown in the menu. The {{ic|Exec}} variable usually begins with {{ic|%}}; for its currently supported options, see [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables exec-variables].<br />
<br />
The following table lists the main variable entries of ''.desktop'' files that affect how an application starts, if it has a MIME-type associated with it. <br />
<br />
{| class="wikitable"<br />
! Variable names !! Example 1 content !! Example 2 content !! Description<br />
|-<br />
| DBusActivatable || DBusActivatable=true || DBusActivatable=false || Application interact with [https://www.freedesktop.org/wiki/Software/dbus/ D-Bus]. <br> See also configuration: [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#dbus D-Bus].<br />
|-<br />
| MimeType || MimeType=application/vnd.oasis.opendocument.text || MimeType=application/vnd.sun.xml.math || List of MIME types supported by application<br />
|-<br />
| StartupWMClass || StartupWMClass=google-chrome || StartupWMClass=xpad || Associate windows with the owning application<br />
|-<br />
| Terminal || Terminal=true || Terminal=false || Start in default terminal<br />
|}</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=XDG_MIME_Applications&diff=436106XDG MIME Applications2016-05-22T21:32:02Z<p>Andy Crowd: /* Set use of MIME-type by default */ added "mimeopen" into the table</p>
<hr />
<div>[[Category:Desktop environments]]<br />
[[ja:デフォルトアプリケーション]]<br />
[[ru:Changing filetype association via MIME]]<br />
[[zh-cn:Default applications]]<br />
{{Related articles start}}<br />
{{Related|Desktop entries}}<br />
{{Related|Desktop environment}}<br />
{{Related|Window manager}}<br />
{{Related articles end}}<br />
<br />
The type of a data file is usually, but not necessarily, denoted by the extension of the file name, for example ''.html'' or ''.jpeg''. A second way to determine the data type is via the so-called "magic bytes" at the start of the file. Both ways determine the MIME-type of the data. <br />
<br />
Each application installed to a [[desktop environment]] provides information about the MIME-types it can handle via the [[Desktop entries]], but frequently there is more than one application able to handle data of a certain MIME-type. This article describes how the ''default applications'' to handle a MIME-type can be configured. <br />
<br />
Note that while Arch Linux does not provide custom presets for default applications, the [[desktop environment]] you install may do so. Some desktop environments also provide a GUI or a file-manager which enables to interactively configure default applications for certain file extensions. If this suffices for your system usage, you may not need to configure anything further. <br />
<br />
The scope of this article is the freedesktop [https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html Association between MIME types and applications] specification. <br />
<br />
== MIME types and desktop entries ==<br />
<br />
MIME-types are specified by two slash ({{ic|/}}) parts: ''Type/Extension'', for example {{ic|video/x-ms-wmv}}. The second part of the MIME-type is expanding faster, for example with new applications or data encoding standards. <br />
<br />
The default applications to open a MIME-type are usually stored in [[#Default mimeapps.list paths|mimeapps.list]] files, but some of the desktop environments and file managers store MIME-type associations in own custom configuration files. If a MIME-type association is not found in the default configuration, the desktop environment will look for the first match of the MIME-type in ''.desktop'' files. <br />
<br />
Description of some MIME-type first part and examples of second parts:<br />
<br />
{| class="wikitable"<br />
! Type of MIME ( 1st part ) !! Description !! Examples of extension (2nd part)<br />
|-<br />
|application || Files with binary content such, e.g.: documents,archives,... || epub+zip, ereader, excel, gbr, gzip<br />
|-<br />
|audio || Audio files that that can be played by a music player or audio editor || flac, m4a, midi<br />
|-<br />
|chemical || Chemical information, molecular and other chemical data || x-cif, x-cml, x-daylight-smiles, x-gamess-input, x-gamess-output, x-gaussian-checkpoint, x-gaussian-cube, x-gaussian-log, x-mopac-out, x-pdb, x-qchem-output, x-xyz<br />
|-<br />
|image || Image files that can be opened by image editor or image viewer || bmp, crw, g3fax, gif, jp2, jpeg, jpeg2000, jpg<br />
|-<br />
|inode || Can be opened by a file manager || blockdevice, chardevice, directory, fifo, mount-point, socket, symlink<br />
|-<br />
|message || Message protocols || delivery-status, disposition-notification, external-body, news, partial, rfc822, x-gnu-rmail<br />
|-<br />
|misc || Streaming meta data || ultravox<br />
|-<br />
|text || Text documents that can be viewed (e.g. with command ''less'') or opened with a text editor || html, javascript, mathml, mml, plain<br />
|-<br />
|video || Video files that can be played or edited with a video editor || flv, mp2t, mp4<br />
|-<br />
|x-content || Content on disks such as e.g. Audio,Video,Image or blank disk || audio-cdda, audio-player, blank-bd, blank-cd, blank-dvd, blank-hddvd, image-picturecd, video-dvd, video-svcd, video-vcd<br />
|-<br />
|x-scheme-handler || Internet protocol || ftp, geo, ghelp, help, http, https, hwplay, icy, icyx, info, irc, magnet, mailto, man, mms, mmsh, net, pnm, rtmp, rtp, rtsp, skype, uvox, vnc, xmpp<br />
|-<br />
|x-epoc || SISX package ||x-sisx-app<br />
|-<br />
|multipart || Multi-part mime messages ||alternative, appledouble, digest, encrypted, mixed, related, report, signed, x-mixed-replace<br />
|-<br />
|model || such as 3D model || x-kpovmodeler, vrml, x-modelica<br />
|}<br />
<br />
For the description of MIME-types you can search in XDG database:<br />
$ grep -e 'mime-type type=' -e '<comment>' /usr/share/mime/packages/freedesktop.org.xml<br />
<br />
{{Tip|To see all MIME extensions in the system's ''.desktop'' files that belongs to a MIME-type you can use {{AUR|lsdesktopf}}, for example {{ic|lsdesktopf --gm -gx video}}.}} <br />
<br />
If you ever require to create a custom association of a new file extension to a MIME-type, see the <br />
[http://standards.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html Association between MIME types and applications] standard.<br />
<br />
== Set default applications == <br />
<br />
=== Default mimeapps.list paths ===<br />
<br />
The {{ic|mimeapps.list}} file stores the configuration for the default application to open a MIME-type. <br />
There are different locations for it: <br />
* system-wide, <br />
* per-user, <br />
* custom locations some [[desktop environment]]s or [[window managers]] may use. <br />
<br />
The {{ic|''$desktop''}} denotes the name of the related DE or WM in the following list. The search order of paths is: <br />
<br />
{| class="wikitable"<br />
! Path !! Usage<br />
|-<br />
| {{ic|$HOME/.config/''$desktop''-mimeapps.list}} || user overrides, desktop-specific<br />
|-<br />
| {{ic|$HOME/.config/mimeapps.list}} || user overrides<br />
|-<br />
| {{ic|/etc/xdg/''$desktop''-mimeapps.list}} || sysadmin and vendor overrides, desktop-specific<br />
|-<br />
| {{ic|/etc/xdg/mimeapps.list}} || sysadmin and vendor overrides<br />
|-<br />
| {{ic|$HOME/.local/share/applications/''$desktop''-mimeapps.list}} || for compatibility but now deprecated, desktop-specific<br />
|-<br />
| {{ic|$HOME/.local/share/applications/mimeapps.list}} || for compatibility but now deprecated<br />
|-<br />
| {{ic|/usr/local/share/applications/''$desktop''-mimeapps.list}}<br>{{ic|/usr/share/applications/$desktop-mimeapps.list}} || distribution-provided defaults, desktop-specific<br />
|-<br />
| {{ic|/usr/local/share/applications/mimeapps.list}}<br>{{ic|/usr/share/applications/mimeapps.list}} || distribution-provided defaults<br />
|}<br />
<br />
=== Description of the mimeapps.list file ===<br />
<br />
The file contains two main sections for default and additional alternatives to open files of a MIME-type. The second and the third section ({{ic|[Removed Associations]}}) are optional.<br />
<br />
Example:<br />
<br />
[Default Applications]<br />
mimetype1=default1.desktop<br />
<br />
Defined additional associations of applications to MIME-types:<br />
[Added Associations]<br />
mimetype1=foo1.desktop;foo2.desktop;foo3.desktop;<br />
mimetype2=foo4.desktop;<br />
<br />
Removed associations of applications with MIME-types (blacklisting a MIME-type association of an application in its {{ic|.desktop}} file):<br />
[Removed Associations]<br />
mimetype1=foo5.desktop<br />
<br />
Multiple ''.desktop'' files for a single MIME-type must be semicolon-separated. Not supported entries are ignored in {{ic|mimeapps.list}}. The DE/WM then searches for the first match to the needed MIME-type them in the default path for ''.desktop'' files. <br />
<br />
{{Tip|To get a quick overview of how many and which ''.desktop'' files can be associated with a certain MIME-type, you can use the {{AUR|lsdesktopf}} utility, e.g. {{ic|lsdesktopf --gen-mimeapps}}.}}<br />
<br />
{{Note|Arch Linux itself does not provide system-wide presets for associations, but other distributions and specific desktop environments may do so via packaged {{ic|mimeapps.list}} files, or the older and deprecated {{ic|defaults.list}} files. Hence, your choice of desktop environment, or none, will also affect how your default applications are associated.}}<br />
<br />
There are available additional preset MIME-type descriptions for a various desktop environments.<br />
<br />
{| class="wikitable"<br />
! Package name !! Description !! Files<br />
|-<br />
| {{AUR|gnome-defaults-list}} || Ubuntu defaults || {{ic|/etc/gnome/defaults.list}} <br> {{ic|/usr/share/applications/defaults.list}}<br />
|-<br />
| {{Pkg|mime-types}} || Additional list of MIME-types || {{ic|/etc/mime.types}}<br />
|}<br />
<br />
=== Shared MIME-info database ===<br />
<br />
In background to the {{ic|mimeapps.list}} files, the system holds a database of MIME-type information registered via the installed applications' ''.desktop'' files. The [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176 Shared MIME-info Database]. <br />
When an application is installed, updated or removed, a [[pacman]] hook automatically updates the database, located in the {{ic|mimeinfo.cache}} in the {{ic|/usr/local/share/applications}} and {{ic|/usr/share/applications}} directories. These files keep track of which MIME-types are associated with which ''.desktop'' files overall. <br />
<br />
{{Warning|The database files are not meant to be edited directly.}}<br />
<br />
Application specific configuration is stored in ''.xml'' files and further files of the [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176 shared MIME-info database], stored in ''.keys'' and ''.mime'' files that are located in {{ic|/usr/share/mime-info/}}.<br />
<br />
Global directories for the ''.xml'' files are:<br />
<br />
/usr/share/mimelnk/application/<br />
/usr/share/mime/packages/ <br />
<br />
{{Warning|Above should not be modified, for user-specific configuration see below.}}<br />
<br />
Any user-specific ''.xml'' configuration may be stored in:<br />
~/.local/share/mime/packages/<br />
<br />
==== Example: .xml and related .desktop configuration ====<br />
<br />
Create and edit {{ic|~/.local/share/mime/packages/application-x-foobar.xml}}:<br />
<br />
{{bc|1=<br />
<?xml version="1.0" encoding="UTF-8"?><br />
<nowiki><mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"></nowiki><br />
'''<mime-type type="application/x-foobar">'''<br />
<comment>foo file</comment><br />
<icon name="application-x-foobar"/><br />
<glob-deleteall/><br />
'''<glob pattern="*.foo"/>'''<br />
</mime-type><br />
</mime-info><br />
}}<br />
<br />
Create a related {{ic|~/.local/share/applications/foobar.desktop}} file:<br />
<br />
{{bc|1=<br />
[Desktop Entry]<br />
Name=Foobar<br />
Exec=/usr/bin/foobar<br />
'''MimeType=application/x-foobar'''<br />
Icon=foobar<br />
Terminal=false<br />
Type=Application<br />
Categories=AudioVideo;Player;Video;<br />
Comment=<br />
}}<br />
<br />
The {{ic|Categories}} variable contains information about the DE/WM ''menu'' where the application is placed.<br />
<br />
Now update the application and mime database with:<br />
<br />
$ update-desktop-database ~/.local/share/applications<br />
$ update-mime-database ~/.local/share/mime<br />
<br />
Programs that use MIME-types, such as file managers, should now open {{ic|*.foo}} files with foobar (you may need to restart your file manager to see the change.)<br />
<br />
See also [[Environment variables#Examples]] about global variables that can be used in start-up scripts to set default applications for specific actions.<br />
<br />
== Utilities to manage MIME types ==<br />
<br />
Many of the file managers has options to set up and configure associations of mime types with programs. <br />
<br />
It can be done by using:<br />
<br />
* Preferences for selected file<br />
* File manager configuration menu<br />
* External program for a specific file manager<br />
<br />
Other utilities to manage MIME-types are: <br />
<br />
{| class="wikitable"<br />
! Name/Package !! Method !! Based on !! xdg-utils replacement !! Configuration file<br />
|-<br />
| {{Pkg|mime-editor}} || MIME-type || Utility for [http://rox.sourceforge.net/desktop/home.html ROX] applications || ||<br />
|-<br />
| {{AUR|ayr}} || MIME-type <br> name <br> regex || {{Pkg|file}} <br> {{Pkg|perl-file-mimeinfo}}, etc|| || {{ic|mimeapps.list}} <br> {{ic|defaults.list}}<br />
|-<br />
| {{AUR|busking-git}} || regex || {{Pkg|perl-file-mimeinfo}} || YES || custom<br />
|-<br />
| {{AUR|linopen}} || || {{Pkg|file}} || || custom<br />
|-<br />
| {{AUR|mimeo}} || MIME-type <br> regex || {{Pkg|file}} || {{AUR|xdg-utils-mimeo}} ||{{ic|mimeapps.list}} <br> {{ic|defaults.list}} <br> custom is optional<br />
|-<br />
| {{AUR|mimi-git}} || || {{Pkg|file}} || YES || custom<br />
|-<br />
| {{ic|rifle}} <br> part of {{Pkg|ranger}} || MIME-type <br> name <br> regex || || || custom<br />
|-<br />
| {{AUR|sx-open}} || regex || {{Pkg|file}} <br> bash regex || YES || custom<br />
|-<br />
| {{AUR|whippet}} || MIME-type <br> name <br> regex || SQLite database <br> {{Pkg|file}} <br> {{Pkg|perl-file-mimeinfo}}, etc || || custom SQLite database <br> {{ic|mimeapps.list}}<br />
|-<br />
| {{Pkg|xdg-utils}} || || {{Pkg|file}} <br> {{Pkg|perl-file-mimeinfo}} || ||<br />
|}<br />
<br />
{{Note|Packages that replacing ''xdg-utils'' can be symbolically linked to ''xdg-open'' in the user's {{ic|$PATH}} above {{ic|/usr/bin}}, but some applications hard-code the absolute path {{ic|/usr/bin/xdg-open}}. In this case, install {{AUR|xdg-utils-no-open}} from the [[AUR]] and copy the replacement to {{ic|/usr/bin/xdg-open}}.}}<br />
<br />
=== Examples of usage ===<br />
<br />
Here is a short description about how to use command line tools to show MIME-type of a file or set preferred program as default to open MIME-type.<br />
<br />
==== Detect MIME-type ====<br />
<br />
Tools detecting MIME-type by reading meta-data from header of the file or detecting by magic number that is in two bytes identifier in the begin of the file. See [[Wikipedia:File format#File header|File header]].<br />
<br />
Many programs are using command ''file'' to detect correct MIME-type. For detection it uses compiled database that is stored in the {{ic|/usr/share/misc/magic/}} directory. It has many options to determinate correct MIME-type and for showing output.<br />
<br />
In Linux it is two standards to detect MIME-type that can affect which program will start and open the file, e.g. extension is associated with one program but content is associated with another MIME-type. The simplest way to see what is your system prioritizes is by renaming file extension and check again with tools that can use custom [[#Associate file extensions with applications MIME-type|*.xml]] configuration files.<br />
<br />
Here is examples of utility ''xdg-mime'' that first checking association of extension in [[#Associate file extensions with applications MIME-type|*.xml]] configuration files.<br />
{| class="wikitable"<br />
! Without extension !! With extension <br />
|-<br />
|xdg-mime query filetype ''foo-file'' || xdg-mime query filetype ''foo-file''.''jpg''<br />
|-<br />
! application/vnd.oasis.opendocument.text || image/jpeg<br />
|-<br />
|}<br />
<br />
Comparison functionality of the tools <br />
<br />
Here is shown options only for simple or multiple checks of a file, for more options read their own documentation.<br />
{| class="wikitable"<br />
! Name of the tool !! Option !! Detection order !! Functionality !! Type !! Interface<br />
|-<br />
|file || ''(has many)'' || Magic(Byte/Pattern) || Show only || binary || terminal<br />
|-<br />
|xdg-mime || query filetype || *.xml -> Magic || Show / Set || binary || terminal<br />
|-<br />
|mimetype || -i ''(*.xml)'' -M ''(Magic)'' || *.xml -> Magic || Show only || script || terminal<br />
|-<br />
|mimeo || -m || *.xml -> Magic || Show / Set / Launch || script || terminal<br />
|}<br />
<br />
==== Set use of MIME-type by default ====<br />
<br />
Comparison functionality of the tools <br />
<br />
Here is shown options only for single file associations, for more options read their own documentation.<br />
<br />
{| class="wikitable"<br />
! Name of the tool !! Option !! Functionality !! Type !! Interface<br />
|-<br />
|xdg-mime || default ''*.desktop'' Type1/Extension1 Type2/Extension2 || Show / Set || binary || terminal<br />
|-<br />
|mimeo || --prefer 'regex:^Type/(Extension'''1'''<nowiki> |</nowiki>Extension?'''2''')$' ''*.desktop'' || Show / Set / Launch || script || terminal<br />
|-<br />
|mimeopen || --ask-default ''(interactive)'' || Set / Launch || script || terminal<br />
|}<br />
<br />
=== Application launchers ===<br />
<br />
{{App|[[xdg-open]]|Starting applications from command line, has basic functionality.|https://www.freedesktop.org/wiki/Software/xdg-utils/|{{Pkg|xdg-utils}}}}<br />
<br />
''xdg-open'' uses {{Pkg|perl-file-mimeinfo}} as a fallback ("generic") method if no [[desktop environment]] is detected. It is a desktop-independent tool. Many applications invoke the {{ic|xdg-open}} command internally. Inside a [[desktop environment]] it passes the arguments to desktop supported environment's file-opener applications (e.g. ''gvfs-open'', ''kde-open'', or ''exo-open''). When no desktop environment is detected the ''xdg-open'' will use its own configuration files.<br />
<br />
{{App|mimeopen|Starting applications from command line. It can use custom database and prompt user to chose default application from a list of detected relevant and offers to chose own alternative.|https://metacpan.org/release/File-MimeInfo|{{Pkg|perl-file-mimeinfo}}}}<br />
<br />
Example of the prompt:<br />
<br />
{{hc| mimeopen -d /path/to/foo-file|<br />
Please choose a default application for files of type ''Type''/''Extension''<br />
1) notepad (wine-extension-txt)<br />
2) Leafpad (leafpad)<br />
3) OpenOffice.org Writer (writer)<br />
4) gVim (gvim)<br />
5) Other...<br />
}}<br />
Your answer becomes the default handler for that type of file. Mimeopen is installed as {{ic|/usr/bin/vendor_perl/mimeopen}}.<br />
<br />
If you run ''xdg-open'' without a desktop environment, you should also install {{Pkg|perl-file-mimeinfo}}, or {{AUR|xdg-utils-mimeo}} and {{AUR|mimeo}} from the [[AUR]] for a faster alternative.<br />
<br />
==== Miscellaneous ====<br />
<br />
The [http://linux.die.net/man/4/mailcap mailcap] file.<br />
<br />
{{Expansion|When using {{AUR|run-mailcap}}, ''xdg-open'' may refer to it.[http://cgit.freedesktop.org/xdg/xdg-utils/tree/scripts/xdg-open.in#n266] It should then clearly not be combined with the below file to prevent endless loops.}}<br />
<br />
The ''.mailcap'' file format is used by mail programs such as {{Pkg|mutt}} and {{Pkg|sylpheed}}. To have those programs use ''xdg-open'', edit {{ic|~/.mailcap}}:<br />
<br />
{{hc|~/.mailcap|<br />
*/*; xdg-open "%s"<br />
}}<br />
<br />
=== Extended practical examples ===<br />
<br />
==== xdg-open ====<br />
<br />
''xdg-mime'' modifies the local file {{ic|~/.config/mimeapps.list}} and {{ic|~/.local/share/applications/mimeapps.list}} (deprecated).<br />
<br />
To '''query''' the mime type used by an existing file, use <br />
$ xdg-mime query ''filetype'' ''file.ext''<br />
<br />
To change an associated desktop entry by setting [[Thunar]] as the default file browser:<br />
<br />
$ xdg-mime default Thunar.desktop inode/directory<br />
Note that you should not specify the complete path, but only the name of the ''.desktop'' file.<br />
<br />
This command can take multiple mime-types, allowing related files to be handled by the same program. The example below associates [[Emacs]] to all known source files:<br />
$ xdg-mime default emacs.desktop $(grep '^text/x-*' /usr/share/mime/types)<br />
<br />
===== Set the default browser =====<br />
<br />
To set the default application for {{ic|http(s)://}} internet protocols:<br />
<br />
$ xdg-mime default midori.desktop x-scheme-handler/http<br />
$ xdg-mime default midori.desktop x-scheme-handler/https<br />
<br />
As an alternative try:<br />
<br />
$ xdg-settings set default-web-browser netsurf.desktop<br />
<br />
To verify if the URLs opens correctly:<br />
<br />
$ xdg-open <nowiki>https://archlinux.org</nowiki><br />
<br />
To associate ''.html'' files with the {{Pkg|netsurf}} web-browser:<br />
<br />
$ xdg-mime default netsurf.desktop text/html<br />
<br />
== Troubleshooting == <br />
<br />
=== Variables in .desktop files that affect application launch ===<br />
<br />
Desktop environments and file managers supporting the specifications launch programs according to definition in the ''.desktop'' files. See [[Desktop entries#Application entry]]. <br />
<br />
Usually, configuration of the packaged ''.desktop'' files is not required, but it may not be bug-free. Even if an application containing necessary MIME-type description in the ''.desktop'' file {{ic|MimeType}} variable that is used for association, it can fail to start correctly, not start at all or start without opening a file. <br />
<br />
This may happen, for example, if the {{ic|Exec}} variable is missing internal options needed for how to open a file, or how the application is shown in the menu. The {{ic|Exec}} variable usually begins with {{ic|%}}; for its currently supported options, see [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables exec-variables].<br />
<br />
The following table lists the main variable entries of ''.desktop'' files that affect how an application starts, if it has a MIME-type associated with it. <br />
<br />
{| class="wikitable"<br />
! Variable names !! Example 1 content !! Example 2 content !! Description<br />
|-<br />
| DBusActivatable || DBusActivatable=true || DBusActivatable=false || Application interact with [https://www.freedesktop.org/wiki/Software/dbus/ D-Bus]. <br> See also configuration: [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#dbus D-Bus].<br />
|-<br />
| MimeType || MimeType=application/vnd.oasis.opendocument.text || MimeType=application/vnd.sun.xml.math || List of MIME types supported by application<br />
|-<br />
| StartupWMClass || StartupWMClass=google-chrome || StartupWMClass=xpad || Associate windows with the owning application<br />
|-<br />
| Terminal || Terminal=true || Terminal=false || Start in default terminal<br />
|}</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=XDG_MIME_Applications&diff=436105XDG MIME Applications2016-05-22T21:10:38Z<p>Andy Crowd: moved table about preset MIME-type configuration files to section "Description of the mimeapps.list file"</p>
<hr />
<div>[[Category:Desktop environments]]<br />
[[ja:デフォルトアプリケーション]]<br />
[[ru:Changing filetype association via MIME]]<br />
[[zh-cn:Default applications]]<br />
{{Related articles start}}<br />
{{Related|Desktop entries}}<br />
{{Related|Desktop environment}}<br />
{{Related|Window manager}}<br />
{{Related articles end}}<br />
<br />
The type of a data file is usually, but not necessarily, denoted by the extension of the file name, for example ''.html'' or ''.jpeg''. A second way to determine the data type is via the so-called "magic bytes" at the start of the file. Both ways determine the MIME-type of the data. <br />
<br />
Each application installed to a [[desktop environment]] provides information about the MIME-types it can handle via the [[Desktop entries]], but frequently there is more than one application able to handle data of a certain MIME-type. This article describes how the ''default applications'' to handle a MIME-type can be configured. <br />
<br />
Note that while Arch Linux does not provide custom presets for default applications, the [[desktop environment]] you install may do so. Some desktop environments also provide a GUI or a file-manager which enables to interactively configure default applications for certain file extensions. If this suffices for your system usage, you may not need to configure anything further. <br />
<br />
The scope of this article is the freedesktop [https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html Association between MIME types and applications] specification. <br />
<br />
== MIME types and desktop entries ==<br />
<br />
MIME-types are specified by two slash ({{ic|/}}) parts: ''Type/Extension'', for example {{ic|video/x-ms-wmv}}. The second part of the MIME-type is expanding faster, for example with new applications or data encoding standards. <br />
<br />
The default applications to open a MIME-type are usually stored in [[#Default mimeapps.list paths|mimeapps.list]] files, but some of the desktop environments and file managers store MIME-type associations in own custom configuration files. If a MIME-type association is not found in the default configuration, the desktop environment will look for the first match of the MIME-type in ''.desktop'' files. <br />
<br />
Description of some MIME-type first part and examples of second parts:<br />
<br />
{| class="wikitable"<br />
! Type of MIME ( 1st part ) !! Description !! Examples of extension (2nd part)<br />
|-<br />
|application || Files with binary content such, e.g.: documents,archives,... || epub+zip, ereader, excel, gbr, gzip<br />
|-<br />
|audio || Audio files that that can be played by a music player or audio editor || flac, m4a, midi<br />
|-<br />
|chemical || Chemical information, molecular and other chemical data || x-cif, x-cml, x-daylight-smiles, x-gamess-input, x-gamess-output, x-gaussian-checkpoint, x-gaussian-cube, x-gaussian-log, x-mopac-out, x-pdb, x-qchem-output, x-xyz<br />
|-<br />
|image || Image files that can be opened by image editor or image viewer || bmp, crw, g3fax, gif, jp2, jpeg, jpeg2000, jpg<br />
|-<br />
|inode || Can be opened by a file manager || blockdevice, chardevice, directory, fifo, mount-point, socket, symlink<br />
|-<br />
|message || Message protocols || delivery-status, disposition-notification, external-body, news, partial, rfc822, x-gnu-rmail<br />
|-<br />
|misc || Streaming meta data || ultravox<br />
|-<br />
|text || Text documents that can be viewed (e.g. with command ''less'') or opened with a text editor || html, javascript, mathml, mml, plain<br />
|-<br />
|video || Video files that can be played or edited with a video editor || flv, mp2t, mp4<br />
|-<br />
|x-content || Content on disks such as e.g. Audio,Video,Image or blank disk || audio-cdda, audio-player, blank-bd, blank-cd, blank-dvd, blank-hddvd, image-picturecd, video-dvd, video-svcd, video-vcd<br />
|-<br />
|x-scheme-handler || Internet protocol || ftp, geo, ghelp, help, http, https, hwplay, icy, icyx, info, irc, magnet, mailto, man, mms, mmsh, net, pnm, rtmp, rtp, rtsp, skype, uvox, vnc, xmpp<br />
|-<br />
|x-epoc || SISX package ||x-sisx-app<br />
|-<br />
|multipart || Multi-part mime messages ||alternative, appledouble, digest, encrypted, mixed, related, report, signed, x-mixed-replace<br />
|-<br />
|model || such as 3D model || x-kpovmodeler, vrml, x-modelica<br />
|}<br />
<br />
For the description of MIME-types you can search in XDG database:<br />
$ grep -e 'mime-type type=' -e '<comment>' /usr/share/mime/packages/freedesktop.org.xml<br />
<br />
{{Tip|To see all MIME extensions in the system's ''.desktop'' files that belongs to a MIME-type you can use {{AUR|lsdesktopf}}, for example {{ic|lsdesktopf --gm -gx video}}.}} <br />
<br />
If you ever require to create a custom association of a new file extension to a MIME-type, see the <br />
[http://standards.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html Association between MIME types and applications] standard.<br />
<br />
== Set default applications == <br />
<br />
=== Default mimeapps.list paths ===<br />
<br />
The {{ic|mimeapps.list}} file stores the configuration for the default application to open a MIME-type. <br />
There are different locations for it: <br />
* system-wide, <br />
* per-user, <br />
* custom locations some [[desktop environment]]s or [[window managers]] may use. <br />
<br />
The {{ic|''$desktop''}} denotes the name of the related DE or WM in the following list. The search order of paths is: <br />
<br />
{| class="wikitable"<br />
! Path !! Usage<br />
|-<br />
| {{ic|$HOME/.config/''$desktop''-mimeapps.list}} || user overrides, desktop-specific<br />
|-<br />
| {{ic|$HOME/.config/mimeapps.list}} || user overrides<br />
|-<br />
| {{ic|/etc/xdg/''$desktop''-mimeapps.list}} || sysadmin and vendor overrides, desktop-specific<br />
|-<br />
| {{ic|/etc/xdg/mimeapps.list}} || sysadmin and vendor overrides<br />
|-<br />
| {{ic|$HOME/.local/share/applications/''$desktop''-mimeapps.list}} || for compatibility but now deprecated, desktop-specific<br />
|-<br />
| {{ic|$HOME/.local/share/applications/mimeapps.list}} || for compatibility but now deprecated<br />
|-<br />
| {{ic|/usr/local/share/applications/''$desktop''-mimeapps.list}}<br>{{ic|/usr/share/applications/$desktop-mimeapps.list}} || distribution-provided defaults, desktop-specific<br />
|-<br />
| {{ic|/usr/local/share/applications/mimeapps.list}}<br>{{ic|/usr/share/applications/mimeapps.list}} || distribution-provided defaults<br />
|}<br />
<br />
=== Description of the mimeapps.list file ===<br />
<br />
The file contains two main sections for default and additional alternatives to open files of a MIME-type. The second and the third section ({{ic|[Removed Associations]}}) are optional.<br />
<br />
Example:<br />
<br />
[Default Applications]<br />
mimetype1=default1.desktop<br />
<br />
Defined additional associations of applications to MIME-types:<br />
[Added Associations]<br />
mimetype1=foo1.desktop;foo2.desktop;foo3.desktop;<br />
mimetype2=foo4.desktop;<br />
<br />
Removed associations of applications with MIME-types (blacklisting a MIME-type association of an application in its {{ic|.desktop}} file):<br />
[Removed Associations]<br />
mimetype1=foo5.desktop<br />
<br />
Multiple ''.desktop'' files for a single MIME-type must be semicolon-separated. Not supported entries are ignored in {{ic|mimeapps.list}}. The DE/WM then searches for the first match to the needed MIME-type them in the default path for ''.desktop'' files. <br />
<br />
{{Tip|To get a quick overview of how many and which ''.desktop'' files can be associated with a certain MIME-type, you can use the {{AUR|lsdesktopf}} utility, e.g. {{ic|lsdesktopf --gen-mimeapps}}.}}<br />
<br />
{{Note|Arch Linux itself does not provide system-wide presets for associations, but other distributions and specific desktop environments may do so via packaged {{ic|mimeapps.list}} files, or the older and deprecated {{ic|defaults.list}} files. Hence, your choice of desktop environment, or none, will also affect how your default applications are associated.}}<br />
<br />
There are available additional preset MIME-type descriptions for a various desktop environments.<br />
<br />
{| class="wikitable"<br />
! Package name !! Description !! Files<br />
|-<br />
| {{AUR|gnome-defaults-list}} || Ubuntu defaults || {{ic|/etc/gnome/defaults.list}} <br> {{ic|/usr/share/applications/defaults.list}}<br />
|-<br />
| {{Pkg|mime-types}} || Additional list of MIME-types || {{ic|/etc/mime.types}}<br />
|}<br />
<br />
=== Shared MIME-info database ===<br />
<br />
In background to the {{ic|mimeapps.list}} files, the system holds a database of MIME-type information registered via the installed applications' ''.desktop'' files. The [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176 Shared MIME-info Database]. <br />
When an application is installed, updated or removed, a [[pacman]] hook automatically updates the database, located in the {{ic|mimeinfo.cache}} in the {{ic|/usr/local/share/applications}} and {{ic|/usr/share/applications}} directories. These files keep track of which MIME-types are associated with which ''.desktop'' files overall. <br />
<br />
{{Warning|The database files are not meant to be edited directly.}}<br />
<br />
Application specific configuration is stored in ''.xml'' files and further files of the [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176 shared MIME-info database], stored in ''.keys'' and ''.mime'' files that are located in {{ic|/usr/share/mime-info/}}.<br />
<br />
Global directories for the ''.xml'' files are:<br />
<br />
/usr/share/mimelnk/application/<br />
/usr/share/mime/packages/ <br />
<br />
{{Warning|Above should not be modified, for user-specific configuration see below.}}<br />
<br />
Any user-specific ''.xml'' configuration may be stored in:<br />
~/.local/share/mime/packages/<br />
<br />
==== Example: .xml and related .desktop configuration ====<br />
<br />
Create and edit {{ic|~/.local/share/mime/packages/application-x-foobar.xml}}:<br />
<br />
{{bc|1=<br />
<?xml version="1.0" encoding="UTF-8"?><br />
<nowiki><mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"></nowiki><br />
'''<mime-type type="application/x-foobar">'''<br />
<comment>foo file</comment><br />
<icon name="application-x-foobar"/><br />
<glob-deleteall/><br />
'''<glob pattern="*.foo"/>'''<br />
</mime-type><br />
</mime-info><br />
}}<br />
<br />
Create a related {{ic|~/.local/share/applications/foobar.desktop}} file:<br />
<br />
{{bc|1=<br />
[Desktop Entry]<br />
Name=Foobar<br />
Exec=/usr/bin/foobar<br />
'''MimeType=application/x-foobar'''<br />
Icon=foobar<br />
Terminal=false<br />
Type=Application<br />
Categories=AudioVideo;Player;Video;<br />
Comment=<br />
}}<br />
<br />
The {{ic|Categories}} variable contains information about the DE/WM ''menu'' where the application is placed.<br />
<br />
Now update the application and mime database with:<br />
<br />
$ update-desktop-database ~/.local/share/applications<br />
$ update-mime-database ~/.local/share/mime<br />
<br />
Programs that use MIME-types, such as file managers, should now open {{ic|*.foo}} files with foobar (you may need to restart your file manager to see the change.)<br />
<br />
See also [[Environment variables#Examples]] about global variables that can be used in start-up scripts to set default applications for specific actions.<br />
<br />
== Utilities to manage MIME types ==<br />
<br />
Many of the file managers has options to set up and configure associations of mime types with programs. <br />
<br />
It can be done by using:<br />
<br />
* Preferences for selected file<br />
* File manager configuration menu<br />
* External program for a specific file manager<br />
<br />
Other utilities to manage MIME-types are: <br />
<br />
{| class="wikitable"<br />
! Name/Package !! Method !! Based on !! xdg-utils replacement !! Configuration file<br />
|-<br />
| {{Pkg|mime-editor}} || MIME-type || Utility for [http://rox.sourceforge.net/desktop/home.html ROX] applications || ||<br />
|-<br />
| {{AUR|ayr}} || MIME-type <br> name <br> regex || {{Pkg|file}} <br> {{Pkg|perl-file-mimeinfo}}, etc|| || {{ic|mimeapps.list}} <br> {{ic|defaults.list}}<br />
|-<br />
| {{AUR|busking-git}} || regex || {{Pkg|perl-file-mimeinfo}} || YES || custom<br />
|-<br />
| {{AUR|linopen}} || || {{Pkg|file}} || || custom<br />
|-<br />
| {{AUR|mimeo}} || MIME-type <br> regex || {{Pkg|file}} || {{AUR|xdg-utils-mimeo}} ||{{ic|mimeapps.list}} <br> {{ic|defaults.list}} <br> custom is optional<br />
|-<br />
| {{AUR|mimi-git}} || || {{Pkg|file}} || YES || custom<br />
|-<br />
| {{ic|rifle}} <br> part of {{Pkg|ranger}} || MIME-type <br> name <br> regex || || || custom<br />
|-<br />
| {{AUR|sx-open}} || regex || {{Pkg|file}} <br> bash regex || YES || custom<br />
|-<br />
| {{AUR|whippet}} || MIME-type <br> name <br> regex || SQLite database <br> {{Pkg|file}} <br> {{Pkg|perl-file-mimeinfo}}, etc || || custom SQLite database <br> {{ic|mimeapps.list}}<br />
|-<br />
| {{Pkg|xdg-utils}} || || {{Pkg|file}} <br> {{Pkg|perl-file-mimeinfo}} || ||<br />
|}<br />
<br />
{{Note|Packages that replacing ''xdg-utils'' can be symbolically linked to ''xdg-open'' in the user's {{ic|$PATH}} above {{ic|/usr/bin}}, but some applications hard-code the absolute path {{ic|/usr/bin/xdg-open}}. In this case, install {{AUR|xdg-utils-no-open}} from the [[AUR]] and copy the replacement to {{ic|/usr/bin/xdg-open}}.}}<br />
<br />
=== Examples of usage ===<br />
<br />
Here is a short description about how to use command line tools to show MIME-type of a file or set preferred program as default to open MIME-type.<br />
<br />
==== Detect MIME-type ====<br />
<br />
Tools detecting MIME-type by reading meta-data from header of the file or detecting by magic number that is in two bytes identifier in the begin of the file. See [[Wikipedia:File format#File header|File header]].<br />
<br />
Many programs are using command ''file'' to detect correct MIME-type. For detection it uses compiled database that is stored in the {{ic|/usr/share/misc/magic/}} directory. It has many options to determinate correct MIME-type and for showing output.<br />
<br />
In Linux it is two standards to detect MIME-type that can affect which program will start and open the file, e.g. extension is associated with one program but content is associated with another MIME-type. The simplest way to see what is your system prioritizes is by renaming file extension and check again with tools that can use custom [[#Associate file extensions with applications MIME-type|*.xml]] configuration files.<br />
<br />
Here is examples of utility ''xdg-mime'' that first checking association of extension in [[#Associate file extensions with applications MIME-type|*.xml]] configuration files.<br />
{| class="wikitable"<br />
! Without extension !! With extension <br />
|-<br />
|xdg-mime query filetype ''foo-file'' || xdg-mime query filetype ''foo-file''.''jpg''<br />
|-<br />
! application/vnd.oasis.opendocument.text || image/jpeg<br />
|-<br />
|}<br />
<br />
Comparison functionality of the tools <br />
<br />
Here is shown options only for simple or multiple checks of a file, for more options read their own documentation.<br />
{| class="wikitable"<br />
! Name of the tool !! Option !! Detection order !! Functionality !! Type !! Interface<br />
|-<br />
|file || ''(has many)'' || Magic(Byte/Pattern) || Show only || binary || terminal<br />
|-<br />
|xdg-mime || query filetype || *.xml -> Magic || Show / Set || binary || terminal<br />
|-<br />
|mimetype || -i ''(*.xml)'' -M ''(Magic)'' || *.xml -> Magic || Show only || script || terminal<br />
|-<br />
|mimeo || -m || *.xml -> Magic || Show / Set / Launch || script || terminal<br />
|}<br />
<br />
==== Set use of MIME-type by default ====<br />
<br />
Comparison functionality of the tools <br />
<br />
Here is shown options only for single file associations, for more options read their own documentation.<br />
<br />
{| class="wikitable"<br />
! Name of the tool !! Option !! Functionality !! Type !! Interface<br />
|-<br />
|xdg-mime || default ''*.desktop'' Type1/Extension1 Type2/Extension2 || Show / Set || binary || terminal<br />
|-<br />
|mimeo || --prefer 'regex:^Type/(Extension'''1'''<nowiki> |</nowiki>Extension?'''2''')$' ''*.desktop'' || Show / Set / Launch || script || terminal<br />
|}<br />
<br />
=== Application launchers ===<br />
<br />
{{App|[[xdg-open]]|Starting applications from command line, has basic functionality.|https://www.freedesktop.org/wiki/Software/xdg-utils/|{{Pkg|xdg-utils}}}}<br />
<br />
''xdg-open'' uses {{Pkg|perl-file-mimeinfo}} as a fallback ("generic") method if no [[desktop environment]] is detected. It is a desktop-independent tool. Many applications invoke the {{ic|xdg-open}} command internally. Inside a [[desktop environment]] it passes the arguments to desktop supported environment's file-opener applications (e.g. ''gvfs-open'', ''kde-open'', or ''exo-open''). When no desktop environment is detected the ''xdg-open'' will use its own configuration files.<br />
<br />
{{App|mimeopen|Starting applications from command line. It can use custom database and prompt user to chose default application from a list of detected relevant and offers to chose own alternative.|https://metacpan.org/release/File-MimeInfo|{{Pkg|perl-file-mimeinfo}}}}<br />
<br />
Example of the prompt:<br />
<br />
{{hc| mimeopen -d /path/to/foo-file|<br />
Please choose a default application for files of type ''Type''/''Extension''<br />
1) notepad (wine-extension-txt)<br />
2) Leafpad (leafpad)<br />
3) OpenOffice.org Writer (writer)<br />
4) gVim (gvim)<br />
5) Other...<br />
}}<br />
Your answer becomes the default handler for that type of file. Mimeopen is installed as {{ic|/usr/bin/vendor_perl/mimeopen}}.<br />
<br />
If you run ''xdg-open'' without a desktop environment, you should also install {{Pkg|perl-file-mimeinfo}}, or {{AUR|xdg-utils-mimeo}} and {{AUR|mimeo}} from the [[AUR]] for a faster alternative.<br />
<br />
==== Miscellaneous ====<br />
<br />
The [http://linux.die.net/man/4/mailcap mailcap] file.<br />
<br />
{{Expansion|When using {{AUR|run-mailcap}}, ''xdg-open'' may refer to it.[http://cgit.freedesktop.org/xdg/xdg-utils/tree/scripts/xdg-open.in#n266] It should then clearly not be combined with the below file to prevent endless loops.}}<br />
<br />
The ''.mailcap'' file format is used by mail programs such as {{Pkg|mutt}} and {{Pkg|sylpheed}}. To have those programs use ''xdg-open'', edit {{ic|~/.mailcap}}:<br />
<br />
{{hc|~/.mailcap|<br />
*/*; xdg-open "%s"<br />
}}<br />
<br />
=== Extended practical examples ===<br />
<br />
==== xdg-open ====<br />
<br />
''xdg-mime'' modifies the local file {{ic|~/.config/mimeapps.list}} and {{ic|~/.local/share/applications/mimeapps.list}} (deprecated).<br />
<br />
To '''query''' the mime type used by an existing file, use <br />
$ xdg-mime query ''filetype'' ''file.ext''<br />
<br />
To change an associated desktop entry by setting [[Thunar]] as the default file browser:<br />
<br />
$ xdg-mime default Thunar.desktop inode/directory<br />
Note that you should not specify the complete path, but only the name of the ''.desktop'' file.<br />
<br />
This command can take multiple mime-types, allowing related files to be handled by the same program. The example below associates [[Emacs]] to all known source files:<br />
$ xdg-mime default emacs.desktop $(grep '^text/x-*' /usr/share/mime/types)<br />
<br />
===== Set the default browser =====<br />
<br />
To set the default application for {{ic|http(s)://}} internet protocols:<br />
<br />
$ xdg-mime default midori.desktop x-scheme-handler/http<br />
$ xdg-mime default midori.desktop x-scheme-handler/https<br />
<br />
As an alternative try:<br />
<br />
$ xdg-settings set default-web-browser netsurf.desktop<br />
<br />
To verify if the URLs opens correctly:<br />
<br />
$ xdg-open <nowiki>https://archlinux.org</nowiki><br />
<br />
To associate ''.html'' files with the {{Pkg|netsurf}} web-browser:<br />
<br />
$ xdg-mime default netsurf.desktop text/html<br />
<br />
== Troubleshooting == <br />
<br />
=== Variables in .desktop files that affect application launch ===<br />
<br />
Desktop environments and file managers supporting the specifications launch programs according to definition in the ''.desktop'' files. See [[Desktop entries#Application entry]]. <br />
<br />
Usually, configuration of the packaged ''.desktop'' files is not required, but it may not be bug-free. Even if an application containing necessary MIME-type description in the ''.desktop'' file {{ic|MimeType}} variable that is used for association, it can fail to start correctly, not start at all or start without opening a file. <br />
<br />
This may happen, for example, if the {{ic|Exec}} variable is missing internal options needed for how to open a file, or how the application is shown in the menu. The {{ic|Exec}} variable usually begins with {{ic|%}}; for its currently supported options, see [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables exec-variables].<br />
<br />
The following table lists the main variable entries of ''.desktop'' files that affect how an application starts, if it has a MIME-type associated with it. <br />
<br />
{| class="wikitable"<br />
! Variable names !! Example 1 content !! Example 2 content !! Description<br />
|-<br />
| DBusActivatable || DBusActivatable=true || DBusActivatable=false || Application interact with [https://www.freedesktop.org/wiki/Software/dbus/ D-Bus]. <br> See also configuration: [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#dbus D-Bus].<br />
|-<br />
| MimeType || MimeType=application/vnd.oasis.opendocument.text || MimeType=application/vnd.sun.xml.math || List of MIME types supported by application<br />
|-<br />
| StartupWMClass || StartupWMClass=google-chrome || StartupWMClass=xpad || Associate windows with the owning application<br />
|-<br />
| Terminal || Terminal=true || Terminal=false || Start in default terminal<br />
|}</div>Andy Crowdhttps://wiki.archlinux.org/index.php?title=XDG_MIME_Applications&diff=436101XDG MIME Applications2016-05-22T21:01:00Z<p>Andy Crowd: /* Utilities to manage MIME types */ corrected "Note" because in table is already shown which replaces xdg-utils</p>
<hr />
<div>[[Category:Desktop environments]]<br />
[[ja:デフォルトアプリケーション]]<br />
[[ru:Changing filetype association via MIME]]<br />
[[zh-cn:Default applications]]<br />
{{Related articles start}}<br />
{{Related|Desktop entries}}<br />
{{Related|Desktop environment}}<br />
{{Related|Window manager}}<br />
{{Related articles end}}<br />
<br />
The type of a data file is usually, but not necessarily, denoted by the extension of the file name, for example ''.html'' or ''.jpeg''. A second way to determine the data type is via the so-called "magic bytes" at the start of the file. Both ways determine the MIME-type of the data. <br />
<br />
Each application installed to a [[desktop environment]] provides information about the MIME-types it can handle via the [[Desktop entries]], but frequently there is more than one application able to handle data of a certain MIME-type. This article describes how the ''default applications'' to handle a MIME-type can be configured. <br />
<br />
Note that while Arch Linux does not provide custom presets for default applications, the [[desktop environment]] you install may do so. Some desktop environments also provide a GUI or a file-manager which enables to interactively configure default applications for certain file extensions. If this suffices for your system usage, you may not need to configure anything further. <br />
<br />
The scope of this article is the freedesktop [https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html Association between MIME types and applications] specification. <br />
<br />
== MIME types and desktop entries ==<br />
<br />
MIME-types are specified by two slash ({{ic|/}}) parts: ''Type/Extension'', for example {{ic|video/x-ms-wmv}}. The second part of the MIME-type is expanding faster, for example with new applications or data encoding standards. <br />
<br />
The default applications to open a MIME-type are usually stored in [[#Default mimeapps.list paths|mimeapps.list]] files, but some of the desktop environments and file managers store MIME-type associations in own custom configuration files. If a MIME-type association is not found in the default configuration, the desktop environment will look for the first match of the MIME-type in ''.desktop'' files. <br />
<br />
Description of some MIME-type first part and examples of second parts:<br />
<br />
{| class="wikitable"<br />
! Type of MIME ( 1st part ) !! Description !! Examples of extension (2nd part)<br />
|-<br />
|application || Files with binary content such, e.g.: documents,archives,... || epub+zip, ereader, excel, gbr, gzip<br />
|-<br />
|audio || Audio files that that can be played by a music player or audio editor || flac, m4a, midi<br />
|-<br />
|chemical || Chemical information, molecular and other chemical data || x-cif, x-cml, x-daylight-smiles, x-gamess-input, x-gamess-output, x-gaussian-checkpoint, x-gaussian-cube, x-gaussian-log, x-mopac-out, x-pdb, x-qchem-output, x-xyz<br />
|-<br />
|image || Image files that can be opened by image editor or image viewer || bmp, crw, g3fax, gif, jp2, jpeg, jpeg2000, jpg<br />
|-<br />
|inode || Can be opened by a file manager || blockdevice, chardevice, directory, fifo, mount-point, socket, symlink<br />
|-<br />
|message || Message protocols || delivery-status, disposition-notification, external-body, news, partial, rfc822, x-gnu-rmail<br />
|-<br />
|misc || Streaming meta data || ultravox<br />
|-<br />
|text || Text documents that can be viewed (e.g. with command ''less'') or opened with a text editor || html, javascript, mathml, mml, plain<br />
|-<br />
|video || Video files that can be played or edited with a video editor || flv, mp2t, mp4<br />
|-<br />
|x-content || Content on disks such as e.g. Audio,Video,Image or blank disk || audio-cdda, audio-player, blank-bd, blank-cd, blank-dvd, blank-hddvd, image-picturecd, video-dvd, video-svcd, video-vcd<br />
|-<br />
|x-scheme-handler || Internet protocol || ftp, geo, ghelp, help, http, https, hwplay, icy, icyx, info, irc, magnet, mailto, man, mms, mmsh, net, pnm, rtmp, rtp, rtsp, skype, uvox, vnc, xmpp<br />
|-<br />
|x-epoc || SISX package ||x-sisx-app<br />
|-<br />
|multipart || Multi-part mime messages ||alternative, appledouble, digest, encrypted, mixed, related, report, signed, x-mixed-replace<br />
|-<br />
|model || such as 3D model || x-kpovmodeler, vrml, x-modelica<br />
|}<br />
<br />
For the description of MIME-types you can search in XDG database:<br />
$ grep -e 'mime-type type=' -e '<comment>' /usr/share/mime/packages/freedesktop.org.xml<br />
<br />
{{Tip|To see all MIME extensions in the system's ''.desktop'' files that belongs to a MIME-type you can use {{AUR|lsdesktopf}}, for example {{ic|lsdesktopf --gm -gx video}}.}} <br />
<br />
If you ever require to create a custom association of a new file extension to a MIME-type, see the <br />
[http://standards.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html Association between MIME types and applications] standard.<br />
<br />
== Set default applications == <br />
<br />
=== Default mimeapps.list paths ===<br />
<br />
The {{ic|mimeapps.list}} file stores the configuration for the default application to open a MIME-type. <br />
There are different locations for it: <br />
* system-wide, <br />
* per-user, <br />
* custom locations some [[desktop environment]]s or [[window managers]] may use. <br />
<br />
The {{ic|''$desktop''}} denotes the name of the related DE or WM in the following list. The search order of paths is: <br />
<br />
{| class="wikitable"<br />
! Path !! Usage<br />
|-<br />
| {{ic|$HOME/.config/''$desktop''-mimeapps.list}} || user overrides, desktop-specific<br />
|-<br />
| {{ic|$HOME/.config/mimeapps.list}} || user overrides<br />
|-<br />
| {{ic|/etc/xdg/''$desktop''-mimeapps.list}} || sysadmin and vendor overrides, desktop-specific<br />
|-<br />
| {{ic|/etc/xdg/mimeapps.list}} || sysadmin and vendor overrides<br />
|-<br />
| {{ic|$HOME/.local/share/applications/''$desktop''-mimeapps.list}} || for compatibility but now deprecated, desktop-specific<br />
|-<br />
| {{ic|$HOME/.local/share/applications/mimeapps.list}} || for compatibility but now deprecated<br />
|-<br />
| {{ic|/usr/local/share/applications/''$desktop''-mimeapps.list}}<br>{{ic|/usr/share/applications/$desktop-mimeapps.list}} || distribution-provided defaults, desktop-specific<br />
|-<br />
| {{ic|/usr/local/share/applications/mimeapps.list}}<br>{{ic|/usr/share/applications/mimeapps.list}} || distribution-provided defaults<br />
|}<br />
<br />
=== Description of the mimeapps.list file ===<br />
<br />
The file contains two main sections for default and additional alternatives to open files of a MIME-type. The second and the third section ({{ic|[Removed Associations]}}) are optional.<br />
<br />
Example:<br />
<br />
[Default Applications]<br />
mimetype1=default1.desktop<br />
<br />
Defined additional associations of applications to MIME-types:<br />
[Added Associations]<br />
mimetype1=foo1.desktop;foo2.desktop;foo3.desktop;<br />
mimetype2=foo4.desktop;<br />
<br />
Removed associations of applications with MIME-types (blacklisting a MIME-type association of an application in its {{ic|.desktop}} file):<br />
[Removed Associations]<br />
mimetype1=foo5.desktop<br />
<br />
Multiple ''.desktop'' files for a single MIME-type must be semicolon-separated. Not supported entries are ignored in {{ic|mimeapps.list}}. The DE/WM then searches for the first match to the needed MIME-type them in the default path for ''.desktop'' files. <br />
<br />
{{Tip|To get a quick overview of how many and which ''.desktop'' files can be associated with a certain MIME-type, you can use the {{AUR|lsdesktopf}} utility, e.g. {{ic|lsdesktopf --gen-mimeapps}}.}}<br />
<br />
{{Note|Arch Linux itself does not provide system-wide presets for associations, but other distributions and specific desktop environments may do so via packaged {{ic|mimeapps.list}} files, or the older and deprecated {{ic|defaults.list}} files. Hence, your choice of desktop environment, or none, will also affect how your default applications are associated.}}<br />
<br />
=== Shared MIME-info database ===<br />
<br />
In background to the {{ic|mimeapps.list}} files, the system holds a database of MIME-type information registered via the installed applications' ''.desktop'' files. The [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176 Shared MIME-info Database]. <br />
When an application is installed, updated or removed, a [[pacman]] hook automatically updates the database, located in the {{ic|mimeinfo.cache}} in the {{ic|/usr/local/share/applications}} and {{ic|/usr/share/applications}} directories. These files keep track of which MIME-types are associated with which ''.desktop'' files overall. <br />
<br />
{{Warning|The database files are not meant to be edited directly.}}<br />
<br />
Application specific configuration is stored in ''.xml'' files and further files of the [https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html#idm139839923550176 shared MIME-info database], stored in ''.keys'' and ''.mime'' files that are located in {{ic|/usr/share/mime-info/}}.<br />
<br />
Global directories for the ''.xml'' files are:<br />
<br />
/usr/share/mimelnk/application/<br />
/usr/share/mime/packages/ <br />
<br />
{{Warning|Above should not be modified, for user-specific configuration see below.}}<br />
<br />
Any user-specific ''.xml'' configuration may be stored in:<br />
~/.local/share/mime/packages/<br />
<br />
==== Example: .xml and related .desktop configuration ====<br />
<br />
Create and edit {{ic|~/.local/share/mime/packages/application-x-foobar.xml}}:<br />
<br />
{{bc|1=<br />
<?xml version="1.0" encoding="UTF-8"?><br />
<nowiki><mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"></nowiki><br />
'''<mime-type type="application/x-foobar">'''<br />
<comment>foo file</comment><br />
<icon name="application-x-foobar"/><br />
<glob-deleteall/><br />
'''<glob pattern="*.foo"/>'''<br />
</mime-type><br />
</mime-info><br />
}}<br />
<br />
Create a related {{ic|~/.local/share/applications/foobar.desktop}} file:<br />
<br />
{{bc|1=<br />
[Desktop Entry]<br />
Name=Foobar<br />
Exec=/usr/bin/foobar<br />
'''MimeType=application/x-foobar'''<br />
Icon=foobar<br />
Terminal=false<br />
Type=Application<br />
Categories=AudioVideo;Player;Video;<br />
Comment=<br />
}}<br />
<br />
The {{ic|Categories}} variable contains information about the DE/WM ''menu'' where the application is placed.<br />
<br />
Now update the application and mime database with:<br />
<br />
$ update-desktop-database ~/.local/share/applications<br />
$ update-mime-database ~/.local/share/mime<br />
<br />
Programs that use MIME-types, such as file managers, should now open {{ic|*.foo}} files with foobar (you may need to restart your file manager to see the change.)<br />
<br />
See also [[Environment variables#Examples]] about global variables that can be used in start-up scripts to set default applications for specific actions.<br />
<br />
== Utilities to manage MIME types ==<br />
<br />
Many of the file managers has options to set up and configure associations of mime types with programs. <br />
<br />
It can be done by using:<br />
<br />
* Preferences for selected file<br />
* File manager configuration menu<br />
* External program for a specific file manager<br />
<br />
Other utilities to manage MIME-types are: <br />
<br />
{| class="wikitable"<br />
! Name/Package !! Method !! Based on !! xdg-utils replacement !! Configuration file<br />
|-<br />
| {{Pkg|mime-editor}} || MIME-type || Utility for [http://rox.sourceforge.net/desktop/home.html ROX] applications || ||<br />
|-<br />
| {{AUR|ayr}} || MIME-type <br> name <br> regex || {{Pkg|file}} <br> {{Pkg|perl-file-mimeinfo}}, etc|| || {{ic|mimeapps.list}} <br> {{ic|defaults.list}}<br />
|-<br />
| {{AUR|busking-git}} || regex || {{Pkg|perl-file-mimeinfo}} || YES || custom<br />
|-<br />
| {{AUR|linopen}} || || {{Pkg|file}} || || custom<br />
|-<br />
| {{AUR|mimeo}} || MIME-type <br> regex || {{Pkg|file}} || {{AUR|xdg-utils-mimeo}} ||{{ic|mimeapps.list}} <br> {{ic|defaults.list}} <br> custom is optional<br />
|-<br />
| {{AUR|mimi-git}} || || {{Pkg|file}} || YES || custom<br />
|-<br />
| {{ic|rifle}} <br> part of {{Pkg|ranger}} || MIME-type <br> name <br> regex || || || custom<br />
|-<br />
| {{AUR|sx-open}} || regex || {{Pkg|file}} <br> bash regex || YES || custom<br />
|-<br />
| {{AUR|whippet}} || MIME-type <br> name <br> regex || SQLite database <br> {{Pkg|file}} <br> {{Pkg|perl-file-mimeinfo}}, etc || || custom SQLite database <br> {{ic|mimeapps.list}}<br />
|-<br />
| {{Pkg|xdg-utils}} || || {{Pkg|file}} <br> {{Pkg|perl-file-mimeinfo}} || ||<br />
|}<br />
<br />
{{Note|Packages that replacing ''xdg-utils'' can be symbolically linked to ''xdg-open'' in the user's {{ic|$PATH}} above {{ic|/usr/bin}}, but some applications hard-code the absolute path {{ic|/usr/bin/xdg-open}}. In this case, install {{AUR|xdg-utils-no-open}} from the [[AUR]] and copy the replacement to {{ic|/usr/bin/xdg-open}}.}}<br />
<br />
There are available additional preset MIME-type descriptions for a various desktop environments.<br />
<br />
{| class="wikitable"<br />
! Package name !! Description !! Files<br />
|-<br />
| {{AUR|gnome-defaults-list}} || Ubuntu defaults || {{ic|/etc/gnome/defaults.list}} <br> {{ic|/usr/share/applications/defaults.list}}<br />
|-<br />
| {{Pkg|mime-types}} || Additional list of MIME-types || {{ic|/etc/mime.types}}<br />
|}<br />
<br />
=== Examples of usage ===<br />
<br />
Here is a short description about how to use command line tools to show MIME-type of a file or set preferred program as default to open MIME-type.<br />
<br />
==== Detect MIME-type ====<br />
<br />
Tools detecting MIME-type by reading meta-data from header of the file or detecting by magic number that is in two bytes identifier in the begin of the file. See [[Wikipedia:File format#File header|File header]].<br />
<br />
Many programs are using command ''file'' to detect correct MIME-type. For detection it uses compiled database that is stored in the {{ic|/usr/share/misc/magic/}} directory. It has many options to determinate correct MIME-type and for showing output.<br />
<br />
In Linux it is two standards to detect MIME-type that can affect which program will start and open the file, e.g. extension is associated with one program but content is associated with another MIME-type. The simplest way to see what is your system prioritizes is by renaming file extension and check again with tools that can use custom [[#Associate file extensions with applications MIME-type|*.xml]] configuration files.<br />
<br />
Here is examples of utility ''xdg-mime'' that first checking association of extension in [[#Associate file extensions with applications MIME-type|*.xml]] configuration files.<br />
{| class="wikitable"<br />
! Without extension !! With extension <br />
|-<br />
|xdg-mime query filetype ''foo-file'' || xdg-mime query filetype ''foo-file''.''jpg''<br />
|-<br />
! application/vnd.oasis.opendocument.text || image/jpeg<br />
|-<br />
|}<br />
<br />
Comparison functionality of the tools <br />
<br />
Here is shown options only for simple or multiple checks of a file, for more options read their own documentation.<br />
{| class="wikitable"<br />
! Name of the tool !! Option !! Detection order !! Functionality !! Type !! Interface<br />
|-<br />
|file || ''(has many)'' || Magic(Byte/Pattern) || Show only || binary || terminal<br />
|-<br />
|xdg-mime || query filetype || *.xml -> Magic || Show / Set || binary || terminal<br />
|-<br />
|mimetype || -i ''(*.xml)'' -M ''(Magic)'' || *.xml -> Magic || Show only || script || terminal<br />
|-<br />
|mimeo || -m || *.xml -> Magic || Show / Set / Launch || script || terminal<br />
|}<br />
<br />
==== Set use of MIME-type by default ====<br />
<br />
Comparison functionality of the tools <br />
<br />
Here is shown options only for single file associations, for more options read their own documentation.<br />
<br />
{| class="wikitable"<br />
! Name of the tool !! Option !! Functionality !! Type !! Interface<br />
|-<br />
|xdg-mime || default ''*.desktop'' Type1/Extension1 Type2/Extension2 || Show / Set || binary || terminal<br />
|-<br />
|mimeo || --prefer 'regex:^Type/(Extension'''1'''<nowiki> |</nowiki>Extension?'''2''')$' ''*.desktop'' || Show / Set / Launch || script || terminal<br />
|}<br />
<br />
=== Application launchers ===<br />
<br />
{{App|[[xdg-open]]|Starting applications from command line, has basic functionality.|https://www.freedesktop.org/wiki/Software/xdg-utils/|{{Pkg|xdg-utils}}}}<br />
<br />
''xdg-open'' uses {{Pkg|perl-file-mimeinfo}} as a fallback ("generic") method if no [[desktop environment]] is detected. It is a desktop-independent tool. Many applications invoke the {{ic|xdg-open}} command internally. Inside a [[desktop environment]] it passes the arguments to desktop supported environment's file-opener applications (e.g. ''gvfs-open'', ''kde-open'', or ''exo-open''). When no desktop environment is detected the ''xdg-open'' will use its own configuration files.<br />
<br />
{{App|mimeopen|Starting applications from command line. It can use custom database and prompt user to chose default application from a list of detected relevant and offers to chose own alternative.|https://metacpan.org/release/File-MimeInfo|{{Pkg|perl-file-mimeinfo}}}}<br />
<br />
Example of the prompt:<br />
<br />
{{hc| mimeopen -d /path/to/foo-file|<br />
Please choose a default application for files of type ''Type''/''Extension''<br />
1) notepad (wine-extension-txt)<br />
2) Leafpad (leafpad)<br />
3) OpenOffice.org Writer (writer)<br />
4) gVim (gvim)<br />
5) Other...<br />
}}<br />
Your answer becomes the default handler for that type of file. Mimeopen is installed as {{ic|/usr/bin/vendor_perl/mimeopen}}.<br />
<br />
If you run ''xdg-open'' without a desktop environment, you should also install {{Pkg|perl-file-mimeinfo}}, or {{AUR|xdg-utils-mimeo}} and {{AUR|mimeo}} from the [[AUR]] for a faster alternative.<br />
<br />
==== Miscellaneous ====<br />
<br />
The [http://linux.die.net/man/4/mailcap mailcap] file.<br />
<br />
{{Expansion|When using {{AUR|run-mailcap}}, ''xdg-open'' may refer to it.[http://cgit.freedesktop.org/xdg/xdg-utils/tree/scripts/xdg-open.in#n266] It should then clearly not be combined with the below file to prevent endless loops.}}<br />
<br />
The ''.mailcap'' file format is used by mail programs such as {{Pkg|mutt}} and {{Pkg|sylpheed}}. To have those programs use ''xdg-open'', edit {{ic|~/.mailcap}}:<br />
<br />
{{hc|~/.mailcap|<br />
*/*; xdg-open "%s"<br />
}}<br />
<br />
=== Extended practical examples ===<br />
<br />
==== xdg-open ====<br />
<br />
''xdg-mime'' modifies the local file {{ic|~/.config/mimeapps.list}} and {{ic|~/.local/share/applications/mimeapps.list}} (deprecated).<br />
<br />
To '''query''' the mime type used by an existing file, use <br />
$ xdg-mime query ''filetype'' ''file.ext''<br />
<br />
To change an associated desktop entry by setting [[Thunar]] as the default file browser:<br />
<br />
$ xdg-mime default Thunar.desktop inode/directory<br />
Note that you should not specify the complete path, but only the name of the ''.desktop'' file.<br />
<br />
This command can take multiple mime-types, allowing related files to be handled by the same program. The example below associates [[Emacs]] to all known source files:<br />
$ xdg-mime default emacs.desktop $(grep '^text/x-*' /usr/share/mime/types)<br />
<br />
===== Set the default browser =====<br />
<br />
To set the default application for {{ic|http(s)://}} internet protocols:<br />
<br />
$ xdg-mime default midori.desktop x-scheme-handler/http<br />
$ xdg-mime default midori.desktop x-scheme-handler/https<br />
<br />
As an alternative try:<br />
<br />
$ xdg-settings set default-web-browser netsurf.desktop<br />
<br />
To verify if the URLs opens correctly:<br />
<br />
$ xdg-open <nowiki>https://archlinux.org</nowiki><br />
<br />
To associate ''.html'' files with the {{Pkg|netsurf}} web-browser:<br />
<br />
$ xdg-mime default netsurf.desktop text/html<br />
<br />
== Troubleshooting == <br />
<br />
=== Variables in .desktop files that affect application launch ===<br />
<br />
Desktop environments and file managers supporting the specifications launch programs according to definition in the ''.desktop'' files. See [[Desktop entries#Application entry]]. <br />
<br />
Usually, configuration of the packaged ''.desktop'' files is not required, but it may not be bug-free. Even if an application containing necessary MIME-type description in the ''.desktop'' file {{ic|MimeType}} variable that is used for association, it can fail to start correctly, not start at all or start without opening a file. <br />
<br />
This may happen, for example, if the {{ic|Exec}} variable is missing internal options needed for how to open a file, or how the application is shown in the menu. The {{ic|Exec}} variable usually begins with {{ic|%}}; for its currently supported options, see [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables exec-variables].<br />
<br />
The following table lists the main variable entries of ''.desktop'' files that affect how an application starts, if it has a MIME-type associated with it. <br />
<br />
{| class="wikitable"<br />
! Variable names !! Example 1 content !! Example 2 content !! Description<br />
|-<br />
| DBusActivatable || DBusActivatable=true || DBusActivatable=false || Application interact with [https://www.freedesktop.org/wiki/Software/dbus/ D-Bus]. <br> See also configuration: [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#dbus D-Bus].<br />
|-<br />
| MimeType || MimeType=application/vnd.oasis.opendocument.text || MimeType=application/vnd.sun.xml.math || List of MIME types supported by application<br />
|-<br />
| StartupWMClass || StartupWMClass=google-chrome || StartupWMClass=xpad || Associate windows with the owning application<br />
|-<br />
| Terminal || Terminal=true || Terminal=false || Start in default terminal<br />
|}</div>Andy Crowd