XFile FAQ/Guide

The Tools Menu

Custom tools may be added to XFile's Tools drop-down menu using X resources like this:

XFile.tools.name: command [arguments]

Arguments may contain context dependent variables:

† If more than one file is selected, the specified command will be run for each file separately.


Adds a tool named search that runs the find command in xterm after prompting the user for search pattern:

XFile.tools.search: xterm -hold -e find %p -name %u

The menu button widget inherits tool's name, hence (if desired) its XmPushButton resources may be set as follows:

XFile*toolsMenu.search.labelString: Search...
XFile*toolsMenu.search.mnemonic: S
XFile*toolsMenu.search.acceleratorText: F3
XFile*toolsMenu.search.accelerator: <Key>F3

File Types

File type associations are meant to be defined by the user. XFile distribution contains some generic file type definitions, which are installed in prefix†/share/XFile/types/system.db. Files in this directory, as well as $HOME/.xfile/types are sourced in alphabetical order, overriding identically named types defined earlier. Definitions under $HOME/.xfile/types have precedence over system wide definitions.

prefix is platform dependent and is specified in the platform specific makefile.

Basic Example

# A type definition starts with a descriptive type name
GIMP Image
	# Icon to be displayed for the file type
	# (name of an icon pixmap file without suffix)
	icon xcf
	# File name pattern
	match_name *.xcf
	# Action to be shown in file context menu (& designates the mnemonic character)
	# and command to be run. %n expands to the file name selected
	action &Open: gimp %n

NOTE: Sourced database files as well as types defined within can be viewed by choosing the Help->File Types menu command.

Multiple patterns and actions may be specified, in groups as well:


	View: foo %n
	Edit: bar %n
	Print: lpr %n

Matching Contents

Files may also be identified by their contents by specifying offset (in bytes) into the file, followed by data to match. For example:
match_content 1 PDF

match_content 0 #/bin/sh
See man 1 xfile for detailed description.


Using variables instead of actual command names in action fields makes it easy to control which application is used to open certain kinds of files by setting X resources, instead of modifying the file type database.

Variables for common applications may be defined using X resources: XFile.variables.name: value.

For example, following defines a variable named imageEditor and sets its value to gimp in Xresources/app-defaults:

XFile.variables.imageEditor: gimp

...which can then be specified in the type database as follows:

action Open: %imageEditor %n

NOTE: The default database makes use of several variables: terminal, textEditor, webBrowser, imageViewer, imageEditor, audioPlayer, videoPlayer. These may be set in Xresources/app-defaults according to user's preferences.


XFile uses icons in XPM (X pixmap) format. Default icon set is installed in prefix/share/xfile/icons. The naming convention is: name.size.xpm while size may be either t,s,m,l (tiny, small medium and large, being 16, 24, 32 and 48 pixels in size respectively). Custom icons may be installed in $HOME/.xfile/icons, and have precedence over those installed under prefix

The size of icons displayed in the file list is chosen depending on the font height used for file name labels by default. This can be controlled with the XFile*iconSize: auto|tiny|small|medium|large resource.

Mount Points

XFile will highlight mount points (folder icon with green tab, bright green if mounted). The userMounts X resource specifies whether Un/Mount commands will be shown in the context menu for mount points. Additionally, mountCommand and unmountCommand resources may be set to override default mount commands.

NOTE: the host system must be configured accordingly to allow user mounts. See fstab(5) (fs_mntops) on Linuxen and vfs.usermounts for FreeBSD.

Mount Daemon

Additionally, XFile may be configured to utilize a mount daemon that manages a media directory, which is set using the mediaDirectory resource. If mediaDirectory is set, mediaMountCommand, mediaUnmountCommand must also be specified.

Here is an example Xresources configuration for udevil/devmon on Linux:

XFile.mediaDirectory: /media/$LOGNAME
XFile.mediaUnmountCommand: udevil umount
XFile.mediaMountCommand: udevil mount

Long File Names

If desired, XFile can abbreviate long file names (full name will still be displayed in the status field). This feature is disabled by default and can be controlled with the XFile*fileList.shortenLabels resource by specifying the maximum number of characters to be displayed (the minimum is 12).

Back to XFile Homepage About