SpaceFM Homepage Downloads News Wiki Report Issues README User's Manual |
SpaceFM User's Manual This manual uses your browser's default settings for fonts, font sizes, and colors. TIP: For help within SpaceFM, right-click on a menu item and select Help. Or, highlight the menu item (hover your mouse cursor over it) and press F1. Some dialogs also include a Help button which links to this manual.
Introduction Installation Invocation | ||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
Contents
|
Highlights
SpaceFM is a multi-panel tabbed file and desktop manager for Linux with built-in VFS, udev- or HAL-based device manager, customisable menu system, and bash integration. SpaceFM aims to provide a stable, capable file manager with significant customisation capabilities.
| ||||||||||||||||||||||||||||||||||||
Contents
|
History
SpaceFM was originally developed from a fork of the legacy PCManFM file manager. When PCManFM reached version 0.5.2 (aka 'the legacy version'), the original author (Hon Jen Yee) abandoned it for a major rewrite which made later versions (the 0.9.x series) dependent on gvfs and other components. At about this same time, PCManFM-Mod was created as a minor fork of the legacy version which added features, addressed bugs, and kept the legacy version alive for those who prefered it for its light dependencies and added features. PCManFM-Mod was later used as a base for developing SpaceFM, which included an extensible user interface, multiple panel support, a new udev device manager, inotify support, and removed dependencies on fam/gamin and HAL. Much of the internal virtual filesystem (VFS), which had been developed and debugged in legacy PCManFM and PCManFM-Mod, was retained and extended, providing SpaceFM with a reliable VFS to build upon. Due to the extensive changes in many parts of the project, SpaceFM was released with its new name as an alpha test version in January 2012. With version 0.7.5 in April 2012, SpaceFM replaced udisks with direct udev support for device detection and information, and support for multiple mount solutions including udevil (a mount program developed specifically for SpaceFM), pmount, udisks v1 or v2, or any program you specify. When used with udevil or a custom protocol handler, this update also added support for network filesystems. In 2012, the GTK3 version of SpaceFM was introduced. Rather than abandoning GTK2, users can choose what version of the GTK+ library (2.18 thru 3.x) they want to use with SpaceFM. In 2013-2014, improvements included extending the features of SpaceFM's Desktop Manager, a new Item Properties dialog for adding and customising menu items, socket commands for interacting with a running instance, and an improved panel configuration memory. In 2014-2015, customisable handlers were added, greatly extending SpaceFM's ability to open devices and protocols, and handle archives and files. Also, a new Bookmarks side pane was added to include submenus and more powerful bookmarks. Other changes included the addition of video thumbnails and a transparent desktop background mode.
| ||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
Contents
|
Downloads
SpaceFM is included in most distro repositories. To find packages, forum threads, and other info for your distro, see the Distros Wiki. If there are no packages for your distro, you prefer to use a testing branch, or you prefer to build SpaceFM with custom build options, a net installer is available. SpaceFM's source code is distributed from Github:
You can easily build any version or branch of SpaceFM using the Net Installer. For manual installation, or to create a custom Debian package, please see SpaceFM's detailed README file. Also check the homepage, latest news and report issues. The SpaceFM Wiki contains user-contributed plugins, help, and information. Everyone is encouraged to contribute to the wiki.
| ||||||||||||||||||||||||||||||||||||
Contents |
Net Installer
If there are no packages for your distro, or you prefer to build SpaceFM with custom build options, a net installer is available. The installer MUST be run in a terminal. It automatically downloads, builds and installs, and will work with most distros. From README: Install required build dependencies (below are Debian package names - packages names on your distro may vary but should be similar): autotools-dev bash build-essential intltool pkg-config fakeroot shared-mime-info desktop-file-utils libc6 libcairo2 libglib2.0-0 libglib2.0-dev libpango1.0-0 libx11-6 libx11-dev libudev1 libudev-dev libffmpegthumbnailer-dev Also, if using GTK2: libgtk2.0-0 (>=2.18) libgtk2.0-dev libgtk2.0-bin OR, if using GTK3: libgtk-3-0 libgtk-3-dev libgtk-3-bin Also, if you want to use startup notification: libstartup-notification0-dev RECOMMENDED: udevil|pmount|udisks gksu|kdesu|ktsuss|lxqt-sudo eject lsof wget For additional mounting support: fuseiso curlftpfs jmtpfs gphotofs ifuse To download the installer: wget https://raw.github.com/IgnorantGuru/spacefm/next/spacefm-installer # OR using curl: curl -L -o spacefm-installer \ https://raw.github.com/IgnorantGuru/spacefm/next/spacefm-installer To run the installer (MUST be run in a terminal): bash spacefm-installer Most users can press Enter to accept default values at both prompts. The installer will display dependencies for your chosen build. If any dependencies are missing, examine the error, install missing packages, and try again. If you have already downloaded the source, the installer can be run from within the source directory to automatically build and install: ./spacefm-installer When SpaceFM is installed, the installer is also installed to /usr/bin. For automated options, run: spacefm-installer --help To reinstall or upgrade, just run the installer again. For example, to upgrade to the latest rolling release, just run: spacefm-installer --version=next --prefix=/usr To uninstall: spacefm-installer --uninstall Note: When using older distros, enabling kernel polling may be required. If you insert a CD and SpaceFM still says 'no media', please see the ENABLE KERNEL POLLING section in README. | ||||||||||||||||||||||||||||||||||||
Contents
|
Uninstall
If you installed from a package, use your package manager to remove SpaceFM. Or, use the installer to uninstall: spacefm-installer --uninstallOtherwise, run these commands AS ROOT: (these commands assume you installed with the default rm /usr/bin/spacefm /usr/bin/spacefm-auth /usr/bin/spacefm-installer rm -r /usr/share/spacefm rm /usr/share/pixmaps/spacefm.png rm /usr/share/pixmaps/spacefm-*.png rm /usr/share/icons/hicolor/*/apps/spacefm.png rm /usr/share/icons/hicolor/*/apps/spacefm-*.png rm /usr/share/icons/Faenza/apps/48/spacefm.png rm /usr/share/icons/Faenza/apps/48/spacefm-*.png rm /usr/share/locale/*/LC_MESSAGES/spacefm.mo rm /usr/share/applications/spacefm*.desktop rm /usr/share/mime/packages/spacefm-mime.xml update-mime-database /usr/share/mime > /dev/null update-desktop-database -q gtk-update-icon-cache -q -t -f /usr/share/icons/hicolor | ||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
Contents |
Command Line
To see SpaceFM's command line usage run Usage: spacefm [OPTION...] [DIR | FILE | URL | DEVICE]... Help Options: -h, --help Show help options --help-all Show all help options --help-gtk Show GTK+ Options Application Options: -t, --new-tab Open folders in new tab of last window (default) -r, --reuse-tab Open folder in current tab of last used window -n, --no-saved-tabs Don't load saved tabs -w, --new-window Open folders in new window -p, --panel=P Open folders in panel 'P' (1-4) --desktop Launch desktop manager daemon --desktop-pref Show desktop settings --show-pref=N Show Preferences ('N' is the Pref tab number) -d, --daemon-mode Run as a daemon -c, --config-dir=DIR Use DIR as configuration directory -f, --find-files Show File Search --set-wallpaper Set desktop wallpaper to FILE -g, --dialog Show a custom dialog (See -g help) -s, --socket-cmd Send a socket command (See -s help) --profile=PROFILE No function - for compatibility only --no-desktop No function - for compatibility only --version Show version information --display=DISPLAY X display to use Normally, your session file and other user files are saved in ~/.config/spacefm/ To make SpaceFM read and save your files in another folder (~/.config/spacefm-alt in this example), stop ALL instances of SpaceFM and run: # first stop all instances: killall spacefm # then: spacefm --config-dir ~/.config/spacefm-alt IMPORTANT: The config directory path may not contain spaces or other special characters - keep it simple. Also, if /etc/xdg/spacefm/ exists, its contents will be copied to the config directory if it doesn't exist at startup.
| ||||||||||||||||||||||||||||||||||||
Contents |
Opening Windows
To open an initial SpaceFM window, run 'spacefm' with or without a folder specification: spacefm # or to open a folder: spacefm /home # or to open several folders in tabs: spacefm /home /usr/bin # or to not open saved tabs: spacefm -n To open an additional folder in a new tab of the last used SpaceFM window on the current workspace: spacefm /etc To open a folder in the current tab of the last used SpaceFM window on the current workspace: spacefm -r /etc To simply bring the SpaceFM window to the top of other windows: spacefm -r To open a second window: spacefm -w # or to open a specified folder in a second window: spacefm -w /boot # or to open a second window without loading saved tabs: spacefm -wn To open a File Search window: spacefm --find-files SpaceFM maintains a socket for each user/display combination, so when you open multiple windows using the same user and display, all windows are run from a single instance of SpaceFM. Unless a daemon or the desktop manager is running, SpaceFM will exit when all windows are closed. When a window is closed, the current folder tabs are saved to your session file if option File|Save Tabs is checked. The next time you run SpaceFM, these folder tabs will be re-opened in addition to opening tabs for any folders you specify on the command line (unless you specify -n on the command line). To specify a specific panel in which to open a folder: # open a folder in panel 2: spacefm --panel=2 /usr/bin To simply show and focus panel 2 in the last used window: spacefm --panel=2 As a more advanced example, consider wanting to open multiple SpaceFM windows, each containing different folder tabs in each panel, using a single command. For this, use a script like this to start SpaceFM: #!/bin/bash # open new window with two tabs in panel 1 spacefm -wn --panel=1 /etc /usr & sleep 0.2 # add two tabs to panel 2 spacefm -rn --panel=2 /bin /lib sleep 0.2 # open second window with two tabs in panel 1 spacefm -wn --panel=1 /boot /media sleep 0.2 # add two tabs to panel 2 of second window spacefm -rn --panel=2 /sbin /varThe sleep commands give time for the socket to be created and the newly created window to become the last used window. A shorter sleep time of 0.1 may also work on your system. | ||||||||||||||||||||||||||||||||||||
Contents
|
Opening Files, URLs, and Devices
If you specify a file rather than a folder on the command line, SpaceFM will open the file using the default MIME application for this file type (File Handlers are not used), but will not open a SpaceFM window: # open a file: spacefm /etc/fstabTo open a URL (see Protocol Handlers): spacefm ftp://ftp.us.debian.org/debian/To mount and open a device (see Device Handlers), or open an already mounted device: spacefm /dev/sdd1 | ||||||||||||||||||||||||||||||||||||
Contents |
GTK Themes
The GTK theme you're using may have a significant impact on SpaceFM's performance, and a non-working theme may create dysfunctional behavior. Because multiple panels in SpaceFM use many GUI elements, some themes cause SpaceFM to run more slowly. For example, the Clearlooks GTK2 theme has been observed to be very slow with SpaceFM, while the Raleigh theme is quite fast. SpaceFM may be built to use GTK v2 or v3. To see if your installed copy of SpaceFM is using GTK2 or GTK3 themes, run GTK 2 GTK2_RC_FILES=/usr/share/themes/Raleigh/gtk-2.0/gtkrc spacefm You can also test SpaceFM's speed with no theme, which should be faster than any theme: GTK2_RC_FILES="" spacefm To specify a GTK2 theme within a desktop file, copy SpaceFM's desktop file to your home folder: mkdir -p ~/.local/share/applications cp /usr/share/applications/spacefm.desktop ~/.local/share/applications/ # OR cp /usr/local/share/applications/spacefm.desktop ~/.local/share/applications/Then open ~/.local/share/applications/spacefm.desktop in your editor and set the Exec= line using env. For example: Exec=env GTK2_RC_FILES=/usr/share/themes/Raleigh/gtk-2.0/gtkrc spacefm GTK 3 | ||||||||||||||||||||||||||||||||||||
Contents |
Desktop Manager
SpaceFM includes a lightweight desktop manager to manage desktop icons and show wallpaper (or a transparent background). SpaceFM's DM works well with Openbox, for example, which doesn't include a desktop manager. To start a desktop manager daemon, first terminate any other software which is managing your desktop, then run: spacefm --desktop You can also run ( spacefm --desktop ) & While managing the desktop, SpaceFM's volume monitor will also be running, meaning that if configured to do so, it will automount devices. To set the wallpaper from the command line, run a command like: spacefm --set-wallpaper /home/user/wallpaper.jpg To open the desktop preferences window from the command line run: spacefm --desktop-pref To stop management of the desktop prematurely (before logoff), send spacefm a quit signal: killall spacefmLike other menus in SpaceFM, Design Mode may be used in the desktop's right-click menu to add custom menu items and set key shortcuts (which will be active when the desktop has focus). | ||||||||||||||||||||||||||||||||||||
Contents |
Daemon Mode
If you want SpaceFM always running in the background, ready to quickly open windows and automount volumes, but don't want it to manage the desktop, start a daemon instance of SpaceFM: spacefm -d No window will open in this case, but an instance will be started if not already running, and it will continue running for the duration of your X login session. You can also start the daemon from your login script. For example, if using Openbox, add this line to ~/.config/openbox/autostart.sh: (sleep 2 && spacefm -d) & One particular use for daemon mode is to make sure leftover folders in /media are removed. SpaceFM can unmount removable devices on exit to prevent folders remaining in /media at shutdown (if you check option Settings|Auto-Mount|Unmount On Exit). If running as a normal instance, this means devices will be unmounted whenever you close the last SpaceFM window. When running as a daemon (or as a desktop manager daemon), devices won't be unmounted until you logoff. To stop a daemon mode instance, send SpaceFM a quit signal: killall spacefm | ||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
Contents
|
Frequently Asked Questions
How do I set or change key shortcuts and icons? How to I set or change the key to go Up a directory? Right-click on the file list, right-click on menu item Go|Up, and select Key Shortcut.How do I change the file list view, add/remove columns, etc.? How do I hide a menu item? How do I customise the toolbars? How do I create a custom menu item? Use Design Mode to add a New custom menu item.How do I move a custom menu item to another menu or menu position? How do I import a plugin to another menu? How do I create a new tab in the current folder? Right-click on any tab and select Tab Here (you can assign any key shortcut to this item using Design Mode).How do I make archives (tar.gz etc) open with an application? Why aren't all my thumbnails displayed? View|Preferences|Max Pic Size To Thumbnail may limit what pics are thumbnailed. | ||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
Contents |
Panels
SpaceFM includes up to four file manager panels in each window. Each panel represents a complete file manager, including tabbed directory contents and optionally shown side panes, toolbars, path bar, and status bar. Each panel can be hidden or shown via the View menu, or via the Panel Bar located to the right of the main menu bar. If shown, panels 1 and 2 are next to each other in the top half of the window, and panels 3 and 4 are in the bottom half. This allows horizontally arranged panels, vertically arranged panels, and combinations of both. NOTE: SpaceFM's main menu bar (File, View, etc.) is mostly used for program-wide settings and functions. Most adjustments for an individual panel's appearance can be made by right-clicking on the file list and selecting the View context menu (also available in the main View menu). This View menu will allow you to set which side panes and toolbars are visible in a panel, add and remove file list columns, set the list style and font, set the sort method, etc. The best way to use SpaceFM's memory for panel configurations is to select the panels you want visible, then arrange each panel as you want it to appear. Hide or show side panes and adjust their sizes, choose file list columns and adjust their widths, choose which toolbars are visible, etc. Each time you select a different combination of panels, you may need to do some further configuration until SpaceFM gets to know all the combinations you use and how you like them arranged. Many settings in each panel are specific to that panel. For example, a different font can be set for the file list or other panes in each panel. Also, each panel may have a different view style (Detailed, Compact, or Icons), different file list columns visible, different side panes visible, etc. Some panel settings use a four-state memory, and these settings may be different depending on the panel's relationship to other panels in the window. The four states are:
The four-state memory of each panel allows SpaceFM to remember how you configured each panel in combination with other panels. This makes it easier to show and hide panels on the fly without having to readjust columns, side panes, etc. SpaceFM will remember the selected columns (visibility), column widths, side pane visibility and sizes, and toolbar visibility for each state of each panel. For more advanced users, note that socket commands can be used to adjust panel configurations from a command or script. When set as event handlers, adjustments can be made automatically when GUI or other events occur, such as showing/hiding a panel or changing window size. If you maximize the SpaceFM window, any changes to column widths are not remembered (in any panel or in the task manager). This means that you can change column widths while maximized, and when you return to an unmaximized window state, your columns widths will revert to their original sizes. However, if you exit SpaceFM while the window is maximized, your column widths will be saved. When you restart SpaceFM it will open maximized, and any changes to column widths thereafter will be remembered while maximized (unless you unmaximize and maximize again). In fullscreen mode, neither changes to column widths nor to side pane heights are remembered. When you return to non-fullscreen mode, these will revert to their original sizes. Focus Highlighting However, sometimes it is necessary to know which panel has focus, such as when using keyboard shortcuts on selected files, or using a custom command or plugin in the main menus. For this purpose, SpaceFM provides an icon at the right of each panel's status bar. This icon will be enabled for the panel which has focus. If you would like a more prominent reminder, it is possible to set custom highlight colors for the focused panel's status bar text and background. To set highlight colors, right-click on the status bar of the panel and select Highlight Text or Highlight Bar. Each panel may use different highlight colors, or the same.
| ||||||||||||||||||||||||||||||||||||
Contents |
Path Bar
SpaceFM's Path Bar (location bar) is located in each panel above the file list in the panel's main toolbar. At its simplest, the Path Bar allows you to see the current folder's path, and you can enter a new path and press Enter to change to another folder. TIP: To place the cursor in the Path Bar, you can use Go|Focus|Path Bar, accessed from the right-click menu of the file list. By default, this is assigned to key shortcut Ctrl+L. In addition to displaying and accepting a folder path, SpaceFM's Path Bar has additional methods and uses as detailed below. Editing Keys
When the Path Bar has focus, it will steal the following keypresses (even if they are set as key shortcuts): visible characters without a modifier key, Enter, Home, Shift+Home, End, Shift+End, Delete, Tab, Backspace, Left, Shift+Left, Right, Shift+Right. Auto Seek To locate files within the current directory, use Find-As_You-Type Search or Actions|Select By Pattern. Completion Breadcrumbs Middle-Click Auto Seek File Path or Device Also, a device file (eg /dev/sdd1) may be entered in the path bar. The device will be mounted if needed, and the mount point directory of the device will be opened. Protocol URL Regardless of the protocol, most of SpaceFM's default protocol handlers accept URLs in the format: PROTOCOL://USERNAME:PASSWORD@HOST:PORT/SHARE WARNING: Including a password in the URL is a very unsafe mode of use, as your password is included in the command line and may be written to temporary and/or system files by SpaceFM or mount helpers. See documentation specific to the filesystem for other authentication methods offered, or enter your password when prompted. Some parts of the above URL format may be omitted. Examples include: ftp://mirrors.kernel.org smb://user:pass@10.0.0.1:50/docs ssh://user@sys.domain mtp://NFS and Samba (cifs) URLs may also be in the alternate formats: NFSHOST:/SHARE //SAMBAHOST/SHAREFor additional URL examples, see URL protocols and formats handled by udevil, which natively uses the same URL formats supported by SpaceFM. In addition, custom protocol handlers may be added which accept URLs in the above formats, or in any format you prefer. URLs may also be opened via the main menu bar's File|Open URL item, which is equivalent to entering them in the Path Bar, or on the command line. TIP: You can sometimes right-click on a mounted network in the Devices List and select Bookmark to bookmark the URL for future use. Or, right-click on the Path Bar containing a URL and select New Bookmark. Or, edit an existing bookmark to contain a URL target. Command Line One or more command prefixes are required to tell SpaceFM how to run your command:
A Path Bar entry is interpreted as a command only if at least one of the above prefixes preceeds the command. A space after the prefix(es) is optional. For example, enter in the Path Bar: $ lsWhen you press Enter, ls will be run for the current directory, and a dialog will open showing the output. When using prefix '$', the command is run as a task (it will be listed in the Task Manager if it takes longer than a half second to run), and a popup dialog will open only if the command produces output or an error. In addition, the substitution variables defined in Command Line, and the bash script variables described in Command Script may also be used in Path Bar command lines. For example, to open a dialog showing the path of the current directory: $ echo Current Directory: %dOr to run umount in a terminal (+) as root (!) passing it the currently selected device (%v): +! umount %v When a plus sign (+) prefix is included, the command is run in a terminal, not as a task. When an exclamation point (!) prefix is included, the command is run as root. If the ampersand (&) prefix is included, the command is run and forgotten (no error or output will be shown). This is useful for starting an application. For example: & firefoxFor a reminder of prefixes and substitution variables, enter a lone dollar sign ($) in the Path Bar and press Enter. Or press F1 while the Path Bar has focus to open this manual. Command History Select By Pattern % *.aviWhen you press Enter, all filenames in the file list ending in ".avi" will be selected, and all other files will be unselected. If your pattern contains any uppercase characters, the matching will be case sensitive. For additional wildcard characters and pattern specifics, see IEEE Pattern Matching Notation. See also: Find-As-You-Type Search. Font | ||||||||||||||||||||||||||||||||||||
Contents
|
Find-As-You-Type Search
When the file list has focus (click on the file list), pressing an alphanumeric key will open the Find-As-You-Type search box in the lower right corner of the file list, allowing you to quickly jump to a file. Press down or up arrow, or scroll wheel up/down, to go to the next or previous matched filename. In addition, Find-As-You-Type Search supports the following modes:
| ||||||||||||||||||||||||||||||||||||
Contents |
Rename Dialog
SpaceFM's Rename Dialog, accessed by right-clicking on a file and selecting Rename, does much more than rename files. It can move, copy, or create a link to the selected file or directory. It can also copy the target of a selected link, or create a new link to the target. By checking As Root, the function will be performed as the root user. The Option button allows you to add and remove fields from the dialog. The selected fields, which are extra-large for easy editing of long filenames, show different parts of the selected path, such as the name and extension, full filename, parent, or path. As you edit the file's path, you will be advised if the entered path already exists. If you use a path which doesn't exist, SpaceFM will create the necessary parents automatically. The Confirm Create option determines if you will be prompted before parents are created. The Browse button allows you to browse for a filename, parent, or path, and insert it into the dialog. TIPS: To select all the text in an entry, click the entry's label (eg 'Filename:'), press the Alt key shortcut, or use Tab. To quickly copy an entry's text to the clipboard, double- or middle-click on the entry's label (eg 'Filename:'). Multiple files can be selected in the file browser to rename a batch of files.
| ||||||||||||||||||||||||||||||||||||
Contents
|
New File/Folder Dialog
The New File/Folder Dialog is opened by right-clicking on the file list and selecting New|File, Folder, or Link. This dialog works similarly to the Rename Dialog, allowing you to create files and folders in other paths, create as root, create relative links (eg a link to ../filename.txt), and create new files and folders using templates. SpaceFM looks in $XDG_TEMPLATES_DIR/, ~/Templates/, or ~/.templates/ to find template files. Templates are simply empty or partially filled files (of any type) used to create new files, so instead of an empty file you get a copy of the template file. You can place any files or links to files in your Templates folder. Subfolders in the templates folder can also be used to create new folders pre-filled with a set of files, or to organize templates. After you have finished entering the path for your new file or folder, you can press Create to create it, or the '& Open' button to create and open the file or folder in one step.
| ||||||||||||||||||||||||||||||||||||
Contents |
Bookmarks
SpaceFM's main Bookmarks menu works like most other menus - you can right-click in the menu to add custom menu items, and to cut, copy, and paste items to other menus. Custom menu items may be bookmarks which open folders, but they may also run commands or applications. This means that items in SpaceFM's bookmarks can run socket commands to open folders in specific panels, change view settings, run external programs, and perform other automated tasks. Items added to the Bookmarks menu may be shown in the Bookmarks side pane of each panel. To show the Bookmarks pane, select Show Bookmarks from the main Bookmarks menu, or right-click on a file and select View|Bookmarks. Right-click in the Bookmarks pane and enter the Settings submenu to adjust behavior. The Single Click option determines if a single- or double-click is required to open an item. New Tab, if checked, will open bookmarks in a new tab. Bookmark Icon and Submenu Icon are used to set the default icons used in the list, and individual item icons can also be configured via their Properties. The Font setting adjusts the font and font size used in the Bookmarks side pane. Finally, the Follow Dir option will cause the Bookmarks pane to follow the current directory. If a bookmark matches the current directory, it will be highlighted. If the matching bookmark is in a submenu, the submenu will be opened. Follow Dir is a per-panel setting. For example, you can turn it on in the Bookmarks pane of Panel 1, and turn it off in Panel 2. When Follow Dir is off, the bookmark selection will not change automatically. Tips:
To add a new bookmark targeting the current directory, select New Bookmark from the Bookmarks menu (a key shortcut may also be assigned to this item - right-click on it to set one), or right-click in the Bookmarks pane or menu and select New|Bookmark (which will ask you to select a directory target). To bookmark a single selected file or directory, or otherwise the current directory, right-click on the file list and select New|Bookmark. To bookmark a mounted URL, in some cases you can right-click on the URL in the Devices List and select Bookmark. Or, a URL or file/dir path in the Path Bar may be bookmarked by right-clicking on the Path Bar and selecting New Bookmark. To view or adjust the properties of a bookmark, right-click on it and select Properties. Note: The Properties dialog of all custom menu items includes a Context tab which determines when and how menu items are displayed based on the file browser's current context. Note that Context settings do not affect display of bookmarks in the Bookmarks side pane, which always shows all bookmarks. The Context settings WILL affect how items are shown in the main Bookmarks menu. Any single item or submenu of items in Bookmarks may be exported to a SpaceFM plugin file by right-clicking on the item and selecting Export. Plugin files created in this way can also be imported into any other menu. To export all items in Bookmarks, right-click on "Bookmarks" - the top item in the Bookmarks side pane - and select Export. This will create a special plugin file named "Bookmarks.spacefm-bookmarks.tar.gz". This file may then be imported into any SpaceFM menu, or into the Bookmarks side pane, by right-clicking and selecting Import|File. Note that this bookmarks plugin file CANNOT be installed or imported via the main Plugins menu. Some GNOME applications store bookmarks in GTK's bookmarks file (~/.config/gtk-3.0/bookmarks or the older ~/.gtk-bookmarks). This is a plain text file which can be edited manually. While SpaceFM is not a GNOME application and does not store its bookmarks in this file (the format of the file cannot store SpaceFM's specialized bookmarks and submenus), SpaceFM can import the contents of this file. To do so, right-click on an item in the Booksmarks side pane and select New|Import|GTK Bookmarks. All bookmarks will be imported into the current submenu (or, if you right-clicked on a submenu, then into the selected submenu). IMPORTANT: Note that importing hundreds of bookmarks into SpaceFM is not recommended. Due to their integration with the menu system, this may cause performance lags in the GUI. If you have many GTK bookmarks, you may wish to edit the file before importing it, or import them into a submenu and keep only those you need. In addition to importing GTK's bookmarks, these bookmarks are also shown in the GTK file and folder chooser dialogs used in SpaceFM. You will see the GTK bookmarks listed in the upper-left 'Places' pane of these dialogs, and you can use the plus (+) and minus (-) buttons there to add or remove bookmarks from that list (which will update the ~/.config/gtk-3.0/bookmarks file). Changing bookmarks in this 'Places' list has no effect on SpaceFM's Bookmarks menu.
| ||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
Contents |
Introduction
SpaceFM includes a programmable udev-based device manager which lists device volumes, allows you to mount and unmount devices, and detects changes, insertions, and removals. On events, SpaceFM can auto-mount and auto-open devices, and run commands you specify. In addition, perform-as-root commands allow you to mount and unmount as root; change volume labels; and check, format, erase, backup, and restore partitions. Like most parts of SpaceFM, the behavior and appearance of the device manager is customisable. Whenever SpaceFM is running, whether a window is visible or not, a volume monitor is running to monitor device events and take actions. The volume monitor requires the udevd daemon to be running for device event detection, and enabling kernel polling is recommended. SpaceFM mounts and unmounts devices using customisable Device Handlers which can use udevil (a mount program developed specifically for SpaceFM), pmount, the udisks command line tool (v1 or v2), or any program you specify. To troubleshoot behavior, you can run the same command lines in a terminal that SpaceFM uses, or create your own custom handlers or menu items to manipulate devices. NOTE: If you choose to use udisks with SpaceFM, note that SpaceFM does not configure udisks. It merely runs the udisks command line tool to mount and unmount devices (unless you install udevil, pmount or specify another program). If you receive the common 'Not Authorized' or other similar errors from udisks when mounting, or you are prompted for a password, this indicates that udisks (and policykit, etc.) are not properly installed or configured. This must be corrected in your system configuration, not in SpaceFM. Installing udevil is the quickest way to solve such problems. Deprecated HAL support can also be used in SpaceFM (alternate build required). However, SpaceFM's HAL device manager is far less capable than the udev-based version. It can only be used to manually mount and unmount devices. Thus the udev-based version is recommended, and this manual deals exclusively with the udev-based device manager. To have the device manager always running, responding to events even while no SpaceFM windows are open, run SpaceFM as a daemon or desktop manager. When testing the device manager, it may be useful to run the initial instance of SpaceFM in a terminal so that you can see additional diagnostic output as it's running. Just open a terminal window and run | ||||||||||||||||||||||||||||||||||||
Contents |
List
Each panel or tab in SpaceFM can display a Devices list to show devices and permit configuration of the underlying volume monitor. A Devices list is one interface to the volume monitor's information and actions. Even if multiple Devices lists are displayed or multiple SpaceFM windows are open, only one volume monitor will be running. To show or hide a Devices list in each panel, right-click on the file list and check or uncheck option View|Devices. You can also show or hide the list using the 'Devices' toggle tool item on a toolbar. The Devices list will display only removable and optical devices. If your Devices list is empty, this means there are no removable or optical devices with media, the udevd daemon is not installed or is not working properly on your system, or you may need to enable kernel polling for media detection. To show or hide additional devices, use the Show submenu. You can mount and open a device in the Devices list by simply left-clicking on it. The behavior of a left-click will vary depending on options New Tab and Single Click. Right-click on a device to show the Devices context menu. Middle-clicking on a device is equivalent to right-clicking on the device and selecting Remove / Eject. Thus to quickly remove a device, just middle-click on it.
| ||||||||||||||||||||||||||||||||||||
Contents |
Menu
Similar to the Devices List, SpaceFM's main menu bar and the desktop menu include Devices menus which list currently shown devices. Click on a device to mount and open it, or right-click on a device for additional options. Right-clicking on a device in these menus or in the Devices List shows the context menu described below. As in the Devices List, you can also middle-click on a device in the menu to 'Remove / Eject'. Like most menus in SpaceFM, to see the help for any menu item, hover your mouse cursor over the menu item and press F1. Alternatively, right-click on the menu item and select Help in the Design Menu. The Devices context menu includes: (not all items may be shown) Remove / Eject Next, if the volume is mounted, it will be unmounted, and if the device is ejectable, it will be ejected. If the device is removable, it is safe to remove it once the 'Remove / Eject' command has completed without errors, and any lights on the device indicate activity has stopped. (Even after the sync and unmount has finished, it may take a second or two for the device to stop flashing due to hardware caches. If the device has no activity indicator, it is best to wait 5 seconds before removing it.) If you click 'Remove / Eject' and nothing seems to happen, this also indicates the device is ready to be removed. When a device is removed or unmounted, any tabs showing directories on the device may be automatically closed. Middle-clicking on a device in the Devices list is equivalent to right-clicking the device and selecting 'Remove / Eject'. Thus to quickly remove a device, just middle-click on it. NOTE: SpaceFM does NOT disable or power-down usb ports or spin down disks when removing a device, it merely performs a sync to ensure data is written. Usually this is sufficient to prevent data loss. If powering down is required for your device, you must add a custom command to the Devices menu, or add the applicable command or option to the unmount handler. Reload Unmount Sync Open You can also open a device by simply left-clicking on it. The behavior of a left-click will vary depending on options New Tab and Single Click. To mount, SpaceFM runs the mount command from the appropriate Device Handler for the selected device. By default, udevil, pmount, or the udisks command line tool will be used. The mount point will be determined automatically by the mount program or handler, usually an automatically created subfolder in /media or /run/media/$USER. If it was automatically created, this subfolder will be automatically removed when the device is unmounted. If the device has an entry in /etc/fstab, that mount point may be used instead, and its mount directory will not be removed when unmounted. The device will generally be mounted using SpaceFM's Mount Options. If the device has an fstab entry, options specified there may take precedence, depending on your mount program, which may also automatically add or change some mount options. pmount does not support conventional mount options, so when using pmount as the mount command, options set in Mount Options will be ignored. Instead, you can include pmount's command line options in the device handler. Open In Tab works similarly to open, except that the device's mount point directory will be opened in a new tab, instead of reusing the current tab. This is also the default behavior of a left-click on a device if option New Tab is checked. Again, a left-click will not display an error, while selecting Tab will. Mount The device will generally be mounted using SpaceFM's Mount Options. If the device has an fstab entry, options specified there may take precedence. The mount program may also automatically add or change some mount options. pmount does not support conventional mount options, so when using pmount as the mount command, options set in Mount Options will be ignored. Instead, you can include pmount's command line options in the device handler. Re/mount Because most mount programs cannot perform a true remount, the device will be unmounted and mounted. Re/mount accepts extended mount options, as detailed in Mount Options. pmount does not support conventional mount options, so when using pmount as the mount command, options set here will be ignored. Instead, you can include pmount's command line options in the device handler. Bookmark Note: Any custom menu items you add directly after the Bookmark menu item in the Devices menu will also only appear if the selected device is a mounted network, providing an automatic context. Root For details, see the Root section below. Settings For details, see the Settings section below. Properties If mounted, any mtab lines related to the device will be shown in DEVICE, showing you how and where the device is mounted. USAGE will show information about the filesystem on the device. If the device has any related lines in the /etc/fstab file, these will be listed in FSTAB. These may include lines which are disabled (# comments). In the INFO section, the device's UUID will be listed if known, as well as detailed information from udev on the device's properties. The PROCESSES section, shown for mounted devices, uses lsof to display any processes which are using the device. Sometimes when unmounting a device, you will receive an error that the device is in use. You can check this processes list to see what is holding the device open. Custom Menus There are several provided bash variables which your commands can use to get information about the currently selected device: "$fm_device" selected device (eg /dev/sr0) ( same as %v ) "$fm_device_udi" device ID "$fm_device_mount_point" device mount point if mounted (eg /media/dvd) (%m) "$fm_device_label" device volume label ( same as %l ) "$fm_device_fstype" device fs_type (eg vfat) "$fm_device_size" device volume size in bytes "$fm_device_display_name" device display name "$fm_device_icon" icon currently shown for this device $fm_device_is_mounted device is mounted (0=no or 1=yes) $fm_device_is_optical device is an optical drive (0 or 1) $fm_device_is_table a partition table (usually a whole device) $fm_device_is_floppy device is a floppy drive (0 or 1) $fm_device_is_removable device appears to be removable (0 or 1) $fm_device_is_audiocd optical device contains an audio CD (0 or 1) $fm_device_is_dvd optical device contains a DVD (0 or 1) $fm_device_is_blank device contains blank media (0 or 1) $fm_device_is_mountable device APPEARS to be mountable (0 or 1) $fm_device_nopolicy policy_noauto set (no automount) (0 or 1) "$fm_panel3_device" panel 3 selected device (eg /dev/sdd1) "$fm_panel3_device_udi" panel 3 device ID ... (all these are the same as above for each panel)For example, to add a custom command which shows the size of the currently selected device in bytes, use this command line: echo "$fm_device_size" | ||||||||||||||||||||||||||||||||||||
Contents |
Root
The Root submenu allows you to perform actions on a device as root. When performing commands as root, SpaceFM will use your configured Terminal SU or Graphical SU program to run the command. When most items on this menu are selected, a dialog will open showing you the exact command to be run, and allowing you to edit it. If SpaceFM knows how to perform the function on the selected device type, a default command will already be present. In order to edit the default command, you must first depress the Edit button. To restore the command to its default, depress Edit and then press Default. Most items accept the substitution variable %v in their command, which is used to insert the device file (eg /dev/sda2). Some commands accept additional substitution variables. These will be displayed in the dialog's instructions. When performing commands which result in data loss, such as format, the exact command line to be run will be displayed in the terminal after you enter the root password. You will need to type the word 'yes' and press Enter to execute the command. The following functions are included: Unmount Mount Label Next the command used to change the volume label on this filesystem type will be shown. If SpaceFM doesn't know how to change the volume label for this type, the command will be blank and you will have to supply your own. This dialog remembers the change label command used for each filesystem type. When you click OK, your Graphical SU program will be used to run the command (no terminal will open). IMPORTANT: SpaceFM will display a warning in both dialogs if the device is currently mounted. Although some filesystem types permit it, it is generally good practice to unmount a volume before changing its label. Check Check may only be used on unmounted filesystems. Format The submenu contains common filesystem types to choose from. To format, select the type and review or edit the command in the dialog. This dialog remembers the format command used for each filesystem type. When you click OK, the command will be run in a terminal. After entering the root password, you will be shown the exact command to be run, and you must type the word 'yes' and press Enter to execute it. The format submenu also contain 'zero' and 'urandom'. If selected, the device will be overwritten with zeroes or random values to completely erase it. As with filesystem formats, you can edit the particular command used. Edit with care! To test out the format function without actually formatting anything, try using format on a DVD drive, or an empty drive. The entire procedure will be the same - you will merely receive an error when the command is finally executed. This will allow you to safely review how SpaceFM conducts a format. Just be sure you know which device is the DVD or empty drive! Backup|FSArchiver FSArchiver (website) is a modern program which creates an archive of a filesystem. It is similar to tar, except that the archive includes checksums, can be restored if corrupted, and includes additional information. One disadvantage to using FSArchiver is that unlike Partimage, the on disk locations of files will change when restored. For most files this won't matter, but in the case of grub's stage files, moving them can cause the grub boot process to no longer work. Thus if you restore a volume containing grub's files using an FSArchiver archive, you will then need to reinstall grub to the MBR (so that it knows accurately where it's files are - these locations are stored in the MBR's boot code). An advantage to FSArchiver is that it supports more filesystem types than Partimage, including ext4 and btrfs, and several compression methods. Other advantages include file exclusion, multi-thread compression, and encryption. The data may also be restored to any partition large enough to hold it, regardless of the original partition's size. FSArchiver is also currently maintained, while Partimage is no longer actively developed. There are additional differences between Partimage and FSArchiver - see their websites for details. By default, FSArchiver will backup unmounted volumes and volumes mounted read-only. To backup a volume which is mounted read-write, you must add --allow-rw-mounted to the command. This may create inconsistencies in the backup. Run To create an FSArchiver backup, right-click on a device and select Root|Backup|FSArchiver. A file save dialog will open asking you to select a filename and location. Keep in mind that the archive size may be 50% or more of the total data saved in the filesystem. Choose a save location with ample space. Next a command dialog will show you the FSArchiver command to be used, and allow you to edit it. When you click OK, the command will be run immediately in a terminal. Backup|Partimage
To create a Partimage backup, right-click on an unmounted device and select Root|Backup|Partimage. A file save dialog will open asking you to select a filename and location. Keep in mind that the archive size may be 50% or more of the total data saved in the filesystem. Choose a save location with ample space. Note that Partimage will add a '.000' volume extension to the name you select. Next a command dialog will show you the Partimage command to be used, and allow you to edit it. By default, the command will break the archive into archive volumes 4G in size. This can be adjusted by carefully editing the command. When you click OK, the command will be run immediately in a terminal. Backup|MBR After selecting Root|Backup|MBR, a file save dialog will open asking you to select a filename and location. This is a very small backup file. When you click OK, a terminal will open and the command will be executed immediately. (It is not possible to edit the MBR backup command.) Restore|From File Next a dialog will show the restoration command to be used, and allow you to edit it. When you click OK, a terminal will open prompting you for the root password. Once entered, the exact command to be run will be shown. You will need to type the word 'yes' and press Enter to execute it. IMPORTANT: Restoring data to a partition overwrites any existing filesystem. After restoring from an FSArchiver backup, if the filesystem contains grub's files, you may need to reinstall grub to the MBR to restore normal boot behavior. (Reinstalling grub is not handled by SpaceFM, and is outside the scope of this manual, but you can create a custom command to do so.) When restoring an MBR, only the first 448 bytes of the MBR are restored. This portion contains the boot code. The remaining portion of the MBR contains the primary partition table. This portion is NOT restored (it is generally not useful to do so, and in the case of an out of date backup, could cause extreme data loss). However, the MBR backup file created by SpaceFM does contain the full 512 byte MBR, so if you do want to restore the entire MBR, consult appropriate instructions such as these. To practice restoring a file without making real changes, consider restoring to a DVD or empty drive as the target. This will allow you to see the entire process, except that the final command will fail when executed. Just be sure you know which device is your DVD or empty drive! Restore|File Info Restore|File Info makes no changes to the backup file or any device - it only displays information about the backup file. It may need to run as root to do so. Edit fstab | ||||||||||||||||||||||||||||||||||||
Contents |
Settings
The Settings submenu is your interface for controlling the appearance and behavior of the Devices list and volume monitor. Options include: Show|Internal Drives Internal drives are often treated differently by mount programs. You may not be able to mount or unmount them as a normal (non-root) user without making changes to /etc/fstab or to the mount program's configuration. Note that some external esata drives report themselves as internal, so they may not be shown unless Show|Internal Drives is checked. Another solution with these drives is to enter an exception for them in Show|Volumes. Show|Empty Drives Properties can still be obtained on empty drives, and you can use Remove or Reload to open or close the tray. NOTE: For proper detection of media, enabling kernel polling may be required. Show|Partition Tables IMPORTANT: For some purposes, a whole device file, such as /dev/sda, designates not just the primary partition table, but also the entire device including partitions (/dev/sda1, /dev/sda2, etc.) Thus if you format /dev/sda, for example, you will overwrite all partitions on the entire device. However, in some cases a device uses no partitions, and the entire device has been formatted with a single filesystem. In this case, the Devices list does not consider the whole device file a partition table, so option Show|Partition Tables will have no effect on it being shown. The size displayed for a whole device file (eg /dev/sda) will generally be the size of the entire device (including all partitions), regardless of whether it contains a partition table or a filesystem. Specifically, SpaceFM considers a device to be a partition table if its udev properties include a 'partition table:' line, or the device is a partition of type 0x05 (extended partition). Show|Mounted Networks Show|Mounted Other If you do not want mounted files and non-block device filesystems listed, uncheck option Show|Mounted Other. Show|Ignore Hide Policy The hide policy of a device can be seen by selecting Properties for the device and observing the value of 'presentation hide:' in the INFO section. To ignore UDISKS_PRESENTATION_HIDE for a specific device, use Show|Volumes. Show|Volumes One example use for Show|Volumes is to show an external esata drive which is erroneously identified by udev as internal. Even if option Show|Internal Drives is unchecked, the drive will be shown if listed in Show|Volumes. Show|Volumes opens a dialog which allows you to specify device files, volume labels, or device IDs in a space-separated list. There must be a space between entries and a plus or minus sign directly before each item. This list is case-sensitive. For example, to force showing device /dev/sdd1, include:
Or, to force hiding of /dev/sdd1, include:
The '/dev/' portion of the device file MUST be included. Devices can also be identified by volume label. For example, to always hide a device with volume label "Label With Space" use:
DO NOT use quotes to enclose the label, even if it contains spaces. Finally, a device's ID may be used:
For example, this list in Show|Volumes:
would cause /dev/sdd1 and the OCZ device to be shown, and the volume with label "Label With Space" to be hidden. Show|Display Name In addition to separator characters of your choice, the following substitution variables may be used:
A device in the list is guaranteed to have a unique, non-blank device filename - no two will be alike. The other values may be duplicated or empty in some cases. After you click OK, the display names of the currently shown devices will be updated. The list is sorted alphabetically, ignoring spaces. Auto Mount|Mount Optical IMPORTANT: If you have multiple auto-mount solutions installed and running, this can create confusing behavior. For example, if you use devmon, then when using SpaceFM's auto-mount features, it is best to disable devmon. If option Mount Optical is checked, optical devices such as CD/DVD drives will be automatically mounted when media is inserted, and at SpaceFM startup. TIP: For additional information on what the volume monitor is doing, try running SpaceFM in a terminal. Information on devices being auto-mounted will be printed to the terminal, and error messages generated by your command may be seen there as well. Auto Mount|Mount Removable Auto Mount|Ignore No Policy The policy of a device can be seen by selecting Properties for the device and observing the value of 'presentation nopolicy:' in the INFO section. To ignore UDISKS_PRESENTATION_NOPOLICY for a specific device, use Mount|Volumes. Auto Mount|Mount Volumes Mount Volumes opens a dialog which allows you to specify device files, volume labels, or device IDs in a space-separated list. There must be a space between entries and a plus or minus sign directly before each item. This list is case-sensitive. For example, to force auto-mounting of device /dev/sdc1, include:
Or, to inhibit auto-mounting of /dev/sdc1, include:
The '/dev/' portion of the device file MUST be included. Devices can also be identified by volume label. For example, to inhibit auto-mounting of a device with volume label "Label With Space" use:
DO NOT use quotes to enclose the label, even if it contains spaces. Finally, a device's ID may be used:
For example, this list in Mount Volumes:
would cause /dev/sdc1 and the OCZ device to be auto-mounted, and the volume with label "Label With Space" to not be auto-mounted. Auto Mount|Mount Dirs The following variables are recognized and will be replaced with their current value: $USER $UID $HOME $XDG_RUNTIME_DIR $XDG_CACHE_HOME Note that some handlers or mount programs may not obey this setting. It will only be used by handlers which use %a in their mount or open commands. Anytime a device, protocol or file handler uses %a to automatically create a mount point, the specified directory will be used as the parent. This applies to both manual and automatic mounts. Note that empty subdirectories will be routinely and automatically removed from the specified directory. Auto Mount|Open Tab Note that the Open Tab option only affects what happens after a device is auto-mounted by SpaceFM. It has no effect on devices mounted by other means, nor does it apply to devices mounted by user action within SpaceFM. Auto Mount|Unmount On Exit When mounting a device, if there is no fstab entry for the device, your mount program may create a subfolder for the device mount point in /media or /run/media/$USER. If you or SpaceFM unmounts the device, this subfolder will be removed. However, if you logoff without unmounting the device, the subfolder may be left behind. In order to avoid these subfolders accumulating in /media, SpaceFM can unmount devices on exit. If you don't check option Unmount On Exit, you may need to unmount devices in some other way before logging off to avoid these /media subfolders accumulating. Auto Run|On Mount
Note: When the command is run, %v, %l, and %m refer to the device being added or removed, not the device which is currently selected in the Devices list. For this command to be run, the device must be auto-mounted by SpaceFM. It will not be run for devices mounted by other means, or for devices mounted by user action within SpaceFM. The command will not be run for devices which are auto-mounted at SpaceFM's initial startup. Thus Auto Run affects devices you add after SpaceFM is running. For additional information on what the volume monitor is doing, try running SpaceFM in a terminal. Information on devices being auto-mounted will be printed to the terminal, and error messages generated by your command may be seen there as well. For example, to automatically add a mounted volume to traydevice, set the On Mount command line to: traydevice %v Another example: To have notify-send alert you of new drive mounts: notify-send --icon=block-device --urgency=low "Volume %l has been mounted" Auto Run|On Audio CD The command will be run only if: a) option Mount Optical is checked, AND b) the device qualifies for auto-mounting based on Mount Volumes (ie it is not inhibited). The command will not be run for media which is already inserted during SpaceFM's initial startup. Thus Auto Run|On Audio CD affects media you insert after SpaceFM is running. For example, to set an audio CD to automatically start playing in the vlc media player, set the On Audio CD command line to: vlc --verbose=-1 cdda://%v Auto Run|On Video DVD The command will be run only if: a) the device is auto-mounted by SpaceFM, AND b) the device contains a video DVD. The command will not be run for devices which are auto-mounted at SpaceFM's initial startup, nor will it be run for devices mounted by other means, nor for devices mounted by user action within SpaceFM. For example, to set a video DVD to automatically start in the vlc media player, set the On Video DVD command line to: vlc --verbose=-1 dvd://%v Auto Run|On Insert Auto-mount settings have no impact on this function. Note that when inserting a single drive, your command may be run several times - once for each device file added. For example, if you insert device /dev/sdd which contains one partition /dev/sdd1, your command will be run once with %v=/dev/sdd and once with %v=/dev/sdd1. It is up to your command or script to discard events for unwanted devices or partitions. A script can run one of these commands to get current information on a device's status: udevil info /dev/sdX udisks --show-info /dev/sdX udisksctl info -b /dev/sdX For greater control, an event handler may be set for event evt_device. Auto Run|On Unmount Auto-mount settings have no impact on this function. For example, to automatically remove the drive from traydevice, set the On Unmount command line to: pkill -f "traydevice %v" For greater control, an event handler may be set for event evt_device. Auto Run|On Remove The device must be removed. Ejection of media will not cause this command to be run. Auto-mount settings have no impact on this function. Note that when removing a single drive, your command may be run several times - once for each device file removed. For example, if you remove device /dev/sdd which contains one partition /dev/sdd1, your command will be run once with %v=/dev/sdd and once with %v=/dev/sdd1. It is up to your command or script to discard events for unwanted devices or partitions. Note that when the command is run, %v equals the device file which has been removed, not the device file which is selected in the Devices list. For greater control, an event handler may be set for event evt_device. Device Handlers Protocol Handlers Mount Options In addition to regular options, you can also specify options to be added or removed for a specific filesystem type by using the form OPTION+FSTYPE or OPTION-FSTYPE. For example, this set of options:
will add nosuid and noatime for all filesystem types, add sync for vfat and ntfs only, and remove noatime for ext4. Note that only handlers which use the %o substitution variable will use options specified here. They will not apply to mounts performed by other handlers. Note that some options, such as nosuid or noatime, may be added by your mount program even if you don't include them. For example, if using udevil, you may need to also change the default options in /etc/udevil/udevil.conf. Also, options specified in /etc/fstab may take precedence over options specified in Mount Options. pmount does not support conventional mount options, so when using pmount as the mount command, options set here will be ignored. Instead, you can include pmount's command line options in the appropriate Device Handler. Change Detection When SpaceFM opens a directory in a tab, normally it will detect changes, for example if you edit or change the properties or sizes of files in the directory. Because SpaceFM works directly with the kernel for file information, and because some network filesystems become temporarily unresponsive when busy, this can cause SpaceFM to become temporarily unresponsive to mouse clicks, etc. To prevent this, the device's filesystem can be listed in the Change Detection Blacklist. In this case, SpaceFM will not detect changes to files, load thumbnails, or load subdirectory sizes, and you will need to manually refresh the file list view to see file changes. To do so, right-click on the file list and select View|Refresh, or press F5. Note that even if the filesystem is listed in Change Detection, new files created in the directory, or files which are renamed or deleted, will be detected and read. An alternative approach to blacklisting filesystems is to close the tab containing the filesystem while a copy is in progress to that directory. Single Click New Tab Icon By default, SpaceFM reuses a limited number of icons so that only stock GTK icons are required. If you would like the device icons to better reflect the changing state of devices, it is valuable to customise these icons. Font | ||||||||||||||||||||||||||||||||||||
Contents
|
How To Enable Kernel Polling
You may need to enable kernel polling for device media changes to be detected by SpaceFM. For example, if you insert a CD and SpaceFM still says 'no media', this is a symptom that kernel polling is not enabled. Kernel polling is a newer feature of the Linux kernel and udev, so some distros don't yet have it enabled by default. To use kernel polling, your Linux kernel may need to be 2.6.38 or newer, and udev may need to be version 173 or newer. To determine if kernel polling is enabled: cat /sys/module/block/parameters/events_dfl_poll_msecs cat /sys/block/sr0/events_poll_msecsIf you get 0 or -1 from both of those commands, kernel polling may be disabled. To enable kernel polling permanently (survives a reboot), add the following command to your /etc/rc.local file (anywhere before the 'exit' line in that file): echo 2000 > /sys/module/block/parameters/events_dfl_poll_msecsAny number between 2000 and 5000 (milliseconds) should be reasonable - the higher 5000 means poll every 5 seconds, which is less overhead but a little slower. OR pass this option to the kernel boot command line in grub: block.events_dfl_poll_msecs=2000 OR add a udev rule to enable kernel polling on removable devices:
A reboot will be required for the above changes to take effect, or... To enable kernel polling temporarily and immediately, enable common polling for the block module: sudo bash -c 'echo 2000 > /sys/module/block/parameters/events_dfl_poll_msecs' OR you can enable polling just for a single device like this (/dev/sr0 in this example): sudo bash -c 'echo 2000 > /sys/block/sr0/events_poll_msecs'This change should be immediate - media will be detected. However, the above change will be lost when you reboot. References: | ||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
Contents
|
Task Manager
Each SpaceFM window includes a single Task Manager which centrally manages the tasks of all panels in the window. The Task Manager is designed to eliminate annoying popup dialogs which interfere with user multi-tasking, and allows you to continue working while large files are being copied, etc. The Task Manager lists running tasks, automatically manages the task queue, allows you to stop, pause, queue, or resume tasks manually, and opens popup dialogs. Like most parts of SpaceFM, the Task Manager can also be customised with your own commands to control or interact with running tasks. A task is a job initiated by the user, such as copying a file. Tasks come in two varieties: internal and exec. Internal tasks handle built-in functions such as a copying, moving, and deleting files, while an exec task runs an executable or script, either initiated from within SpaceFM's built-in functions (such as running udevil to unmount a device) or from a custom command. The output of exec tasks is also collected and shown in the popup dialog's output monitor. The Task Manager is located at the bottom of the SpaceFM window, below all panels. It has two display modes: Show and Auto-Hide. If option View|Task Manager|Show Manager is selected, the Task Manager is always visible, even when no tasks are running. Or, if option View|Task Manager|Auto-Hide Manager is selected (the default), the Task Manager will become visible when tasks are running, and will be automatically hidden from view when the last task completes. The size of the Task Manager may be adjusted by dragging the pane separator above it. When a task is initiated in any panel and runs for longer than about one half second, it will be listed in the Task Manager, and the Task Manager will be shown if in Auto-Hide mode. If a task finishes in less than about one half second, the task will not be listed. New tasks are added to the end of the task list. When a task completes (successfully or with errors), it is immediately removed from the list. Task Manager columns provide information on each task, and each column can be hidden or moved, allowing you to control what information is shown. A single left-click on a task in the list, anywhere except in the Status column, will open a popup dialog showing the task's stats, a progress bar, and an output monitor. For internal tasks (copy, move, etc), the output monitor is used to show errors. For exec tasks, the output monitor shows the combined stdout and stderr output of the command as its produced. A single left-click on the Status of a task, or a middle-click anywhere on a listed task will change its state (running, queued, or paused). Click repeatedly to achieve the desired state. A right-click on a task shows the Task Manager's menu, which allows you to stop, pause, queue, and resume tasks, and also contains options for the Task Manager. (These same options may also be accessed via the main menu bar's View|Task Manager submenu.)
| ||||||||||||||||||||||||||||||||||||
Contents |
Queue
Each task listed in the Task Manager may be in one of three states: running, paused, or queued. A running task is currently executing - files are being copied, or an executable is running, etc. A paused task has been halted. For internal tasks such as copy and move, the task thread is halted until you resume the task. For exec tasks (eg a custom command running an executable, or SpaceFM running udevil to unmount a device), the process has been sent a SIGSTOP signal as described in Pause. A queued task is also halted. The only difference is that the Task Manager will automatically resume running a queued task when other tasks complete, whereas a paused task will never resume automatically. A task's state (running, paused, or queued) can be changed by the user, and in some cases may be changed automatically. Simply, the queue is used to prevent all tasks from running simultaneously, which can impact performance. For example, copying two sets of files to the same drive simultaneously is often slower than first copying one set, then the other (due to drive seeking and other issues). Thus it may be desirable to queue the second task, so it will remain halted until the first task is completed. If option View|Task Manager|Queue|Queue New Tasks is checked (the default), new tasks are automatically queued when initiated, rather than run immediately. SpaceFM will automatically determine when to resume the queued tasks, depending on option View|Task Manager|Queue|Smart Queue. Or, you can always manually Resume, Pause or Stop a task to remove it from the queue.
| ||||||||||||||||||||||||||||||||||||
Contents |
Menu
The Task Manager's context menu allows you to control tasks and set Task Manager options. The menu is opened by right-clicking on the list. The options found on this menu are also available in the main menu bar's View|Task Manager submenu (convenient if the Task Manager is hidden). The context menu contains the following items: Stop If the task is an exec task (eg a custom command running an executable, or SpaceFM running udevil to unmount a device), the process, and all its child processes, are sent a SIGTERM signal. This will usually cause the processes to terminate, but not always. So SpaceFM will also send a SIGKILL signal to all the processes several seconds later. An exec task will not be removed from the Task Manager until its process terminates. This means that if a process is hung and cannot be stopped with SIGKILL, selecting Stop may have no effect. If the command was run as another user, such as root, selecting Stop will cause a prompt for the user's password (or root's password depending on your configured su program) to open. This password is required to send the SIGTERM and SIGKILL signals to the process running as another user. (You can see the exact commands being issued by running SpaceFM from a terminal and observing its stdout output.) Paused and queued tasks may also be stopped. You can also stop a task by clicking the Stop button in the task's popup dialog. Pause If the task is internal (such as copying files), SpaceFM will suspend the task thread. Any files currently being read or written will remain open as long as the task is paused. If the task is an exec task, the process, and all its child processes, are sent a SIGSTOP signal. This is similar to pressing Ctrl+S in a terminal while a command is running; it will often cause the process to temporarily halt execution. In some cases, a process will not halt on a SIGSTOP signal, but the Task Manager will still list it as being in a 'paused' state until you Resume the task. If the command was run as another user, such as root, selecting Pause will cause a prompt for the user's password (or root's password depending on your configured su program) to open. This password is required to send the SIGSTOP signal to the process running as another user. (You can see the exact commands being issued by running SpaceFM from a terminal and observing its stdout output.) If you change the menu icon for Pause, the new icon will also be used as the 'paused' icon in the task list. You can also pause a task by clicking the Pause button in the task's popup dialog, left-clicking on the Status of a task in the Task Manager list, or by middle-clicking on a task in the list. Queue Note that selecting Queue on a running task may seem to have no effect. This is because the task may be queued, but then may automatically be removed from the queue and resumed by the Task Manager. There is no way to force a task to stay in the queue (but you can Pause it). If you change the menu icon for Queue, the new icon will also be used as the 'queued' icon in the task list. You can also queue a task by clicking the Queue button in the task's popup dialog, left-clicking on the Status of a task in the Task Manager list, or by middle-clicking on a task in the list. Resume If the task is an exec task, the process, and all its child processes, are sent a SIGCONT signal. This is similar to pressing Ctrl+Q in a terminal after a command has been halted with Ctrl+S. If the original SIGSTOP halted the execution, SIGCONT should resume it. If SIGSTOP did not halt execution, SIGCONT will generally have no effect, except that the Task Manager will now list the task as 'running'. If the command was run as another user, such as root, selecting Resume will cause a prompt for the user's password (or root's password depending on your configured su program) to open. This password is required to send the SIGCONT signal to the process running as another user. (You can see the exact commands being issued by running SpaceFM from a terminal and observing its stdout output.) You can also resume a task by clicking the Resume button in the task's popup dialog, left-clicking on the Status of a task in the Task Manager list, or by middle-clicking on a task in the list. Tasks may also be resumed automatically by the Task Manager if they are queued. Show Output Note that any custom menu items added directly after Show Output will also only appear for tasks with a custom popup handler. All Tasks Selecting All Tasks|Queue will place all tasks in the 'queued' state momentarily, but note that one or more of the tasks may then be automatically removed from the queue and resumed. Show Manager This option is also available via the main menu bar's View|Task Manager submenu. You may also associate a key shortcut with it. Auto-Hide Manager Although there is no option to hide the Task Manager while tasks are listed, you can effectively hide it if desired by dragging the pane separator to the very bottom of the window. However, if you do so you should enable option View|Task Manager|Popups|Popup All Tasks, so that you are aware that tasks are running. This combination of a zero-height Task Manager and Popup All Tasks makes SpaceFM behave like a conventional file manager, showing a popup dialog when performing a task, rather than showing a list of tasks. You can also enable option View|Task Manager|Popups|Stay On Top if desired. Columns
The current item refers to the file currently being processed in the task (copied, etc). For exec tasks, the Item column shows the name of the command in parentheses. The Status column, which shows the task icon, current state (queued or paused) and task action (copying, moving, etc.), is not included in the Columns submenu because its visibility not optional. The Reorder menu item shows a reminder: "To change the order of the columns, drag the column header to the desired location." The Font menu item allows you to set a font for the Task Manager's list columns. Narrow fonts work well. Note: The Columns submenu, and other Task Manager options, can also be found in the main menu bar's View|Task Manager submenu. Popups|Popup All Tasks If option Popup All Tasks is unchecked, a popup dialog will open for an internal task only if an error occurs. For custom commands, the popup behavior will depend on the command's popup settings. Note that if Popup All Tasks is checked, this overrides the command's popup settings. Popup All Tasks makes SpaceFM behave like a conventional file manager with regard to progress dialogs. If the option is enabled, it is also feasible to effectively hide the Task Manager by dragging the pane separator to the very bottom of the window when unneeded. You will still be aware of tasks running due to the popups. Option Stay On Top also works well with this approach. Popups|Stay On Top If unchecked, popup dialogs may be placed beneath the main window. Popups|Above Others Popups|All Workspaces Popups|Detailed Stats If unchecked, a brief stats line is shown. For example: Progress: 204 M / 350 M (26 M/s) :05 remainingIn the above example, 204 MB of 350 MB has been processed at an average speed of 26 MB/s. The estimated time remaining until the task finishes is 5 seconds. If option Detailed Stats is checked, more detailed stats are shown. For example: Progress: #1 (204 M / 350 M) [:08] @cur 31 M/s (:06) @avg 26 M/s (:05)The additional stats include the item count (#1), the elapsed running time of the task (8 seconds), the current speed of the task (31 M/s), and the estimated time remaining at the current speed (6 seconds). The current speed is measured based on the speed over the previous two second interval, whereas the average speed is based on the entire time the task has been running. The current speed is a more accurate measure of what is happening right now, and will fluctuate more, while the average speed is a better measure of the overall performance. The time remaining estimate based on the current speed shows how long the task will continue if it continues at the current speed. The time remaining estimate based on the average speed tends to be a more accurate estimate in general. The information shown in the 'Progress:' line will match the information shown in the corresponding Task Manager columns. Popups|Overwrite Option Popups|Error Option Popups|Font This font may also be set by right-clicking on the output monitor of any task's popup dialog and selecting Font from the context menu. The dialog font you select will be used for new dialogs only; currently open dialogs will not be affected. (You can close a dialog and re-open it to see the change.) Errors If option Stop If Error First is selected (the default), the task will be stopped by the Task Manager if an error occurs AND that error is encountered before the task has successfully processed one file. If an error occurs on later files in the task, the Task Manager will open a popup dialog to show the error, but subsequent actions in the task will continue to run. For example, if there are more files to be copied, SpaceFM will attempt to copy them despite any errors on previous files. Stop If Error First is provided as a convenience option. Usually if the first action of a task fails, the rest of the task will fail as well, so it might as well be stopped rather than producing a long list of errors for every file in the task. If option Stop On Any Error is instead selected, the Task Manager will stop if any error is encountered in the task, regardless of whether the error occurs on the first or later actions. If option Continue is selected, the Task Manager will never stop an internal task due to errors. It will present the popup dialog on each error, and will list the errors in the output monitor, but subsequent actions in the task will continue. For example, if a set of files is being copied, and only one file in the middle produces a copy error, all the other files will still be copied. The popup dialog will show the error(s) for the file(s) which failed. Continue is especially useful when copying large sets of files. If the task stops on errors, you might start the task and leave the computer, only to return to find that only a few files were copied before a single error stopped the entire task. If the task continues on errors, you'll return to find all the files copied except those with errors. You can then correct the problem files without having to restart and wait for the entire task again. You can also change the error mode on a per task basis if View|Task Manager|Popups|Error Option is checked. Queue|Queue New Tasks If unchecked, new tasks are always run immediately, even if other tasks are already running, and the Task Manager will never automatically queue any task. Regardless of how Queue New Tasks is set, you can always manually Queue, Pause or Resume any task. Queue|Smart Queue If option Smart Queue is checked (the default), the Task Manager is more sophisticated in its handling of the queue to improve both performance and convenience. In general, tasks will not be run concurrently, but the following exceptions may be made if Smart Queue is checked: Different Disks Exception To determine what devices a task involves, SpaceFM makes a list of all devices (and their parent devices, if the device is a partition) holding every file in the task, as well as the device of the destination directory, if applicable. If any devices in this list are the same as the devices in another task's devices list, the two tasks conflict and will not be run concurrently. Note that if the files of two tasks are located on different partitions on the same disk, they will conflict, and only one of the tasks will run. Note that all of the devices of the task are examined when a queue decision is made, not just the device of the file currently in use by the task. The reason for this exception is that if two tasks involve mutually exclusive disks, there is usually much less of a performance loss by running them together. On the other hand, if two tasks share files on the same disk, running them together may cause excessive drive seeking as different files are concurrently read and written. Thus no exception is made for such tasks, and only one is resumed at a time. Size Exceptions When a task involves copying or moving a set of files less than 10 MB in total size, an exception is made which allows the task to run immediately, even if other tasks are running on the same devices. An exception is also made when a task involves deleting a set of files less than 5 GB in total size. This allows small tasks to run immediately. Functional Exceptions Also note that you can always manually Queue, Pause or Resume any task, regardless of the Task Manager's queue settings. For example, if you want a task to run immediately even though the Task Manager made no exception for it, you can Resume it yourself. HAL NOTE:: If you are using a copy of SpaceFM built with configure option --enable-hal, or a HAL-based SpaceFM package, option Smart Queue will be unavailable. Queue|Pause On Error The paused tasks will not resume until you manually resume them. Pause On Error is something of a paranoia setting - it ensures that if an error occurs, later tasks (which may depend on files in the task with errors) are suspended until you can examine the problem. Custom Menus There are several provided bash variables which your commands can use to get information about the currently selected task: "fm_task_type" currently SELECTED task type (eg 'run','copy') "fm_task_name" selected task name (custom menu item name) "fm_task_pwd" selected task working directory ( same as %t ) "fm_task_pid" selected task pid ( same as %p ) "fm_task_command" selected task commandNote that the PID of the task refers to the initial process started by SpaceFM. The actual process you want to control may be a child of this PID. For example, to add a custom command which opens the working directory of the currently selected task, use this command line: spacefm "$fm_task_pwd" | ||||||||||||||||||||||||||||||||||||
Contents
|
Popup Dialog
A single left-click on a task listed in the Task Manager will open a popup dialog showing stats, a progress bar, and an output monitor. Popup dialogs may also be automatically shown when errors occur, if option View|Task Manager|Popups|Popup All Tasks is checked, or based on a custom command's popup settings. The popup dialog's relationship to other windows may be controlled with options View|Task Manager|Popups|Stay On Top, Above Others, and All Workspaces. For internal tasks, the popup dialog will show the task's job ("Copy", etc), the current file being processed, the destination directory, brief or detailed stats, the status of the task ("Paused", etc), a progress bar, an output monitor used to show the details of any errors which have occured, and overwrite and error mode controls. If View|Task Manager|Popups|Overwrite Option is checked and the task is internal, the popup dialog will show a drop-down list which displays and allows you to change the overwrite mode of the task (what happens when a file being copied already exists): Ask (prompt to rename, overwrite, or skip each file), Overwrite All (overwrite all files), Skip All (never overwrite files), or Auto Rename (assign a unique filename). Clicking the Overwrite All, Skip All, or Auto Rename All button in an overwrite query dialog will also change the overwrite mode. Note that the overwrite mode you set only applies to future file conflicts in the current task. If View|Task Manager|Popups|Error Option is checked and the task is internal, the popup dialog will show a drop-down list which displays and allows you to change the error mode of the task: Stop If Error First, Stop On Any Error, or Continue. When the task first starts, the error mode will match the default set in View|Task Manager|Errors. If you then change the error mode, it will apply to the current task only. For exec tasks, the popup dialog will show the title of the command being run, the task's status, a pulsing progress bar, and an output monitor showing any output from the command. The output monitor is designed to display text output to be used for monitoring the output of commands as they run, or to display a final result. However, the output monitor is not a terminal and does not allow you to enter input. If your command requires interaction, you will need to enable Run In Terminal instead. Custom commands can also set a custom popup handler to replace the normal popup dialog. To close the dialog, press the Close button or close the window. You can always re-open the dialog by clicking on the task in the Task Manager. To permanently stop a task, click the Stop button. This is equivalent to selecting Stop in the Task Manager menu. The third button in the dialog will change depending on the state of the task. If the task is running, the button will be a Pause button; if the task is paused, the button will become a Queue button; and if the task is queued, the button will become a Resume button. Pressing this button is equivalent to selecting Pause, Queue, or Resume in the Task Manager's context menu.
| ||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
Contents
|
Introduction
SpaceFM's Design Mode allows you to change the name, shortcut key and icon of menu, toolbar and bookmark items; access help for an item; and set menu items to be disabled or hidden based on your context rules. You may add custom commands, applications, bookmarks, and submenus to any position in menus and toolbars, and save your custom items as plugins. Custom items can be cut/copied/pasted from/to bookmarks, toolbars, and menus. All of this is controlled from the Design Menu. To open the Design Menu, simply right-click on a menu item, bookmark, or toolbar item. The Design Menu is available for most menus in SpaceFM, including in the right-click menu of the desktop. To open the Design Menu using a shortcut key, press F2 while a menu item is highlighted. To open the Design Menu for a submenu, first close the submenu (by clicking on it), then right-click on the submenu name. Or, press F2 while the submenu is highlighted. While Design Mode works in almost all menus, a good place to practice is the Tools menu, which is reserved for your custom menu items. When working with Design Mode, it is important to distinguish between two types of items: built-in and custom. Built-in items, such as Rename on the file list context menu, are part of the SpaceFM program, whereas custom items are items you have added. Design Mode can be used on both types of items, but in different ways. For example, custom items can be removed, while built-in menu items cannot (although they can be hidden). You will note that some of the Design Menu's functions will be disabled or enabled depending on the type of item. Custom items in SpaceFM are like word processor macros - they allow you to automate tasks. You might create a quick custom item just for today's use and delete it when you're done, while other items may become a regular part of your file manager use. Custom items come in several varieties: a Bookmark (which opens a folder, group of folders, URLs, or mounts a device), an Application (which starts an application or runs an executable), a Command (which runs a command line or script), a Separator (a line separating items in a menu or toolbar), and a Submenu (a menu containing more custom items).
| ||||||||||||||||||||||||||||||||||||
Contents
|
Design Menu
When you right-click on a menu item, bookmark, or toolbar item, or press F2 while a menu item is highlighted, you will be presented with a menu which gives you extensive control over how the item is displayed and performs. TIP: For help with a menu item in the Design Menu itself, highlight the Design Menu item and press F1. Cut Cut cuts the current item onto the design clipboard. This will not affect the contents of your main (text & files) clipboard. You will not observe any change in the menu after cutting an item - until you paste it. You cannot cut built-in items (except on the toolbar), only custom ones. You can cut and copy submenus, which copies all the items within the submenu recursively. You can also cut a menu item using a design mode shortcut instead of the Design Menu. Highlight the menu item and press Ctrl+X, or use the mouse shortcut Alt + Left-or-Right-Click. Copy Note: When copying an item of type Bookmark, the bookmark target will also be copied to the text and primary clipboards. You can also copy a menu item using a design mode shortcut instead of the Design Menu. Highlight the menu item and press Ctrl+C, or use the mouse shortcut Ctrl + Left-or-Right-Click. Paste For example, to move a custom menu item named 'Test' from the Tools menu to the file list's context menu: Open the Tools menu and right-click on 'Test' to open the Design Menu. Select Cut. Now right-click on the file list and right-click on a menu item, such as 'Rename'. Select Paste in the Design Menu. Right-click again on the file list and you will see your 'Test' command has been moved from the Tools menu and has been placed immediately after the 'Rename' item. When copying a custom item, note that everything contained in the item is copied, including any command script, extra files you added to the command or data directories, settings, etc. You can also copy plugins from the Plugins menu (although you cannot cut them). When a plugin, which is root-installed and -protected, is copied, the copy is no longer protected by root. The copy is now a custom item which you can alter in any way. Copying a plugin provides a means of changing and customising it. It can also then be exported and reinstalled as a plugin. See the Plugins section for details. Paste, Cut, and Copy can also be used on the separators between items. To move a custom item to directly after a separator, copy the item to the Design Menu, right-click on a separator, and select Paste. You can also cut, copy, and paste the separators themselves, providing they are not built-in. You can also paste a menu item using a design mode shortcut instead of the Design Menu. Highlight the menu item and press Ctrl+V, or use the mouse shortcut Shift + Left-or-Right-Click. Remove Unless you have unchecked option View|Preferences|Interface|Confirm delete/remove, you will be presented with a confirmation dialog before the item is removed. IMPORTANT: When a custom item is removed, all files and settings are deleted, including any extra files you added to the command directory, any files stored in the command's data directory, and the command script. When a plugin is uninstalled using Remove, the plugin is removed for all users, and all settings, files and plugin-data for the plugin are deleted. WHEN REMOVING A SUBMENU, all commands and submenus contained within it are deleted as described above. Note that a submenu in SpaceFM can never be empty. As a result, if you remove the last item from a submenu, a new custom item named "New Command" or a default bookmark will automatically be added to it. You can also remove a menu item using a design mode shortcut instead of the Design Menu. Highlight the menu item and press the Delete key, or use the mouse shortcut Ctrl + Shift + Middle-Click. Export Once your item has been exported to a plugin file, the file can then be used to import the item back into either the Plugins menu or another menu or toolbar, or can be shared with other users of SpaceFM. Exporting also provides a mechanism for backing up custom items - the plugin file acts as a backup copy of your item which can always be imported into any SpaceFM session. When using export on a plugin, a new plugin file is created - generally this creates a copy of the original plugin (unless you modified the installed plugin files as root). You can also export a group of custom items into one plugin file by exporting a custom submenu, which means the plugin file will contain all items and submenus contained in the submenu. This provides way to share multiple related plugins in a single plugin file. For more information on plugins, please see the Plugins section. New|Bookmark New|Bookmark adds a new custom item of type Bookmark after the current item. You will be prompted to select a single target folder, and the Bookmark item will be added. To make further changes to your Bookmark item, right-click on it and select Properties. A Bookmark item's target may be a single folder to be opened when you activate the item, or it can be a semicolon-separated list of target folders, URLs, or devices. Bookmarks in SpaceFM may be placed into any menu or toolbar, not just the Bookmarks menu. New|Application New|Command The command line accepts anything you would normally enter in a bash command line. It can be as simple as a program's name you want to run when this menu item is selected, or may include multiple lines and variables. For more information, please see the Command page. For example, right-click on a menu item and select New|Command. Enter 'Current Time' for the item name. For the command line, enter: date And click OK. When you click the new 'Current Time' menu item, a dialog will open showing you the current date and time. You can also add a new Command menu item using a design mode shortcut instead of the Design Menu. Highlight the menu item where you want to insert the new Command item, and press the Insert key, or use the mouse shortcut Ctrl + Shift + Left-or-Right-Click. New|Submenu New|Separator New|Import When imported into other menus, a plugin loses root protection and becomes a normal custom item. Add Tooltips Help Your browser may be customised in Help|Options|Browser, and a custom location for the user's manual can be set in Help|Options|Manual Location. For custom items, including plugins, Help will open the plain text README file for the item in your text editor. If no README file exists for a custom menu item, selecting Help will create one for you to edit. This file may also be named 'README.mkd' or 'README.txt'. You can also open help for a menu item using a design mode shortcut instead of the Design Menu. Highlight the menu item and press F1, or use the mouse shortcut Alt + Middle-Click. F1 may also be used from within the Design Menu itself to show help for a Design Menu item. Key Shortcut After you have set a key combination, when you reopen the menu the new key shortcut will be displayed in the menu. TIP: To use only the keyboard in the Set Key dialog, press a key combination and then press Enter to click the Set button. Or, to click Unset, press the Escape key twice. To cancel, simply close the dialog (usually Alt-F4). NOTE: Due to SpaceFM's literal use of keycodes, turning Caps Lock on or changing your keyboard layout may cause some key shortcuts to not respond. For example, pressing Ctrl+C with Caps Lock on will not activate 'Copy' because the 'C' key returns a different code than with Caps Lock off. Also note that some keycodes for non-Latin keyboard layouts are converted to their approximate Latin equivalent [SpaceFM 1.0.3 and later]. If such a conversion is made, the original keycode will be shown in square brackets. You can also change the key for a menu item using a design mode shortcut instead of the Design Menu. Highlight the menu item and press Ctrl+K, or use the mouse shortcut Ctrl + Middle-Click. Edit Command You can also edit an item's command line using a design mode shortcut instead of the Design Menu. Highlight the menu item and press F4 or Ctrl+E, or use the mouse shortcut Middle-Click. Edit Script You can also edit an item's script using a design mode shortcut instead of the Design Menu. Highlight the menu item and press F4 or Ctrl+E, or use the mouse shortcut Middle-Click. Properties You can also open Item Properties for a menu item using a design mode shortcut instead of the Design Menu. Highlight the menu item and press F3, or use the mouse shortcut Ctrl + Alt + Middle-Click.
| ||||||||||||||||||||||||||||||||||||
Contents
|
Properties
The Item Properties dialog allows you to view and change the properties of built-in or custom menu and toolbar items. To open the dialog, right-click on a menu item, toolbar item, or bookmark and select Properties, or highlight a menu item and press F3. Type The Type drop-down list shows the current type of the item: Built-In Command, Bookmark, Application, Command, Submenu, or Separator. If the type is Bookmark, Application or Command, you can change the type by selecting another type from the list. An item's type determines what properties you can view and change, and how the item appears and behaves. Name Note: In GTK >= 3.10, you must press the Alt key to see the mnemonics underlined. For items of type Bookmark, the Name entry may be left empty, in which case the target of the Bookmark will be displayed as the item name. For items of type Application, the Name entry may also be left empty, in which case the application's name (derived from the .desktop file's Name= key), or the executable's name will be displayed as the item name. Key You can also change the key for an item using a design mode shortcut instead of the Design Menu. Highlight the menu item and press Ctrl+K, or use the mouse shortcut Ctrl + Middle-Click. Icon For best results, use an icon name or stock name so that the icon can be automatically sized. When using an absolute path, the icon may not be sized correctly. Due to various issues, not all icons may work. If an icon fails to load, you will see a broken icon image instead. If successful, the icon will appear in the menu next to the menu item, and will also be used in the task list when a command is run. To remove an icon, simply clear the text box where the icon name is entered and click OK. (For plugins, clearing the box will show the default icon for the plugin, if any.) To browse the available icons on your system, open /usr/share/icons/. When you enter an icon name, GTK will search there for an appropriate icon, and will also search ~/.icons/ and ~/.local/share/icons/. For items of type Bookmark, if no icon is specified, the default icon is used, set by right-clicking on the Bookmarks side pane and selecting Settings|Bookmark Icon. For items of type Application, if no icon is specified, the application's icon (derived from the .desktop file's Icon= key) will be displayed as the item icon. You can also change the icon for an item using a design mode shortcut instead of the Item Properties dialog. Highlight the menu item and press Ctrl+I, or use the mouse shortcut Shift + Middle-Click. Target Bookmark Targets
/etc; /usr/bin; ftp://mirrors.kernel.org; /dev/sr0When the above example is activated, four tabs will be opened: two containing /etc and /usr/bin; the ftp site will be mounted and opened in a third tab; and the disc in /dev/sr0 will be mounted and opened in the fourth. When the Targets list contains a single folder or URL, whether it is opened in a new tab or in the current tab is determined by the New Tab setting for bookmarks, found by right-clicking on the Bookmarks side pane and selecting Settings. If the Targets list contains multiple paths or URLs, each is opened in a new tab. Finally, the Targets list for a Bookmark may contain the path to a file, in which case the directory containing the file will be opened, and the file will be selected in the file list. For example: /etc/fstabClicking the Browse button will allow you to select a folder which will be added to the Targets list. Tip: To prevent the Bookmarks side pane's Follow Dir option selecting a particular bookmark automatically, prefix the targets with a semicolon and Follow Dir will ignore it (only the first target is used by Follow Dir). For example: ;/etc Application Target
When specifying an executable file, note that selected filenames will NOT be passed to the executable when it is run. (To do so, use a menu item of type Command.) When specifying a .desktop file, what is passed to the command is determined by the substitution variables in the Exec= key of the .desktop file. When specifying a .desktop file, it is generally recommended to leave the Name and Icon fields empty so the .desktop file's values are used automatically. Clicking the Browse button will allow you to select an application from a list of applications installed on your system. NOTE: When exporting an item, the target field will be exported with the plugin even if Bookmark or Application is no longer the selected item type. Before distributing a plugin, be sure to open or extract the archive and examine all files in your text editor to be clear on what data you are sharing. Context Context refers to the state of the entire file browser window or desktop when a menu is shown. For example, the MIME type of the currently selected file is one subject of the context. Another context subject is the filename of the selected file. Another is any device that is currently selected in the Devices list. There are many subjects which can be used in context rules. By default, the top line of the context dialog reads "Show item if context matches any rule:", and is followed by an empty rule box. When the rule box is empty, the item will always be shown regardless of context. You can change 'Show item if context matches any rule:' to 'Enable item if context matches any rule:'. If the action is to 'Show', its opposite is to hide. If the action is to 'Enable', then its opposite to disable. Thus if we change the top line to read 'Enable item if context matches any rule:', then the menu item will be enabled or disabled depending on context, but will never be completely hidden from view in the menu. Or, to reverse the logic, action can be set to 'Hide' or 'Disable' when any rule is matched. The 'matches any rules:' box can also be changed so that it requires all rules to be matched instead of just one. This is like putting an AND between the rules, instead of OR. Or you can reverse the matching logic by choosing one of the 'doesn't match' options. Composing Rules
The box to the right of the subject allows you to choose a verb, or a relationship between the subject and its value. In the case of "matches" or "doesn't match", wildcards may be used (eg "Filename matches *.jpg"). If the test pattern contains any uppercase characters, the test is case-sensitive. For additional wildcard characters and pattern specifics, see IEEE Pattern Matching Notation. The box below the subject and verb will contain the value to be used as a test. You can enter custom text in this box or click the arrow at the right to select a common value. Each subject chosen will have a different list of common values. Below the value box is a 'Value:' label, which may or may not show a value. This label shows the subject's value in the current context. When you opened the Design Menu, the file browser had a context - perhaps some files or a device were selected, the browser was in a particular directory, etc. For example, if a file is selected when you open the properties dialog, and the subject is set to 'MIME Type', then the selected file's MIME type will appear next to 'Value:'. If no file is selected, then 'Value:' will show nothing. (Tip: You can quickly copy a value into the value box by double-clicking it.) The context dialog will let you know the result of the current set of rules given the current context. Below the rules box to the right, you will see a 'Current:' label. For example if it reads "Current: Show", then for the current context and set of rules, this menu item will be shown in the menu. If instead it reads "Current: Hide", then the menu item will be hidden from view for the current context - it will not appear in the menu. An Example Set Of Rules
For this example, set the rule subject to 'MIME Type' and set the verb (the box to the right of subject) to 'begins with'. Below these, choose 'audio/' from the drop-down list of common values. Now the words in the Edit Rule box should read 'MIME Type... begins with... audio/'. To add this rule to the rule box above, click the Add button. 'MIME Type begins with audio/' will be added to the list of rules. For this rule to be satisfied, the MIME type of the first selected file must begin with the text "audio/". Thus a file of type "audio/mpeg" (an MP3 file), or of type "audio/x-wav" (a WAV file) would match this rule, but a file of type "video/x-msvideo" (an AVI video file) would not. (You can see the MIME type of any file by right-clicking on it in the file list and selecting Properties|Info.) In this example, our rule will only match the context if the first selected file is an audio file. Now set the top line to read 'Enable item if context matches any rule:'. We now have a context rule set which reads 'Enable item if context matches any rule: MIME Type begins with audio/'. Click OK to accept this rule set. Then select an audio file in the file browser's file list. Open the menu where your item appears, and it will be enabled for use. Next select another kind of file, such as a text or video file. Open the menu again, and the menu item will be disabled. In order to open the Design Menu again for this menu item, you must first select an audio file (you cannot open the Design Menu on a disabled menu item). Or you can temporarily check option Ignore Context (see below) to access all menu items. Additional Features To change a rule in the list, click the rule, then edit the rule using the Edit Rule box. When the rule is how you want it to appear, click the Apply button to update the rule in the list. The best way to learn to use the context rules is to practice with a file selected. In this way you can use the 'Value:' and 'Current:' labels to see context values and observe the result of changing the rules. Some context subjects are boolean - they will equal 'true' or 'false' (these words must be in English even if the rest of the rule is translated). For example, the rule subject 'Multiple Selected' will always equal 'true' or 'false', depending on whether more than one file is selected in the file list of the current panel. Thus if your custom menu item is designed to work with only one selected file, you might set a context rule to disable it if the user has selected multiple files. Other context subjects, such as 'Panel Count', contain a number, and you can test whether they are equal to, less than, or greater than a value. For example, the rule 'Panel Count is greater than 1' will only match if the user has multiple panels shown. As a more advanced use, it's also possible to use || (or) or && (and) in the test value to provide a list of possibilities (use || or &&, but not both in the same rule). For example, this rule: causes two tests to be performed. If the MIME Type begins with 'audio/' OR the MIME Type begins with 'video/', then the rule matches. Likewise, the rule: also causes two tests to be performed. If the Device Properties value (which provides information about the currently selected device) contains the word 'dvd', AND it contains the word 'blank', then the rule matches. This context rule would match if the currently selected device contained a blank DVD. Automatic Context
Custom menu items added directly after the Default menu item in the file list's Open context menu have an automatic pre-context - they only appear if the MIME type of the first selected file matches the MIME type when the custom item was added. This provides an easy way to add an item with an automatic context based on MIME type, and may also be used to setup a file handler (see below). Custom menu items added directly after Show Output in the Task Manager's context menu will also only appear for tasks with a custom popup handler. Also, custom submenus which are empty due to all of their children being hidden based on context are hidden automatically. Note: Custom menu items when shown in the Bookmarks side pane will not respond to Context rules, and will always be shown. Impossible Context
Use As Handler For If set to 'files', note that no files are passed to a command on the command line. You must use variables in your command line or script to pass files to it. If the menu item is of type Application, what is passed will depend on the Exec= line of the application's .desktop file. If set to 'devices', clicking on a device in the Devices list, or in the Devices menu, will cause the item to be run rather than the applicable device handler. Variables %v, "$fm_device", or other variables may be used in your command. If more than one item is set as a handler and each is enabled, multiple items will be run each time files or devices are opened. As noted above, custom menu items added directly after the Open|Default menu item have an automatic pre-context - they only appear if the MIME file type of the first selected file matches the MIME type when the custom item was added. This provides an easy way to set a custom handler for a given MIME type. Simply select a file of the desired type, right-click on it and add your custom item directly after the Open|Default menu item. Next, select option 'use as handler for files'. Your custom item will be used to open files when the MIME type matches. Or, you can set additional context rules to determine when your handler is used. NOTE: When imported or installed, plugins lose their 'Use as handler for' setting (by design - you can add it back after import if desired). Ignore Context (see below) has no effect on the handler being context-enabled - its context will be tested even if global option Ignore Context is checked. Ignore Context If you need to change the context of an item you have disabled or hidden, you can either select the appropriate file to create a context where the item is shown and enabled, or you can open the Item Properties dialog for any other item and check option 'Ignore Context'. This will allow you to then access the Design Menu of all items and change their context rules. When you are finished, you can uncheck option 'Ignore Context'. Note that Ignore Context does not affect the automatic context of built-in items - for example, even with Ignore Context checked, the file list's Paste menu item will always be disabled if the clipboard is empty.
Command Command Line
You may use the following substitution variables in command lines:
For example, to calculate the MD5 sum of all selected filenames, use this command line: md5sum %N Before your command is run, the substitution variables will be replaced with their current values. Do NOT place quotes around substitution variables - they will be quoted automatically when required. Bash variables, described below, may also be used in command lines (bash variables SHOULD in general be "double quoted"). To experiment with variables, use the echo command to simply print their values. For example, the following command line will print the current directory: echo %d Command lines may also contain bash scripts containing multiple commands. For example, this command line will print the current time, once per second, for ten seconds, then stop: while (( x < 10 )); do date; sleep 1; (( x++ )); done Environment variables can also be included. For example, to run claws-mail using a custom DISPLAY variable in a command line: DISPLAY=:1 claws-mail Open In Editor
NOTE: When exporting a Command menu item, the value of the command line will be exported with the plugin even if Command Line is no longer the selected command type, or if the menu item type is changed. Before distributing a plugin, be sure to open or extract the archive and examine all files in your text editor to be clear on what data you are sharing. Command Script
At its simplest, a command script is simply a list of commands that could be entered in a terminal. The script executes each command in sequence, allowing you to automate common command-line tasks. You can also use tests and loops in scripts to make them more capable. For more information on writing scripts, see the Bash Scripting Guide. Command scripts can also evolve into small, full-featured applications using SpaceFM Dialog to show custom dialogs from within the script, and socket commands to manipulate elements of the SpaceFM window. Your script can also replace the default task popup dialog by setting a custom popup handler. The substitution variables used above in command lines may NOT be used in a command script. Instead, bash variables are preloaded for your use (these variables may be used in command lines or a script). When you select Script, a default bash script is generated as shown below: #!/bin/bash $fm_import # import file manager variables (scroll down for info) # # Enter your commands here: ( then save this file ) exit $? # Example variables available for use: (imported by $fm_import) # These variables represent the state of the file manager when command is run. # These variables can also be used in command lines and in the Path Bar. # "${fm_files[@]}" selected files ( same as %F ) # "$fm_file" first selected file ( same as %f ) # "${fm_files[2]}" third selected file # "${fm_filenames[@]}" selected filenames ( same as %N ) # "$fm_filename" first selected filename ( same as %n ) # "$fm_pwd" current directory ( same as %d ) # "${fm_pwd_tab[4]}" current directory of tab 4 # $fm_panel current panel number (1-4) # $fm_tab current tab number # "${fm_panel3_files[@]}" selected files in panel 3 # "${fm_pwd_panel[3]}" current directory in panel 3 # "${fm_pwd_panel3_tab[2]}" current directory in panel 3 tab 2 # ${fm_tab_panel[3]} current tab number in panel 3 # "${fm_desktop_files[@]}" selected files on desktop (when run from desktop) # "$fm_desktop_pwd" desktop directory (eg '/home/user/Desktop') # "$fm_device" selected device (eg /dev/sr0) ( same as %v ) # "$fm_device_udi" device ID # "$fm_device_mount_point" device mount point if mounted (eg /media/dvd) (%m) # "$fm_device_label" device volume label ( same as %l ) # "$fm_device_fstype" device fs_type (eg vfat) # "$fm_device_size" device volume size in bytes # "$fm_device_display_name" device display name # "$fm_device_icon" icon currently shown for this device # $fm_device_is_mounted device is mounted (0=no or 1=yes) # $fm_device_is_optical device is an optical drive (0 or 1) # $fm_device_is_table a partition table (usually a whole device) # $fm_device_is_floppy device is a floppy drive (0 or 1) # $fm_device_is_removable device appears to be removable (0 or 1) # $fm_device_is_audiocd optical device contains an audio CD (0 or 1) # $fm_device_is_dvd optical device contains a DVD (0 or 1) # $fm_device_is_blank device contains blank media (0 or 1) # $fm_device_is_mountable device APPEARS to be mountable (0 or 1) # $fm_device_nopolicy policy_noauto set (no automount) (0 or 1) # "$fm_panel3_device" panel 3 selected device (eg /dev/sdd1) # "$fm_panel3_device_udi" panel 3 device ID # ... (all these are the same as above for each panel) # "fm_bookmark" selected bookmark directory ( same as %b ) # "fm_panel3_bookmark" panel 3 selected bookmark directory # "fm_task_type" currently SELECTED task type (eg 'run','copy') # "fm_task_name" selected task name (custom menu item name) # "fm_task_pwd" selected task working directory ( same as %t ) # "fm_task_pid" selected task pid ( same as %p ) # "fm_task_command" selected task command # "fm_task_id" selected task id # "fm_task_window" selected task window id # "$fm_command" current command # "$fm_value" menu item value ( same as %a ) # "$fm_user" original user who ran this command # "$fm_my_task" current task's id (see 'spacefm -s help') # "$fm_my_window" current task's window id # "$fm_cmd_name" menu name of current command # "$fm_cmd_dir" command files directory (for read only) # "$fm_cmd_data" command data directory (must create) # To create: mkdir -p "$fm_cmd_data" # "$fm_plugin_dir" top plugin directory # tmp="$(fm_new_tmp)" makes new temp directory (destroy when done) # To destroy: rm -rf "$tmp" # fm_edit "FILE" open FILE in user's configured editor # $fm_import command to import above variables (this # variable is exported so you can use it in any # script run from this script) # Script Example 1: # # show MD5 sums of selected files # md5sum "${fm_files[@]}" # Script Example 2: # # Show a confirmation dialog using SpaceFM Dialog: # # http://ignorantguru.github.io/spacefm/spacefm-manual-en.html#dialog # # Use QUOTED eval to read variables output by SpaceFM Dialog: # eval "`spacefm -g --label "Are you sure?" --button yes --button no`" # if [[ "$dialog_pressed" == "button1" ]]; then # echo "User pressed Yes - take some action" # else # echo "User did NOT press Yes - abort" # fi # Script Example 3: # # Build list of filenames in panel 4: # i=0 # for f in "${fm_panel4_files[@]}"; do # panel4_names[$i]="$(basename "$f")" # (( i++ )) # done # echo "${panel4_names[@]}" # Script Example 4: # # Copy selected files to panel 2 # # make sure panel 2 is visible ? # # and files are selected ? # # and current panel isn't 2 ? # if [ "${fm_pwd_panel[2]}" != "" ] \ # && [ "${fm_files[0]}" != "" ] \ # && [ "$fm_panel" != 2 ]; then # cp "${fm_files[@]}" "${fm_pwd_panel[2]}" # else # echo "Can't copy to panel 2" # exit 1 # shows error if 'Popup Error' enabled # fi # Script Example 5: # # Keep current time in task manager list Item column # # See http://ignorantguru.github.io/spacefm/spacefm-manual-en.html#sockets # while (( 1 )); do # sleep 0.7 # spacefm -s set-task $fm_my_task item "$(date)" # doneOr, if you would like to use another script as your default, save it as ~/.config/spacefm/scripts/default-script. It is recommended that you include the example variables shown above at the end of your default script. Script Directories
If your script needs to save changing, persistent data to the user's home folder (to keep track of user preferences, for example), the data directory should be used ("$fm_cmd_data"). Because this directory may not already exist, always run this command before using it: mkdir -p "$fm_cmd_data" If your script needs a temporary directory to work in, you can create one automatically using this convenience function: tmp="$(fm_new_tmp)" Your new, empty temporary directory will be created, and its path will be placed in $tmp by the above command. Before the end of your script, be sure to clean up by destroying the temporary directory: rm -rf "$tmp" When you export a Command menu item, the command script and any files in the command directory are included in the plugin file. When you remove a command, all of these files AND the data directory are deleted! Open In Editor & Root Editor
You can also open the command script in your editor directly from the Design Menu with Edit Script or using a design mode shortcut instead of the Design Menu. Highlight the menu item and press F4 or Ctrl+E, or use the mouse shortcut Middle-Click. Run Options Run As Task If Run As Task is checked, then the command is run synchronously - as a child process of SpaceFM. SpaceFM's Task Manager will monitor the task, and if the task runs for longer than about one half second, the Task Manager will auto-show and the task will be listed. When the task finishes, it will be removed from the list. This can be used to monitor a task and to know when it has completed. (When a command is run from the desktop menu, no Task Manager is shown for the task, but a popup may be shown automatically.) In addition, any output from the task (stdout and stderr), will be collected in an output monitor. To raise this monitor, click on the task in the Task Manager. (The output monitor can also be set to raise automatically on certain events - see Popup options below for details.) SpaceFM's output monitor is designed to display text output to be used for monitoring the output of commands as they run, or to display a final result. However, the output monitor is not a terminal and does not allow you to enter input. If your command requires interaction, you will need to use Run In Terminal instead. To stop a task prematurely, raise the output monitor and click the Stop button, or right-click on the task in the Task Manager and select Stop. When SpaceFM stops a task, it sends the process and all its child processes a SIGTERM signal, followed several seconds later by SIGKILL signals. If the process was run as another user, you will be prompted to enter the user's password (or root's password) again to stop the task. When the Run In Terminal option is checked, the Run As Task option will be unchecked automatically as a convenience. Although not normally useful, it is possible to use these options together (just check Run As Task again after checking Run In Terminal). When both are checked, the terminal window itself is run as a task, the output monitor will generally be empty, and errors may not be detected. Mostly this is useful only for monitoring when the command has finished (when the terminal window closes, it will be removed from the Task Manager). Note that some terminal emulators cannot be run as a task by SpaceFM because the emulator does not start a new instance. Popup Task Use Popup Task if you want a popup anytime the task runs for more than a moment. When the task finishes, the popup will remain, allowing you to review any output. You can also close the monitor prematurely while the task is still running by clicking the Close button - the task will continue running in the Task Manager. Note that the global Task Manager setting Popup All Tasks, if checked, takes predecence - the task will popup even if the command's Popup Task option is unchecked. (However, unlike Popup Task, Popup All Tasks will not cause the popup to remain when the command has finished, unless an error occurs.) By default, Popup Task is unchecked in new commands. Popup Error Popup Error provides a convenient way to get feedback on the success of your command. When the command finishes successfully it will simply be removed from the Task Manager. However, if an error occurs then the popup will be raised. Even if your command does not produce a usuable exit status, you can terminate your command line or script with a non-zero exit status to trigger the error popup. For example: if [ ! -e file.output ]; then exit 1; fi(If the file 'file.output' does not exist, then exit with exit status 1, triggering an error popup if Popup Error is checked.) To see another example, scroll to the end of a command script: # Script Example 3: # Copy selected files to panel 2 # make sure panel 2 is visible ? # and files are selected ? # and current panel isn't 2 ? if [ "${fm_pwd_panel[2]}" != "" ] \ && [ "${fm_files[0]}" != "" ] \ && [ "$fm_panel" != 2 ]; then cp "${fm_files[@]}" "${fm_pwd_panel[2]}" else echo "Can't copy to panel 2" exit 1 # shows error if 'Popup Error' enabled fi By default, Popup Error is checked in new commands. Popup Output Popup Output can be used to alert you when your task has produced output. By default, it is checked in new commands. Scroll Output With some commands, it's useful to read the output from the top and scroll down manually. For example, if you right-click on a device in the Devices list and select Properties, you will see a non-auto-scrolling output monitor - the cursor stays at the very beginning of the output so you can read it. With other commands, you're most interested in the end of the output, so you want the output monitor to behave like a terminal and scroll to the end as new output is added. For example, errors usually appear at the end, so if you want to know why the command stopped prematurely, you're most interested in the end of the output. When you want the output monitor to behave like a terminal in this regard, check Scroll Output. Even if Scroll Output is checked, you can always manually move the scrollbar up to inhibit auto-scrolling. Run In Terminal Each time your command is run, a terminal will be opened and the command will be run within it. The terminal program used is configured globally in View|Preferences|Advanced|Terminal. When you check the Run In Terminal option, the Run As Task option will be unchecked automatically as a convenience. If you do want both Run In Terminal and Run As Task, you can then check Run As Task as well. If you do so, normally nothing will be shown in the output monitor. Note that gnome-terminal, konsole, lxterminal, and urxvtc lack a --disable-server or similar option to force a new instance to be started for each terminal window. This means that these terminals cannot generally be used successfully with a combination of both the Run In Terminal and Run As Task options, unless no other terminal window is open when the command is run. Thus use of these terminals may prevent SpaceFM working correctly in some cases. For example, if a handler mounts a protocol in a terminal, the mount point may not be automatically opened when the mount command finishes. If you really want to use these terminals, you can, but you should note that not all functions may work as expected. Keep Terminal Open When Keep Terminal Open is enabled, after the command finishes you will be presented with a message like: [ Finished ] Press Enter to close or s + Enter for a shell: To close the window, simply press Enter. If you want to enter an interactive bash shell, press s then Enter. When finished with the shell, type 'exit'. With other programs or commands, it is not useful for the terminal to be held open after the command has finished. For these commands, uncheck Keep Terminal Open. Run As User To run a command as root, "root" may be entered as the Run As User username. However, running commands as root in this way is generally NOT recommended. Because the command line or script is generally saved with normal user permissions, you are running a command which is not protected by root, as root. This may compromise your system security at the root level. To run commands more safely as root, consider exporting the command and installing it as a plugin. Plugins enjoy root protection from modification, so when they are run as root, you have more assurance that they have not been tampered with. Another option is to run SpaceFM itself as root when needed (select File|Root Window). In this way, all commands and settings are stored in root's home (/root/.config/spacefm), and are protected by root. Yet running SpaceFM as root puts much power at your fingertips - accidentally deleting a file or folder may render your system unusable! When run as root, everything you do in the file browser is done as root, including opening applications. At the very least, be sure to have an up-to-date system backup if running SpaceFM as root. It is your responsibility to evaluate this option for your purposes. When running a custom command as another non-root user, depending on the permissions of your SpaceFM config and scripts directories, this user may not have permission to access the command directory, including the command script. To avoid this limitation, you can use a command line, or use a script which is in a mutually accessible directory. To run a command as the current user, simply leave the Run As User field empty. Style Normal Checkbox On the toolbar, a Checkbox style item will appear as an icon, and clicking it will show the button depressed. In the Bookmarks list, an icon will be shown when a Checkbox style item is checked, and no icon will be shown when it is unchecked. Your command can read the value of the checkbox using the variable $fm_value (or %a in command lines). This will equal 1 if checked, or 0 if unchecked. This allows your command to take different actions depending on the state of the checkbox. For example, add a new Command menu item called 'Checker'. Then open the Properties dialog for the new item and select style Checkbox. Enter or paste this command line on the Command page: if [ $fm_value -eq 1 ]; then echo "Box is checked"; else echo "Box is unchecked"; fi Now when you click your menu item, you will be told if the box is checked or unchecked - each time you click the item, it will change. Confirmation To set or change the message which appears in the dialog, set your message in the Confirmation/Input Message entry on the Options page. Alternatively, to show a dialog while your script is running, or to easily create custom dialogs, see SpaceFM Dialog. Input Your custom command can read the text entered by the user using the variable $fm_value (or %a in command lines). The last text entered in the box will be remembered and will be the default entry next time the item is clicked. For example, add a new menu item called 'Your Name'. Then open the Properties dialog for the new item and select style Input. Enter 'Please enter your name:' as the message. Enter or paste this command line on the Command page: echo "Your name is $fm_value." When you click the menu item, you will be asked for your name, and if you click OK, told your name. Alternatively, to show a dialog while your script is running, or to easily create custom dialogs, see SpaceFM Dialog. NOTE: When exporting a command, the last value entered in the input dialog will be exported with the plugin, even if Input is no longer the selected style. Before distributing a plugin, be sure to open or extract the archive and examine all files in your text editor to be clear on what data you are sharing. Open In Browser Command Dir $fm_cmd_dir Or for a plugin: While you may modify files in the command directory when creating and maintaining your command, the command script should not modify files in this directory while the command is running. The reason is that if you later install the command as a plugin, it will probably no longer have write access to this directory. When exporting a Command item, all files in the command directory are included in the plugin file. There are several special files: 'exec.sh' is the command script, if any. 'icon' is a custom icon file for the command or plugin - it will automatically be shown if no icon is set. You can also include a 'README' file in this directory which describes your command or plugin. All files in the command directory are deleted when the item or plugin is removed! Data Dir $fm_cmd_data This directory must be created on demand, so if you plan to use it in a script, first make sure it exists: mkdir -p "$fm_cmd_data" SpaceFM does not automatically store any files in this directory - it is entirely up to you or the plugin creator how it is used. To see what persistent data a plugin is storing in your home folder, examine the Data Dir. All files in the data directory are deleted when the item or plugin is removed! Plugin Dir $fm_plugin_dir Plugins may contain multiple items (a submenu plugin), so this directory may have several command directories within it, but will at least contain one command directory as well as a 'plugin' file which defines the contents of the plugin. Review the contents of this file, but it should NOT be edited. Before using a plugin obtained from another user, browse Plugin Dir to make sure you understand what each command does. Keep in mind that plugins can do anything on your system which the current user is permitted to do. The plugin directory contained a mirror copy of the contents of the plugin archive file (eg Example.spacefm-plugin.tar.gz) when the plugin was installed. Its contents will not change unless the directory contents are modified by the root user.
| ||||||||||||||||||||||||||||||||||||
Contents |
Toolbars
SpaceFM includes two toolbars in each panel: the main Toolbar above the file list, and a Side Toolbar shown above the side panes. To show or hide the Toolbar or Side Toolbar in a given panel, right-click on the file list and check or uncheck View|Toolbar or View|Side Toolbar. Toolbars can be customised using Design Mode by right-clicking on a toolbar item. You can also middle-click on a toolbar item to open its Item Properties dialog or script. Each panel's toolbars are configured independently of other panels. In addition to adding or pasting the usual custom items in a toolbar, you can also use the Add submenu of the Design Menu to add built-in tool items. These items have preset functions, but you can change their name and icon. Once added, they can be cut, copied and pasted within toolbars only. There are also two built-in submenus in the Add submenu: Back History and Forward History. If shown, these will display not only a back/forward button, but also a menu button which opens a drop-down list showing path history for the current browser tab. When adding or pasting a custom submenu into a toolbar, it will also be displayed as a button with a smaller menu button next to it. The large button will have the icon (and tooltip) of the first item in the submenu (unless a custom icon is set for the submenu), and clicking this button will activate that first item. To use other items in the submenu, click the smaller menu button. Design Mode can also be used within this menu by right-clicking on a menu item. To set properties for the submenu itself, right-click on either button. Menu and bookmark items can be pasted and imported to the toolbars, and custom toolbar items can be cut/copied and pasted elsewhere. Design Mode mouse shortcuts (see below) may also be used on toolbar items. TIP: If you want to create a toolbar button which shows a custom submenu from another menu, without copying the submenu to the toolbar, you can use a socket command to show the submenu as a popup menu instead. To do so, add a New|Command to the toolbar (where "Menu Name" is the name of the existing custom submenu): spacefm -s activate "Menu Name" | ||||||||||||||||||||||||||||||||||||
Contents
|
Shortcuts
In addition to right-clicking on a menu item and using the Design Menu, design mode keyboard and mouse shortcuts are also available. These shortcuts are NOT required - all you really need to know is 'right-click opens the Design Menu'. To use these shortcuts, highlight the menu item (hover your mouse cursor over it, or use the keyboard arrows to highlight the menu item), then use the key or mouse combo shown below. These shortcuts are only available for use when a menu is open. On a toolbar item, mouse shortcuts may be used.
These shortcuts will also work after the Design Menu has been shown. The F1 keyboard shortcut is special in that it can also be used to show help on items in the Design Menu itself. Highlight a Design Menu item (such as Export) and press F1. If the shortcut action is not available for the current item (for example, performing Remove on a built-in menu item), the Design Menu will be opened instead. NOTE: Some window managers may be configured to use some of these mouse combos for other purposes. For these to work within SpaceFM, you may need to disable them in your window manager.
| ||||||||||||||||||||||||||||||||||||
Contents
|
MIME Menu
Although SpaceFM does not include a full-featured MIME editor, SpaceFM's MIME menu makes it easy to find and edit all the files needed to customise your MIME database, and in some cases will create and edit the files for you. One example is the 'Choose...' menu item on the file list context menu's Open submenu, which lets you choose or set a default application for a MIME type. Choosing an application will cause SpaceFM to edit your mimeapps.list file, setting the application as the default. When you right-click on a file in the file list, the Open submenu shows applications associated with the (first selected) file's MIME type (eg text/plain). If you right-click on one of these listed applications, or press F2 while the menu item is highlighted, you will be presented with a menu which allows you to configure MIME associations and definitions for this file type. (Note that other methods may also be used to open files.) TIP: For help with a menu item in the MIME menu itself, highlight the MIME menu item and press F1. IMPORTANT: Changes made with this menu may affect other programs on your system which use the MIME database, not just SpaceFM. However, some programs use other means for determining file types, or some combination of several methods, so not all MIME changes made in SpaceFM will be reflected in all programs. For more elaborate MIME adjustments, consider using a dedicated MIME editor. How MIME Works It helps to know some basics about how MIME works so you can better control how your system handles file types. Note that SpaceFM is not fully compliant with all freedesktop specifications. Where this manual and their specifications differ, this manual is authoritative on SpaceFM's behavior. MIME knows what applications are installed on your system by examining .desktop files. When an application is installed, it will usually install one or more .desktop files for itself to /usr/share/applications or /usr/local/share/applications. These .desktop files determine the display name of the application (which may differ from the executable's name), translated display names, the command used to execute the application, an icon for the application, what MIME file types the application can open, and other specifics. If you would like to change anything in an application's .desktop file, the correct way to do so is to copy the desktop file to ~/.local/share/applications in your home folder, and make changes in the copy. (Changes made directly in /usr/share/applications may be lost when the software is upgraded.) You can also add your own custom .desktop files to run programs or scripts. When MIME looks for a desktop file, first it looks in ~/.local/share/applications, then in /usr/local/share/applications, and then in /usr/share/applications, using the first copy it finds. Thus copies in your home folder always take precedence, and will not be modified when software is upgraded. Anytime .desktop files are created or changed, the MIME desktop database needs to be updated. A user's database can be updated by the user running: update-desktop-database ~/.local/share/applicationsThis command examines all the desktop files and will create files named 'mimeinfo.cache' which contain all the relevant information for fast access. The mimeinfo.cache files should never be edited directly. To determine what applications are associated with a given MIME type (what applications can be used to open files of that type), SpaceFM and many other programs will build a list of applications by examining the mimeinfo.cache files in ~/.local/share/applications, /usr/local/share/applications, and /usr/share/applications. Sometimes a distro, admin, or user may want to associate default or additional applications with a MIME type, or remove unwanted associations. Information about default applications, and added and removed associations are placed in mimeapps.list files located in the applications directories. ~/.config/mimeapps.list (or the older location: ~/.local/share/applications/mimeapps.list) in the user's home folder takes precedence. Distros and admins may also use files named 'defaults.list' to associate applications, although modification of these files by the user is now deprecated - change mimeapps.list instead. (SpaceFM will never modify defaults.list, but may read it.) To define MIME types, xml files are used. These may determine a file type using a filename glob (eg *.txt), or may base determination on a file's contents. freedesktop supplies basic definitions, and additional ones may be added in /usr/share/mime/packages. Any definitions placed in Overrides.xml will override other definitions. Users can add xml files to add custom MIME types or to change existing definitions. These are usually placed in ~/.local/share/mime/packages. After adding or changing these files, run: update-mime-database ~/.local/share/mimeOr to update the system-wide database: sudo update-mime-database At startup, SpaceFM reads and caches these xml files to know how to recognize all the file types on your system. Because they are cached, you may need to restart SpaceFM after changing MIME type definitions. For other adjustments, see the MIME menu items below. Set As Default Specifically, SpaceFM will edit your ~/.config/mimeapps.list file, adding the application's .desktop file to the beginning of the list for the given MIME type in [Default Applications] and [Added Associations], and will remove it from [Removed Associations] if present. Remove Specifically, SpaceFM will edit your ~/.config/mimeapps.list file, removing the application's .desktop file for the given MIME type in [Default Applications] and [Added Associations], and will add it to [Removed Associations] for the given MIME type. To restore an association that you have removed, use Add... NOTE: When compiling the list of applications to appear in the Open submenu for a text file, SpaceFM will include applications associated with the MIME type (eg text/html) and applications associated with the generic 'text/plain'. If you select Remove on an application, it will be removed as an associated application for the MIME type (eg text/html), but will NOT be removed as an associated application for text/plain (unless the MIME type is text/plain). Thus using Remove may not remove the application from the Open submenu for this type, unless you also remove it from text/plain. Text files are the only files with this behavior. Add... Specifically, SpaceFM will edit your ~/.config/mimeapps.list file, adding the application's .desktop file to the list for the given MIME type in [Default Applications] and [Added Associations], and will remove it from [Removed Associations] if present. If you entered a command instead of choosing an application from the list, a custom desktop file will be created for your command in ~/.local/share/applications/. application.desktop If "(*copy)" appears next to the .desktop filename on the menu, this means that no copy of the desktop file currently exists in ~/.local/share/applications/. If you select it, SpaceFM will automatically copy the desktop file from /usr/share/applications/ to ~/.local/share/applications/, and will then open the copy in your text editor. The copy in ~/.local/share/applications/ always takes precedence over other locations. mimeapps.list If you edit this file, be careful to use its default formatting. Any changes you make to this file will immediately take effect. applications/ mime-type.xml If "(*new)" appears next to the xml filename on the menu, this means that the xml file doesn't currently exist in ~/.local/share/mime/packages/. If you select it, SpaceFM will automatically create the xml file using the definition in /usr/share/mime as a template (if present), and will then open the new xml file in your text editor. The copy in ~/.local/share/mime/packages/ always takes precedence over other locations. You can also use this menu item simply to see the MIME type of the selected file. For example, if the name of this menu item is "application-zip.xml", then you know the MIME type is "application/zip". mime/packages/ usr/ For example, to see the original .desktop file for an application, select the .desktop file in the usr/ submenu. It will be opened in your editor, but can only be edited by root. (Normally it is useless to edit files in /usr/share, as a software upgrade may overwrite it. Instead, to make system-wide changes, place a copy in /usr/local/share/applications and edit that. To make changes for a single user only, place a copy in ~/.local/share/applications/). Likewise, to see the system-wide MIME type definition for the current MIME type, select the xml file in the /usr submenu. The Overrides.xml file, if present, will be opened as root to allow you to edit it. This is one place where you can define system-wide changes to MIME types. (Or you can copy your custom xml files to /usr/share/mime/packages/). When making changes here you must run 'sudo update-mime-database' and restart SpaceFM.
| ||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
Contents |
Introduction
Like any plugin, a SpaceFM plugin extends the features of the file manager. What's different about SpaceFM plugins is how readily they're created. Any custom item can be turned into a plugin simply by exporting it to a plugin file. SpaceFM plugins use an open format which can include additional files, and can also store persistent data between sessions. SpaceFM plugins can do anything a bash script can do - which means just about anything. Plugins can be shared and obtained in the SpaceFM Wiki. It is your responsibility to evaluate the safety and applicability to your purposes of all plugins.
| ||||||||||||||||||||||||||||||||||||
Contents |
Install
When a plugin is installed, it is added to the Plugins menu where it gains root protection (it cannot be modified by normal users) and becomes accessible to all users of SpaceFM on your system. Installing a plugin helps protect the plugin's contents from tampering, but it also limits what you can change. To install a plugin using a plugin file, use Plugins|Install|File. You will be prompted to choose a file, and you will need to enter the root password for installation. You can also install a plugin directly from a URL using Plugins|Install|URL (be sure to examine their contents before running commands within the plugin). wget is required when installing from URL (this program is already installed on most Linux distributions). Remember that installing a plugin as root does NOT mean it is run as root. The files for the plugin are merely copied to /usr/?local?/share/spacefm/plugins as root. When installed or imported, plugins lose any key shortcut which was saved with the plugin, and also lose their Use as handler for context setting. These settings must be manually added after installation/import if desired. Installed plugins are available via the Plugins menu. SpaceFM will allow you to set a key shortcut for a plugin, change its icon, and change Run In Terminal and Run As Task options for the plugin. You cannot change the type of a plugin, and unless you do so as root, you cannot edit the command script. You can temporarily edit the command line or custom target of a plugin, but your changes will not be saved - they will be valid only for the current session by the current user. To see the help file for a plugin command, use Help on the Design Menu, or highlight the menu item and press F1. When you make Design Mode changes to a plugin, you are not actually altering the plugin itself. SpaceFM creates a skin for the plugin which holds your custom key shortcut, icon, etc. Thus these changes made to a plugin by one user will not be seen by other users on the system. This skin is retained in the SpaceFM session file until the plugin is removed. If you want to make deeper changes to a plugin, you can copy it using Import on the Design Menu, and Paste the copy into another menu. The copy will be exactly like the plugin, except that its files will no longer be owned by root. Thus you can make any changes to a copied plugin, just as with any custom menu item. You can also export the copy, then install it as a plugin again, either with a new name, or overwriting the old plugin. You can also export an installed plugin. Unless you made changes to the plugin directory as root, the exported plugin file will essentially be a copy of the original plugin file. NOTE: Plugins created with SpaceFM versions 0.7.0 and later may not work correctly with prior versions due to changes in the file structure of plugins and commands.
| ||||||||||||||||||||||||||||||||||||
Contents |
Import
Instead of installing a plugin, you can import it into any SpaceFM menu or toolbar. When imported in this way, the plugin loses root protection and becomes a normal custom item. To do so, use Plugins|Import|File to import a plugin file, or Plugins|Import|URL to import directly from URL. No root password is required. The plugin will be copied to the design clipboard. You may then use Paste on the Design Menu to paste the item into any location in any supported menu. As with any custom items, you cannot paste the item into some parts of the Plugins menu and the file browser's Open menu. If option Plugins|Import|Verbose is checked, after the plugin has been copied to the design clipboard, you'll see a message reminding you what to do next. When installed or imported, plugins lose any key shortcut which was saved with the plugin, and also lose their Use as handler for context setting. These settings must be manually added after installation/import if desired. Alternatively, you can use New|Import on the Design Menu to import and paste a plugin in one step. Note: Exported bookmarks in a "spacefm-bookmarks" plugin file cannot be installed or imported via the Plugins menu, but can be imported into other menus.
| ||||||||||||||||||||||||||||||||||||
Contents |
Uninstall
To uninstall a plugin, use Remove on the Design Menu. You will be prompted for the root password, and all files and settings associated with the plugin will be removed. If the installed plugin is a submenu plugin, you can only remove the top submenu of the plugin. You cannot remove individual items from within it.
| ||||||||||||||||||||||||||||||||||||
Contents
|
Creation And Files
The best way to create a plugin, whether for your own use or for others, is to create a custom command. Develop the command to work the way you want, and set any Design Mode options for how the command is best run. When you're ready to create the plugin, simply use Export on the Design Menu to save the command to a plugin file. A plugin may also contain multiple related commands and submenus of commands. To create such a plugin, simply export a submenu. Exporting commands as plugins also provides a way to back up commands. By exporting it to a plugin file, your custom item becomes portable and self-contained - you can always use the plugin file to import it back into any SpaceFM session, either as a normal custom item, or as an installed plugin. Plugin File A plugin file, such as Example.spacefm-plugin.tar.gz, contains a single file named 'plugin' which SpaceFM uses to define the contents of the plugin. This file is plain text and can be viewed in your editor, but should NOT be edited. In addition, plugin files contain one or more command directories, one for each command in the plugin. Plugins may be a single command, or they may be a single submenu which contains an unlimited number of commands and submenus. Thus a set of commands with related functions can be distributed as a single submenu plugin. (To create a submenu plugin, simply export a submenu.) TIP: If you have a larger plugin, you can manually convert it to tar.xz format and SpaceFM will accept it (only tar.gz or tar.xz). Extra Files You may also add a file named 'icon'. SpaceFM will automatically display this icon for the plugin if no other icon is set in the Item Properties. Small icons work best, as your icon may not be resized. If you don't want to include a custom 'icon' file, you can also simply set a standard icon for the command using the Design Menu. Users can also override your default icon in this way. Keep in mind that the user may be using a different icon theme than you are, so try to stick with common icon names. Using an absolute path for the icon is not recommended. In addition, adding a README file to the command directory is recommended. This file will be created automatically if you select Help from the Design Menu. This file explains what your plugin does, how to use it, and may include an email address, website, license terms, etc. If multiple commands in your plugin need to access shared files, it is possible to place them in the top level of the plugin file, the plugin directory. SpaceFM won't do this for you automatically when exporting a command, but you can add them using an archive application after the plugin file has been created. Or, if your plugin is already installed and you added files to its plugin directory, these files WILL be included in the plugin file when the plugin is exported again. Your scripts can access this directory using "$fm_plugin_dir". To browse it, use Open In Browser on the Options page of the Item Properties dialog. One limitation of using this directory is that if a user copies commands from within your plugin submenu to another menu, the files in the plugin directory will NOT be included. Thus, it may be better to include all of a command's required files in its command directory instead. In this way, each command is complete when copied elsewhere. Or, if multiple commands needs to access the same files, consider creating a config directory in the user's home directory (eg ~/.config/spacefm-plugin-myexample) for your plugin. Data Files Remember that the data directory may not exist, so make sure your script always creates it before attempting to use it. Place this command in the initial part of your script: mkdir -p "$fm_cmd_data" Before distributing a plugin, be sure to open or extract the archive and examine all files in your text editor to be clear on what data you are sharing. For example, some entries may be included in the plugin file even if they are currently disabled in the command.
| ||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
Contents
|
Introduction
Handlers are sets of commands which tell SpaceFM how to perform a function, such as opening a file, mounting a device, or creating/extracting an archive. In some cases your handlers replace SpaceFM's default behavior. Handlers come in several varieties: Devices, Protocols, Archives, and Files. Additional user-contributed handlers may also be found on the Plugins Wiki. If you create a new handler, please consider exporting it and adding it to the wiki.
| ||||||||||||||||||||||||||||||||||||
Contents |
Devices
Device handlers tell SpaceFM how to mount, unmount, and show properties for specific filesystems or devices. Anytime SpaceFM or the SpaceFM daemon mounts or unmounts a device (manually or automatically), or shows the properties of a device, it uses a handler to determine what commands to run. By adding custom device handlers, SpaceFM can be made to mount and unmount virtually any type of device or filesystem.To configure device handlers, right-click in the Devices list and select Settings|Device Handlers. The list at the left of the Device Handlers configuration window lists all device handlers. (Enlarge this window to see the handler commands more clearly.) Click on a handler's name to see its contents. The order of the list is important: Starting from the top, the first handler which matches the current device will be used. You can reorder the list by dragging entries, or using the Up & Down buttons. In this way, you determine what handlers have preference. The "Default" handler is usually listed last, and is used if no other handlers apply. The right side of the window shows the selected handler's contents. If Enable Handler is unchecked, this handler will never be used. The Name contains the common name for the handler, which appears in the list and in debug messages. Next comes a Whitelist and Blacklist: these determine when this handler will be used. Finally, the Mount, Unmount, and Properties boxes contain scripted commands which will be run by the handler to mount, unmount, or list properties of a device. TIP: If you just want to change the mount program that SpaceFM uses to mount removable drives (such as udevil, pmount, or udisks), open Device Handlers and click the Default handler. Example Mount and Unmount commands are shown for each mount program. Just enable the section you want to use by removing the appropriate comment marks (#). Whitelist The following device whitelist elements are recognized: FSTYPE (eg ext3) dev=DEVICE (/dev/sdd1) id=UDI label=VOLUME_LABEL (include spaces as underscores) point=MOUNT_POINT audiocd=0 or 1 optical=0 or 1 removable=0 or 1 mountable=0 or 1The simplest whitelist simply contains a filesystem type, such as "ext3". Thus anytime you mount a device with that filesystem, the handler may be used. If you want a handler to apply to several filesystem types, just list them: ext3 ext4For more complex situations, you can add more elements to narrow or control when a handler will be used. For example, consider the following whitelist: +ext3 +dev=/dev/sdd* +label=My_Volume_LabelFirst, the elements are prefixed with plug signs, so all are required to match, or the handler will not be used. First, the filesystem type MUST be ext3 for this handler to be used. Second, the device file must begin with "/dev/sdd" (eg /dev/sdd1). Finally, the volume label on the device must be "My Volume Label" (or "My_Volume_Label"). Note that spaces in the label are converted to underscores for testing. To see what handler SpaceFM has selected to mount a device, and see the commands being issued, start the Selected Device Handler 'Default': MOUNT [*]This tells you that the 'Default' device handler was used, and the action being performed is MOUNT. The portion(s) of the handler's whitelist which matched will be enclosed in square brackets [ ]. Blacklist For example, consider the following Whitelist/Blacklist combination: Whitelist: vfat Blacklist: dev=/dev/sde1 label=Ignored_Volume_LabelIn this example, the handler applies to any vfat filesystem. However, if the device file is /dev/sde1, OR the volume label on the device is "Ignored Volume Label" (or "Ignored_Volume_Label"), the handler will not be used. Mount Several variables will be replaced before your commands are run: %v device %o volume-specific mount options (use in mount command only) %t filesystem type being mounted (eg vfat) %a create auto mount point%v will be replaced with the device file (eg /dev/sdd1). %o, if included, will be replaced with volume-specific mount options (these are set in Mount Options). Or, you can omit %o and simply include the options you desire in the command. Finally, the presence of %a will cause SpaceFM to create a new directory to be used as a mount point for the mount (eg ~/.cache/spacefm/mountpoint), and %a will be replaced with the directory path. When the device is unmounted, this mount point will be removed. Or, if you wish to create your own mount point, or if your mount program automatically creates one in /media (such as udevil), then you may omit %a. In addition to the above variables, SpaceFM's exported bash variables may be used, as well as the substitution variables defined in Command Line. Example Mount commands (enable only one section by removing #): # # udevil: # udevil mount -o '%o' %v # # # pmount: (does not accept mount options) # pmount %v # # # udisks v2: # udisksctl mount -b %v -o '%o' # # # udisks v1: (enable all three lines!) # fm_udisks=`udisks --mount %v --mount-options '%o' 2>&1` # echo "$fm_udisks" # [[ "$fm_udisks" = "${fm_udisks/ount failed:/}" ]](Note: Because udisks v1 does not return a proper error status on error, the above lines examine the output and set the exit status if appropriate, which triggers an error popup in SpaceFM.) If a handler's Mount command is empty (or contains only blank lines and comments), that handler will not be used. If no handler is found with a non-empty Mount command, SpaceFM will automatically attempt to use udevil, pmount, udisks2, or udisks1 to mount the device (it will use whatever is installed, in this order of preference). NOTE: Custom menu items, added with New|Command, may also be set as primitive device handlers via their Use as handler for option. When a device is clicked, if the menu item is enabled based on the current browser context, this menu item's command will be run rather than any other configured device handler. In addition, device events may be configured to trigger actions based on socket event evt_device. Unmount Several variables will be replaced before your commands are run: %v device %a current mount point%v will be replaced with the device file (eg /dev/sdd1). %a will be replaced with the directory which is the mount point of the device. In addition to the above variables, SpaceFM's exported bash variables may be used, as well as the substitution variables defined in Command Line. Example Unmount commands (enable only one section by removing #): # # udevil: # udevil umount %v # # # pmount: # pumount %v # # # udisks v2: # udisksctl unmount -b %v # # # udisks v1: (enable all three lines!) # fm_udisks=`udisks --unmount %v 2>&1` # echo "$fm_udisks" # [[ "$fm_udisks" = "${fm_udisks/ount failed:/}" ]](Note: Because udisks v1 does not return a proper error status on error, the above lines examine the output and set the exit status if appropriate, which triggers an error popup in SpaceFM.) If a handler's Unmount command is empty (or contains only blank lines and comments), that handler will not be used. If no handler is found with a non-empty Unmount command, SpaceFM will automatically attempt to use udevil, pmount, udisks2, or udisks1 to unmount the device (it will use whatever is installed, in this order of preference). Properties If no applicable device handler has a non-empty Properties command, SpaceFM's default properties will be shown.
| ||||||||||||||||||||||||||||||||||||
Contents |
Protocols
Protocol handlers tell SpaceFM how to respond when a URL is opened or unmounted, such as mounting or unmounting a network filesystem, or showing properties for a mounted URL. Anytime you enter a URL in SpaceFM's Path Bar (eg ftp://mirrors.kernel.org), open a bookmark containing a URL, select Open URL from the file menu, or specify a URL on the command-line, a handler is used to open the URL. This handler can run another program (such as a web browser), can mount the URL as a filesystem, or take any other action you specify.To configure protocol handlers, right-click in the Path Bar and select Protocol Handlers, or select Settings|Protocol Handlers from the Devices menu. Like Device Handlers, protocol handlers have an Enable checkbox, a whitelist and blacklist which determine when the handler is used, and command boxes. Whitelist SpaceFM recognizes a path bar entry as a protocol if it has the form PROTOCOL:// (such as ftp://). SpaceFM recommends a standard URL format regardless of protocol. If the URL is in such a format, SpaceFM will break the URL into parts and assign them to variables ready for your use. You can also use other URL formats (eg those specific to a mount program), but SpaceFM may not correctly assign the parts to variables. The following protocol whitelist elements are recognized: PROTOCOL (eg ssh) url=URL (ssh://...) host=HOSTNAME user=USERNAME mtab_fs=FSTYPE (mounted fs type as shown in mtab) mtab_url=URL (mounted url as shown in mtab) point=MOUNT_POINTFor most protocols, the whitelist will be as simple as the protocol, such as 'ftp' (meaning that this handler will be used to mount ftp:// URLs). For other protocols, you might use a whitelist with additional elements. For example: ssh mtab_fs=fuse.sshfsIn this case, the handler is selected if the protocol is "ssh", which will work when mounting an ssh filesystem. However, when fuse mounts the filesystem, it uses "fuse.sshfs" as the filesystem type, which is listed in mtab (see the output of the mount command). Thus this whitelist also includes "mtab_fs=fuse.sshfs", so this handler will be used for that filesystem type in mtab. This will allow the handler to be used for both mounting ssh URLs and unmounting fuse.sshfs filesystems.
Note: The whitelist mtab_fs= property also may affect what mounted protocols SpaceFM detects and lists in its Devices list. By default, SpaceFM will list most non-block (eg fuse) filesystems which are mounted to a user-readable directory. To have it detect and list another filesystem in the devices list, add the type with mtab_fs=FSTYPE to a protocol handler's whitelist. This will also ensure that your protocol handler, rather than a device handler, is used to unmount and show properties for the mounted protocol. Note that some of the above fields, such as mtab_fs, mtab_url, and point, are only set when performing an unmount. Also, any spaces in the values are replaced with underscores before being tested. To see what handler SpaceFM has selected to mount or unmount a URL, and see the commands being issued, start the Selected Protocol Handler 'ssh': MOUNT [ssh] mtab_fs=fuse.sshfs Selected Protocol Handler 'ssh': UNMOUNT ssh [mtab_fs=fuse.sshfs]This tells you that the 'ssh' protocol handler was used for both MOUNT and UNMOUNT actions. The whitelist of that handler is shown, and the portion(s) of the handler's whitelist which matched are enclosed in square brackets [ ]. For mounting, the URL was recognized with protocol ssh, which matched in the whitelist. For unmounting, the mtab_fs matched the whitelist. After your protocol is mounted, the mount directory may or may not automatically open in SpaceFM (depending on whether SpaceFM can associate a new device with the protocol just mounted based on mtab, mount point, etc.) If it does not open, you can open a mount point after a successful mount command by adding a line such as: [[ $? -eq 0 ]] && spacefm -t "%a" Blacklist Mount Several variables will be replaced before your commands are run: %url% $fm_url %proto% $fm_url_proto %host% $fm_url_host %port% $fm_url_port %user% $fm_url_user %pass% $fm_url_pass %path% $fm_url_path %a auto create mount pointThese variables will be replaced with the appropriate values taken from a standard URL, and the bash equivalents may also be used (eg %url% is the same as $fm_url). In the case of %a, its presence will cause SpaceFM to create a new directory to be used as a mount point for the mount (eg ~/.cache/spacefm/mountpoint, and %a will be replaced with the directory path. When the device is unmounted, this mount point will be removed. Or, if you wish to create your own mount point, or if your mount program automatically creates one in /media (such as udevil), then you may omit %a. In addition to the above variables, SpaceFM's exported bash variables may be used, as well as the substitution variables defined in Command Line. Note that the Mount command does not need to be used to mount a protocol, it may simply open the protocol with a program of your choice. For example, to open http:// URLs with Firefox, put "http" in the handler's whitelist, and use this Mount command: firefox "%url%" &The ampersand (&) tells bash to run the program and move on, without waiting for the program to finish, which is usually appropriate when starting an application. You can also open a website using a SpaceFM socket command, which will guess the user's web browser: spacefm -s run-task web "$fm_url" If a handler's Mount command is empty (or contains only blank lines and comments), that handler will not be used. If no handler is found with a non-empty Mount command, SpaceFM will not handle the protocol, and will display an error to the user. Unmount Several variables will be replaced before your commands are run: %url% $fm_url %proto% $fm_url_proto %host% $fm_url_host %port% $fm_url_port %user% $fm_url_user %path% $fm_url_path %a current mount point $fm_mtab_fs (mounted fs type as shown mtab) $fm_mtab_url (mounted url as shown mtab)Not all of the variables may be filled-in, depending on the protocol. If a protocol handler's Unmount command is empty (or contains only blank lines and comments), that handler will not be used. If no handler is found with a non-empty Unmount command, SpaceFM will not unmount the filesystem, and will display an error to the user. Properties If no applicable protocol handler has a non-empty Properties command, SpaceFM's default properties will be shown.
| ||||||||||||||||||||||||||||||||||||
Contents |
Archives
SpaceFM includes a built-in facility for creating, extracting, and listing the contents of archive files (such as tar.gz or zip files). Open Menu With a default configuration, opening an archive file by double-clicking it in the file list will automatically extract it to a folder of the same name. You can change how SpaceFM opens archives by right-clicking on an archive file and using the Open|Archive Defaults submenu: Open With App Extract Extract To List Contents In addition, the Archive Defaults submenu includes these options: Create Subfolder Write Access Archive Handlers Archive handlers tell SpaceFM how to create, extract, and list the contents of various kinds of archive files (eg tar.gz files). To configure archive handlers, right-click on a known archive file and select Open|Archive Defaults|Archive Handlers. Or, right-click on any file, select New|Archive, and click the Configure button. The list at the left of the Archive Handlers configuration window lists all archive handlers. (Enlarge this window to see the handler commands more clearly.) Click on a handler's name to see its contents. The order of the list is important: Starting from the top, the first handler which matches a file being extracted will be used. You can reorder the list by dragging entries, or using the Up & Down buttons. The right side of the window shows the selected handler's contents. If Enable Handler is unchecked, this handler will never be used. The Name contains the common name for the handler. Next come MIME Type and Pathname text boxes: these determine when this handler will be used. Finally, the Compress, Extract, and List boxes contain scripted commands which will be run by the handler to perform archive functions. MIME Type Pathname Compress Several variables will be replaced before your commands are run: %n: First selected filename/dir to archive %N: All selected filenames/dirs to archive, or (with %O) a single filename %o: Resulting single archive file %O: Resulting archive per source file/directory (use changes %N meaning)When creating an archive, the user first selects one or more files or directories to be included. These are passed to your command via the %n or %N variables, which are replaced with quoted filenames. How these are used will depend on the type of archive you are creating from the selected files: a single archive containing all files, or an archive per source file/directory. If you want to create a single archive containing all selected items, use %o to represent the name of the resulting archive file (which will be chosen by the user at run time). With %o, you will generally use %N to include the list of all selected files. (Or if you only use %n, only the first selected file will be included in your archive.) For example, to create a tar archive, you would use this Compress command: tar -cvf %o %NOther kinds of archiving programs, such as compressing files with GZip, can only operate on one file at a time. In this case, you will use the %O variable (a capital 'O' instead of lowercase) to indicate to SpaceFM that you want your Compress command run multiple times, once for each selected file or directory. In this case, %N will be replaced with a single filename each time the command is run. (If %N is not included, the command will only be run once. If you use %n with %O, it will only be replaced with the first selected file the first time the command is run, and will then be empty "" on any subsequent runs.) For example, to compress all selected files with GZip, use this command: gzip -c %N > %OWhen SpaceFM sees the above command containing %O, it will know to run the gzip command once for each file, and will replace %N with a single filename on each run. It will also replace %O with a different output archive filename on each run, creating multiple files (in this case with the .gz extension). Note: To include a literal '%N' or other string in your command without it being interpreted as a variable, use double percent signs (%%N). In addition to the above variables, or instead of them, SpaceFM's exported bash variables may be used. To create an archive using your handler, select files to be archived in SpaceFM's file list, right-click, and select New|Archive. Select your handler in the Format list. You can also edit the Compress command in this dialog, and the updated command will be saved to your handler. To test your handler commands, run the When running any commands in a terminal, SpaceFM will add a query at the end to keep the terminal open if it sees a non-zero error status from the last command run, or when listing archive contents. If you need to keep the terminal open for other purposes, you can include these lines in your command: echo -n '[ Finished ] Press Enter to close:' read To trap any errors in commands containing multiple lines, you can use the built-in error trap after each line: tar -cvf %o %N || fm_handle_err Extract Several variables will be replaced before your commands are run: %x: Archive file to extract %g: Unique extraction target filename with optional subfolder %G: Unique extraction target filename, never with subfolderIn most cases, you will only need the %x variable to represent the file being extracted, as SpaceFM automatically runs your command in the directory to which files should be extracted. For example, the Extract command for a tar file is simply: tar -xvf %xIn some cases, such as uncompressing a file with GZip, you will want SpaceFM to give you a single non-existing filename to be used as the extraction target. For this purpose you may use %g or %G. %g will cause SpaceFM to substitute a single non-existing filename based on the archive name. If the user has selected the Create Subfolder option, a subfolder will also be created for the file. However, in cases like GZip, it is often unnecessary to create a subfolder for just one file. In this case use %G, which will be substituted with a single non-existing filename in the main extraction directory, and no subfolder will be created (even if the user has option Create Subfolder enabled). For example, when decompressing a GZipped file, rather than create a subfolder for the single output file, SpaceFM simply uncompresses the file to the selected directory. It uses this Extract command to do so: gzip -cd %x > %G In addition to the above variables, or instead of them, SpaceFM's exported bash variables may be used. List | ||||||||||||||||||||||||||||||||||||
Contents |
Files
When you double-click on a file to open it, SpaceFM will use one of the following methods to open the file, in this order of preference:
Note that multiple files may be opened or extracted by selecting them and using Open|Open With Default, subject to the same rules above. For feedback on how SpaceFM is opening files, run the first instance of spacefm in a terminal, and observe the output in the terminal after opening a file in SpaceFM. File handlers are one method of several that SpaceFM may use to open specific types of files, or they can perform any other action when a file is clicked. These handlers work independently of the MIME associations on your system. To configure file handlers, right-click on any file and select Open|File Handlers. The list at the left of the File Handlers configuration window lists all file handlers. (Enlarge this window to see the handler commands more clearly.) Click on a handler's name to see its contents. The order of the list is important: Starting from the top, the first handler which matches a file being opened will be used. You can reorder the list by dragging entries, or using the Up & Down buttons. The right side of the window shows the selected handler's contents. If option 'Enable as a default opener' is checked, this handler will automatically run if you double-click on a file of its type. Or, if the option is unchecked, the handler will only run if you manually select it from the Open menu. The Name and Icon text boxes are used to specify the common name and icon name for the handler, which will appear in the menu and Task Manager. Next come MIME Type and Pathname text boxes: these determine for what files this handler may be used. Finally, the Open Command box contains scripted commands which will be run by the handler to open the file(s), or perform any other function. MIME Type Pathname Open Command Several variables will be replaced before your commands are run:
The presence of %a will cause SpaceFM to create a new directory to be used as a mount point (eg ~/.cache/spacefm/mountpoint, and %a will be replaced with the directory path. This can be used to mount files (eg iso files). When the device is unmounted, this mount point will be removed. For example, this command will mount an iso file using fuseoiso and open the mount point directory in SpaceFM: fuseiso %f %a && spacefm %a & In addition to the above variables, SpaceFM's exported bash variables may be used, as well as all the substitution variables defined in Command Line. When running your commands in a terminal, if you need to keep the terminal open after your command finishes, you can include these lines at the end of your command: echo -n '[ Finished ] Press Enter to close:' read To test your handler commands, run the | ||||||||||||||||||||||||||||||||||||
Contents
|
Options & Defaults
Each handler configuration window includes Options and Defaults buttons. Pressing Defaults will restore the current handler to default values. The handler must be a built-in default handler for this button to be enabled. The Options button opens a popup menu which provides the following options. Note that selecting any of these options automatically clicks Apply first if changes have been made to the current handler. Export Import File Import URL Restore Default Handlers | ||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
Contents |
Introduction
SpaceFM Dialog is a built-in feature of SpaceFM which allows you to easily create and control custom GTK dialogs. Typically such dialogs are shown from scripts to gather information from the user. SpaceFM Dialog allows scripts to easily use much of the power of GTK - a dialog can be as simple as a single message prompt or as complex as a mini-app with lists, editors, and other widgets. Dialog elements can have associated commands which are run when the user takes an action (such as pressing a button ), and internal commands can be used to modify the dialog elements while the dialog is running. When SpaceFM Dialog exits, it writes variables to stdout which can be evaluated directly in bash, or easily parsed in other languages. Although SpaceFM Dialog is relatively easy to use, this portion of the manual assumes you have a basic understanding of command lines and scripts. If you don't, try some of the examples and also consult the Bash Scripting Guide for reference. Also see the IG Example Application plugin. All of the example commands in this section can be pasted as-is into your terminal for a demonstration.
| ||||||||||||||||||||||||||||||||||||
Contents |
Invocation
SpaceFM Dialog runs as a separate instance, whether other instances of SpaceFM are running or not. This means you can use SpaceFM Dialog from within custom command scripts in SpaceFM, or in other scripts which run independently. To see SpaceFM Dialog's help reference, run: $ spacefm -g help SpaceFM Dialog creates a custom GTK dialog based on the GUI elements you specify on the command line, features run-time internal/external commands which can modify elements, and outputs evaluatable/parsable results. Usage: spacefm --dialog|-g {ELEMENT [OPTIONS] [ARGUMENTS...]} ... Example: spacefm -g --label "A message" --button ok ELEMENT: OPTIONS & ARGUMENTS: -------- -------------------- --title TEXT|@FILE Set window title --window-icon ICON|@FILE Set window icon --label [--wrap|--nowrap] LABEL|@FILE Add a text label --button LABEL[:ICON]|STOCK|@FILE [COMMAND...] Add STOCK dialog button, or LABEL button with ICON --free-button LABEL[:ICON]|STOCK|@FILE [COMMAND...] Add STOCK button, or LABEL button with ICON anywhere --input [--select START[:END]] [TEXT|@FILE [COMMAND...]] Add a text entry --input-large [--select START[:END]] [TEXT|@FILE [COMMAND...]] Add a large text entry --password [TEXT|@FILE [COMMAND...]] Add a password entry --viewer [--scroll] FILE|PIPE [SAVEFILE] Add a file or pipe viewer --editor [FILE [SAVEFILE]] Add multi-line text editor --check LABEL [VALUE|@FILE [COMMAND...]] Add a checkbox option --radio LABEL [VALUE|@FILE [COMMAND...]] Add a radio option --icon ICON|@FILE [COMMAND...] Add an icon --image FILE|@FILE [COMMAND...] Add an image --progress [VALUE|pulse|@FILE] Add a progress bar --hsep ( no arguments ) Add a horizontal line separator --vsep ( no arguments ) Add a vertical line separator --timeout [DELAY|@FILE] Automatically close window after DELAY seconds --drop {TEXT... --}|@FILE [DEFAULT|+N|@FILE [COMMAND...]] Add a drop-down list. COMMAND run when clicked. --combo {TEXT... --}|@FILE [DEFAULT|+N|@FILE [COMMAND...]] Add a combo list. COMMAND run when Enter pressed. --list {[^HEAD[:TYPE]] [--colwidth=W] TEXT... --}|@FILE [COMMAND...]] Add a list box. COMMAND run when double-clicked. --mlist {[^HEAD[:TYPE]] [--colwidth=W] TEXT... --}|@FILE [COMMAND...]] Add a list box with multiple selections --chooser [CHOOSER-OPTIONS] [DIR|FILE|@FILE [COMMAND...]] Options: [--save] [--dir] [--multi] [--filter F[:F...]] --prefix NAME|@FILE Set base variable name (Default: "dialog") --window-size "WIDTHxHEIGHT [PAD]"|@FILE Set minimum width, height, padding (-1 = don't change) --hbox [--compact] [PAD|@FILE] Add following widgets to a horizontal box --vbox [--compact] [PAD|@FILE] Add following widgets to a vertical box --close-box Close the current box of widgets --keypress KEYCODE MODIFIER COMMAND... Run COMMAND when a key combination is pressed --click COMMAND... Run COMMAND when an element is clicked or focused --window-close COMMAND... Run COMMAND on window close attempt --command FILE|PIPE [COMMAND...] Read commands from FILE or PIPE. COMMAND for init. The following arguments may be used as shown above: STOCK ok|cancel|close|open|yes|no|apply|delete|edit|help|save|stop ICON An icon name, eg: gtk-open @FILE A text file from which to read a value. In some cases this file is monitored, so writing a new value to the file will update the element. In other cases, the file specifies an initial value. SAVEFILE A viewer's or editor's contents are saved to this file. COMMAND An internal command or executable followed by arguments. Separate multiple commands with a -- argument. The following substitutions may be used in COMMANDs: %n Name of the current element %v Value of the current element %NAME Value of element named NAME (eg: %input1) %(command) stdout from a bash command line %% % LABEL The following escape sequences in LABEL are unescaped: \n newline \t tab \" " \\ \ In --label elements only, if the first character in LABEL is a tilde (~), pango markup may be used. For example: --label '~This is plain. <b>This is bold.</b>' In addition to the OPTIONS listed above, --compact or --expand options may be added to any element. Also, a --font option may be used with most element types to change the element's font and font size. For example: --input --font "Times New Roman 16" "Default Text" INTERNAL COMMANDS: noop ( any arguments ) No operation - does nothing but evaluate arguments close [REVERSE] Close the dialog press BUTTON-NAME Press button named BUTTON-NAME set NAME VALUE Set element NAME to VALUE select NAME [VALUE] Select item VALUE (or first/all) in element NAME unselect NAME [VALUE] Unselect item VALUE (or all) in element NAME focus [NAME [REVERSE]] Focus element NAME hide NAME [REVERSE] Hide element NAME show [NAME [REVERSE]] Show element NAME if previously hidden disable NAME [REVERSE] Disable element NAME enable NAME [REVERSE] Enable element NAME if previously disabled source FILE Save files and write source output to FILE Usage spacefm -g ELEMENT [OPTIONS] [ARGUMENTS] \ ELEMENT [OPTIONS] [ARGUMENTS] \ ELEMENT [OPTIONS] [ARGUMENTS] \ ...where each ELEMENT has its own options and arguments. An element represents one piece of the dialog. It may be a widget, such as a label or button, or it may be an invisible element which controls how the dialog looks or behaves. For example, to show a dialog with a message label and an OK button, run this command: spacefm -g --label "This is a message." \ --button okNote: The forward slash (\) at the end of a line tells the terminal that the command is continued on the next line. You can select both lines above, copy them, and paste them into a terminal to run the above example; it is not necessary to copy and paste each line individually. In this manual, SpaceFM Dialog commands are always shown with at most one element on each line for clarity. These multi-line commands can also be pasted directly into scripts. OPTIONS may include options specific to the element type. In addition, most elements accept a --font FONTNAME option to specify a font for the widget's text. Also, all elements accept --compact or --expand options to force how an element is packed into the current box. Evaluating The Output #!/bin/bash # SpaceFM Dialog source output - execute this output to set variables # Example: eval "`spacefm --dialog --label "Message" --button ok`" dialog_label1='This is a message.' dialog_pressed='button1' dialog_pressed_index='0' dialog_pressed_label='ok' dialog_button1='ok' dialog_windowsize='450x100'The above source output, written to stdout, is produced by the dialog to allow you to easily use element values in your script. (To get this output while the dialog is still running, use source.) If using bash or another compatible shell, you can automatically evaluate this output to set the variables. For example, you can run: eval "`spacefm -g --label "This is a message." \ --button ok`"Using this method, you will no longer see the output in the terminal when the dialog closes. Instead, the output is fed into eval, which reads the variable values. A command enclosed in backticks (`), not to be confused with apostrophes ('), evaluates to a string containing the stdout output of the command. This output is then double-quoted (") and passed to eval, which interprets it (sets the variables). (Be sure to double-quote the backticks as shown above or some data may be lost!) After running the above command, we can see the value is set: echo "$dialog_pressed" button1If you would like the output to also be written in the terminal, you can use the following method instead: out="`spacefm -g --label "This is a message." \ --button ok`" eval "$out" # read echo "$out" # displayThe above commands place spacefm's output into the variable 'out', then pass that value to eval to set the variables, then echo writes the output to the terminal for you to see. Yet another method is to write the output to a file, then source the file. For example: spacefm -g --label "This is a message." \ --button ok > /tmp/outputfile source /tmp/outputfile # read cat /tmp/outputfile # display rm /tmp/outputfile # cleanup In general, anytime you need to use the dialog's variables in your script, you will want to use one of the above methods to evaluate the dialog's output. Or, if your shell doesn't support eval, you can parse the output manually.
| ||||||||||||||||||||||||||||||||||||
Contents |
Simple Elements
Elements tell SpaceFM Dialog how to build your dialog. Each element is similar to a command line - it includes an element followed by arguments. When SpaceFM Dialog sees a new element on the command line, it knows the arguments for the previous element have ended. Most visible elements (widgets) are stacked vertically in the dialog (in a vbox), while buttons are packed horizontally at the bottom of the dialog:
ELEMENT2 ELEMENT3 BUTTON1 BUTTON2 --title The --title element sets the title of the dialog window ("SpaceFM Dialog" is the default title if no --title element is used). For example: spacefm -g --title "A Window Title"--title also accepts a file instead of a string. For example: echo "A Window Title" > /tmp/dialog-title spacefm -g --title @/tmp/dialog-titleThe "at" sign (@) indicates that a file path is being specified, and that SpaceFM Dialog should read the value from the first line of the file /tmp/dialog-title. The file is also watched for changes. This method allows you to later change the window title. As the dialog is running, in another terminal run: echo "Another Window Title" > /tmp/dialog-titleand the dialog window's title will change to reflect the new value. Thus using @FILE is one method which allows you to dynamically change the dialog as its running (commands being another method). In commands, the value of a title element (%title1) is the title's TEXT. Also note that even if no --title element has been added to the dialog, you can later use the set command to set 'title' (no numeric suffix).
--window-icon The --window-icon element sets the dialog window's icon ("spacefm-48-pyramid-blue" is the default icon if no --window-icon element is used). For example: spacefm -g --window-icon gtk-open--window-icon also accepts a file instead of a string. For example: echo "gtk-open" > /tmp/dialog-wicon spacefm -g --window-icon @/tmp/dialog-wiconThe icon name will be read from the first line of the file /tmp/dialog-wicon. The file is also watched for changes, allowing you to later change the window icon. As the dialog is running, in another terminal run: echo "gtk-save" > /tmp/dialog-wiconand the dialog window's icon will change to reflect the new value. In commands, the value of a window-icon (%windowicon1) is the icon name (ICON). Also note that even if no --window-icon element has been added to the dialog, you can later use the set command to set 'windowicon' (no numeric suffix). See also: --window-size
--label The --label element adds a GTK label widget to the dialog, which is used to display one or more lines of text, such as a message for the user or a label for an input box. For example: spacefm -g --label "The process is complete."--label also accepts a file instead of a string. For example: echo "The process is complete." > /tmp/dialog-label spacefm -g --label @/tmp/dialog-labelThe label's text will be read from the file /tmp/dialog-label (which may contain multiple lines). The file is also watched for changes, allowing you to later change the label's text. As the dialog is running, in another terminal run: echo "Another processs is complete." > /tmp/dialog-labeland the text in the dialog window will change to reflect the new value in the file. As with most elements, you can add multiple --label elements to a dialog. Some escape sequences are unescaped when LABEL is read:
For example, to create a label with two lines: spacefm -g --label "This is line 1.\nThis is line 2." Note that you can also set a label to multiple lines by specifying a @FILE which contains multiple lines, in which case \n is not needed (but may be used in files too). Labels can also include Pango markup text, which can be used to italicize, bold, and otherwise stylize portions of text. The --label element (only) recognizes the prefix character tilde (~) to indicate that your text is Pango markup. For example: spacefm -g --label "~This is plain. <b>This is bold.</b>" Labels accept a --wrap or --nowrap option to specify if the text in the label is to be wrapped to multiple lines. If neither option is specified, the GTK2 default is to always wrap, and the GTK3 default is to wrap unless the label is packed into an --hbox element. Like most elements, --label also accepts a --font option to change the font and font size of the text: spacefm -g --label --font "Times New Roman 16" "The process is complete."Note that the --font option must come directly after the --label element. In general it is best to use the default font unless your script is only intended for your own use. In commands, the value of a label (eg %label1) is the text of the label.
--button The --button element adds a button to the dialog. All buttons are packed horizontally at the bottom of the dialog, in the order in which they are added (to add a button in the upper part of the dialog, use a --free-button instead). Most dialogs should include at least an "OK" button. The easiest way to add a complete button is to use a STOCK name, which may be any one of: For example, to add a stock OK button: spacefm -g --button okThe button will include the stock gtk-ok icon on it (taken from your icon theme), and an "OK" label. If you don't want to use a stock button, you can include a custom button label instead: spacefm -g --button _UpdateThe underscore (_), which is optional, indicates that 'U' is to be shown as the shortcut key for this button (Alt-U). Also note that a button label may contain multiple lines if desired. You can also add an icon to your button using a colon: spacefm -g --button _Update:gtk-apply--button also accepts a file instead of a string. For example: echo "_Update:gtk-apply" > /tmp/dialog-button spacefm -g --button @/tmp/dialog-buttonThe button's label and icon will be read from the first line of the file /tmp/dialog-button. The file is also watched for changes, allowing you to later change the button's appearance. As the dialog is running, in another terminal run: echo "close" > /tmp/dialog-buttonand the button in the dialog window will change to reflect the new value in the file. When the user presses a button, the dialog window will close if no COMMAND has been associated with the button. The output will include several variables to allow your script to determine what button was pressed. For example: dialog_pressed='button1' dialog_pressed_index='0' dialog_pressed_label='_Update:gtk-apply'The first, "$dialog_pressed", contains the name of the button which was pressed to close the window, in this case "button1" (the first button added). "$dialog_pressed_index" contains the index of the button. Buttons are indexed left to right, starting from 0, so the first button you add has index 0, the second index 1, etc. Finally, "$dialog_pressed_label" contains the "LABEL[:ICON]" used to create the button. Thus your script can evaluate what button was pressed and take an action, as shown in the example script below: #!/bin/bash # This script shows a Yes/No dialog # Use QUOTED eval to read variables output by SpaceFM Dialog: eval "`spacefm -g --label "Are you sure?" --button yes --button no`" if [[ "$dialog_pressed" == "button1" ]]; then echo "User pressed Yes - take some action" else echo "User did NOT press Yes - abort" fi Note: The stock 'cancel' button has a special function. If it is used to close the dialog (no COMMAND has been associated with the button), element @FILE values will NOT be saved. In this case, the element values written to stdout may not match the values stored in @FILEs. You can perform a source command first if you do want values to be written for @FILEs when Cancel is clicked. [Note: In SpaceFM 0.9.3 and prior, element @FILE values WERE saved when the user pressed Cancel.] Note: If the window is closed by the user pressing the X in the top-right corner, or by pressing Alt-F4, "$dialog_pressed" will be empty (no button was pressed) and "$dialog_pressed_index" will be -2. Also, element @FILE values will NOT be saved, as if the user clicked a Cancel button. If a command is added to a button, then the dialog will not necessarily close when the button is pressed. Instead, the COMMAND(s) will be run. The value of a button (eg %v, %button1, etc) is the "LABEL[:ICON]" used to create the button. The following example creates a dialog with a label and a button. When the button is pressed, the label is set to the current date. spacefm -g --label \ --button 'Get Date' set label1 '%(date)' --free-button A --free-button element is similar to a --button, except that it is packed into the top area of the dialog like any other widget, instead of being placed in the horizontal row of buttons at the bottom. Like a --button, if the user presses a --free-button that has no COMMAND, the dialog window will be closed. The value of "$dialog_pressed_index" will always be -1 for a --free-button.
--input An --input element adds a GTK entry widget to the dialog, which allows the user to enter text in a single-line box. This can be as simple as: spacefm -g --inputIf you would like the box to already have default text in it when the dialog is first shown, add your text on the command line: spacefm -g --input "Some default text"--input also accepts a file instead of a string. For example: echo "Some default text" > /tmp/dialog-input spacefm -g --input @/tmp/dialog-input --button okThe input's default text will be read from the first line of the file. The file is also watched for changes, allowing you to later change the input's contents. As the dialog is running, in another terminal run: echo "Some other text" > /tmp/dialog-inputand the text in the input box will change to reflect the value in the file. Also, when the dialog is closed, the text in the input will be saved to the file. This method can be used to have the dialog remember the last text entered. The next time the dialog is run, assuming the file hasn't been deleted, the input will show the text from the previous dialog. A portion of the text may be selected when the dialog first opens using the --select option. By default, all of the text is selected. If you only want to select a portion, use a command like: spacefm -g --input --select 3:6 "Some default text"Note that the --select option must come directly after the --input element. The first number (START) is the first character to select, and the second number (:END), if included, is the last. So "--select 3:6" will select characters 3 thru 6. Note that counting starts from zero: the first chracter has index 0, the second 1, etc. If END is negative or omitted, text will be selected from START through the end of the text. --input also accepts a --font option to change the font and font size of the text: spacefm -g --input --font "Times New Roman 16" "Some default text"When the user presses Enter in an input box, one of several things may happen. If no COMMAND is associated with the input, then the right-most button at the bottom of the dialog will be automatically pressed. If the dialog has no buttons, nothing will happen. Or, if a command is added to the input, the COMMAND(s) will be run and no button will be automatically pressed. The value of an input (eg %v, %input1, etc) is the text in the box when the command is run. In SpaceFM Dialog's output, the value of an input can be read from, for example, "$dialog_input1". The following example creates a dialog with an input and a label. When Enter is pressed in the input box, the text of the input is copied to the label. spacefm -g --label "Enter some text and press Enter:" \ --input "" set label2 %v \ --label \ --button close --input-large An --input-large element works identically to an --input, except that the text box is larger. It still contains a single line of text, but the text may be wrapped to several display lines. Such boxes are useful for editing long lines, such as a file path.
--password A --password element, used to enter a password, is similar to an --input, except that the text is hidden. Also, the options --select and --font have no effect on a --password element.
--viewer A --viewer element adds a read-only multi-line text box to the dialog, and may be used to view the contents of a file or the data written to a pipe. By writing text to a temporary file, a viewer can also be used to show the user larger amounts of text which won't fit in a --label. A vertical scroll bar will automatically appear when the text exceeds the size of the box. To view the static or changing contents of a regular file: spacefm -g --viewer /etc/fstabAnytime the contents of the file changes, the viewer will be updated. If you always want the viewer to scroll to the end of the file (except when the user pulls the scroll handle up), include the --scroll option: spacefm -g --viewer --scroll /etc/fstab A --viewer may also be used to monitor data written to a pipe. This can be used to show the user changing information. For example: # First, create a pipe: mkfifo /tmp/dialog-pipe # Next, monitor the pipe: spacefm -g --viewer /tmp/dialog-pipeWhen you write text to the pipe, it will be added to the viewer box. For example, while the dialog is running, in another terminal run: echo "some text to a pipe" > /tmp/dialog-pipeOr: # Press Ctrl-C to cancel: while (( 1 )); do date > /tmp/dialog-pipe; sleep 1; doneWhen the dialog is closed, the contents of the viewer are lost unless a SAVEFILE is also specified: spacefm -g --viewer /tmp/dialog-pipe /tmp/dialog-pipe-contents \ --button ok In commands, the value of a viewer (eg %viewer1) is the path of the file being viewed. To change the file being viewed, use set (eg 'set viewer1 /etc/mtab'). Also note that the contents of the viewer are also saved to SAVEFILE whenever the internal command source is run. The following example creates a dialog with a file chooser and a viewer. When the user double-clicks a text file in the chooser, the file's contents are displayed. spacefm -g --label "Double-click a file to view:" \ --chooser --filter text/plain . set viewer1 %v \ --viewer \ --button close --editor Similar to a --viewer, an --editor element adds a multi-line text box to the dialog. Unlike a viewer, the user is able to edit the text in the box. To create an empty editor: spacefm -g --editorOr, to load a text file into the editor: spacefm -g --editor /etc/fstabWhen the dialog is closed, the contents of the editor are lost unless a SAVEFILE is also specified: spacefm -g --editor /etc/fstab /tmp/fstab-edited \ --button okWhen the above dialog is closed via the OK button, the contents of the editor will be automatically saved to /tmp/fstab-edited. Your script can then use this file to replace the original if the user pressed the appropriate button, etc. Note: It is possible to set FILE and SAVEFILE to the same path, in which case the original file will automatically be overwritten when the dialog is closed with any button except Cancel. In commands, the value of an editor (eg %editor1) is the path of the file last loaded. To load a file into the editor, use set (eg 'set editor1 /etc/mtab'). Also note that the contents of the editor are also saved to SAVEFILE whenever the internal command source is run. The following example creates a dialog with a file chooser and an editor. When the user double-clicks a text file in the chooser, the file's contents are displayed in the editor. If the user clicks the Save button, the editor's contents are saved to a temporary file (they are also saved when the dialog closes). spacefm -g --label "Double-click a file to edit a copy:" \ --chooser --filter text/plain . set editor1 %v \ --editor "" /tmp/dialog-copy \ --label \ --button save source /dev/null -- \ set label2 "Copy saved to /tmp/dialog-copy" \ --button close --check A --check element adds a checkbox and associated label to the dialog, allowing the user to check or uncheck the option. The value of the checkbox can be read from a variable when the dialog closes, or it can be used by internal commands while the dialog is running. For example: spacefm -g --check "Option One"By default, the checkbox will not have a check in it. To set a default value for the checkbox, specify "false" or "0" (unchecked), or "true" or "1" (checked). For example: spacefm -g --check "Option One" 1--check also accepts a file instead of a string for the VALUE (but not for the LABEL). For example: echo 1 > /tmp/dialog-check spacefm -g --check "Option One" @/tmp/dialog-check \ --button okThe checkbox's default value will be read from the first line of the file. The file is also watched for changes, allowing you to later change the state of the checkbox. As the dialog is running, in another terminal run: echo 0 > /tmp/dialog-checkand the checkbox state will change to reflect the value in the file. Also, when the dialog is closed with any button except Cancel, the state of the checkbox will be saved to the file. This method can be used to have the dialog remember the state. The next time the dialog is run, assuming the file hasn't been deleted, the checkbox will have the same state as when the previous dialog was closed. If a command is included, the COMMAND(s) will be run whenever the checkbox changes state, either due to the user clicking it, its @FILE value changing, or its value being set with an internal command. (The command is NOT run when the state is set to a default VALUE during dialog creation.) In commands, the value of a --check element (eg %check1) will equal 1 or 0, reflecting whether the box is checked or not. If internal command set is used on a --check and the value is not "0", "false", "1", or "true", the check's LABEL is set to the value (eg "set check1 "A new option label"), instead of the state being changed. In SpaceFM Dialog's output, the value of a check can be read from, for example, "$dialog_check1". The following example creates a dialog with a check and a label. If the checkbox is checked, the label is shown, otherwise it is hidden. spacefm -g --check "Show text" 1 show label1 %v \ --label "Some text"The check's value in the above command works as a reversal in the show command - if %v is "0" then label1 is hidden, otherwise it is shown. --radio A --radio element is similar to a --check, adding a radio button and associated label to the dialog, allowing the user to select or unselect the option. However, only one of a set of radio buttons may be selected at a given time - selecting one will unselect the others in the set. To add a --radio element: spacefm -g --radio "Apples"By default, the first --radio element of a set will be selected. To select another --radio element, include a default VALUE, specifying "false" or "0" (unselected), or "true" or "1" (selected). For example: spacefm -g --radio "Apples" 1Remember that only one --radio can be selected, so the last --radio element you add with a 1 VALUE will be selected. Consecutive --radio elements are part of the same set, until a visible non-radio element is added. For example, these elements will be part of a set: spacefm -g --radio "Apples" \ --radio "Oranges" 1 \ --radio "Pears"In the above example, Oranges will be selected by default. As with --check elements, a @FILE may be substituted for VALUE, causing SpaceFM Dialog to read the value from the first line of the file. The state will be updated if the file is changed. The value will also be written to the file when the dialog closes. To have a dialog remember the selection of a radio set, you must specify a different file for each element. For example: spacefm -g --radio "Apples" @/tmp/dialog-radio1 \ --radio "Oranges" @/tmp/dialog-radio2 \ --radio "Pears" @/tmp/dialog-radio3 \ --button okThe files do not need to be created (they will be created automatically), unless you want to select an option other than the first. If you run the above command multiple times, you will note that your selection is remembered from the previously closed dialog. If a command is included, the COMMAND(s) will be run whenever the radio button is selected (but not when it is unselected), either due to the user clicking it, its @FILE value changing, or its value being set with an internal command. (The command is NOT run when the state is set to a default VALUE during dialog creation.) In commands, the value of a --radio element (eg %radio1) will equal 1 or 0. If internal command set is used on a --radio and the value is not "0", "false", "1", or "true", the radio's LABEL is set to the value (eg "set radio1 "A new option label"), instead of the state being changed. In SpaceFM Dialog's output, the value of each --radio in a set can be read from, for example, "$dialog_radio1", "$dialog_radio2", etc.
--icon An --icon element packs a dialog-sized icon into the dialog. ICON specifies an icon name (not a path - to use a path use --image instead). The icon is selected using your current icon theme. For example: spacefm -g --icon gtk-open--icon also accepts a file instead of a string. For example: echo "gtk-open" > /tmp/dialog-icon spacefm -g --icon @/tmp/dialog-iconIn this case, the icon name is read from the first line of the file /tmp/dialog-icon. This file is also watched, so when its contents change, the icon will change. As the dialog is running, in another terminal run: echo "gtk-close" > /tmp/dialog-iconand the icon will change to reflect the value in the file. If a command is included, the COMMAND(s) will be run whenever the icon is clicked. For example: spacefm -g --icon gtk-open bash -c 'echo "# %n clicked %v" >&2'When you run the above command and click the icon in the dialog, a message will be written to the terminal showing what mouse button was pressed and the location of the click. Both values are in the element's value (%v). Note that the location is relative to the upper-left corner of the event box holding the icon, not necessarily the corner of the icon itself (pack the icon into a compact --vbox for the latter). In commands, the value of an --icon element (eg %icon1) when referenced from another element will equal the icon name, while the current --icon element's value (%v) will equal the mouse button and click location. If internal command set is used on an --icon, the icon name is changed.
--image An --image element packs an image into the dialog. If FILE isn't found or can't be loaded, the resulting image will display a 'broken image' icon. If the file contains an animation, the image will contain an animation. Not all image formats are supported. For example: spacefm -g --image ~/example-image.jpg--image also accepts a file instead of a string. For example: echo "~/example-image.jpg" > /tmp/dialog-image spacefm -g --image @/tmp/dialog-imageIn this case, the image FILE path is read from the first line of the file /tmp/dialog-image. This file is also watched, so when its contents change, the image will change. As the dialog is running, in another terminal run: echo "~/another-image.jpg" > /tmp/dialog-imageand the image will change to reflect the value in the file. Images are not resized. They are displayed at their full size, so only small images can be comfortably packed into a dialog. [Resizing options may be added soon - check this manual for updates.] If a command is included, the COMMAND(s) will be run whenever the image is clicked. For example: spacefm -g --image ~/example-image.jpg bash -c 'echo "# %n clicked %v" >&2'When you run the above command and click the image in the dialog, a message will be written to stderr of the terminal showing what mouse button was pressed and the location of the click (bash -c is required to send the output to stderr instead of stdout). Both values are in the element's value (%v). Note that the location is relative to the upper-left corner of the event box holding the image, not necessarily the corner of the image itself (pack the image into a compact --vbox for the latter). In commands, the value of an --image element (eg %image1) when referenced from another element will equal the image FILE path, while the current --image element's value (%v) will equal the mouse button and click location. If internal command set is used on an --image, the image path is changed.
--progress A --progress element adds a progress bar to the dialog. For example: spacefm -g --progressBy default, the progress bar will pulse automatically. You can also specify an initial VALUE (eg '100' or 'pulse'). To update the progress bar, it is most convenient to specify @FILE so the progress bar's value is read from FILE. For example: spacefm -g --progress @/tmp/dialog-progressThe file is watched for changes. To later update the value of the progress bar: echo 50 > /tmp/dialog-progressOr, the progress bar will advance one pulse step each time you run: echo pulse > /tmp/dialog-progressOr, the progress bar will pulsate automatically if you run: echo auto-pulse > /tmp/dialog-progressOr, you can set additional text to appear in the progress bar: echo "25 % copying" > /tmp/dialog-progressOr, you can set just the progress bar length with no text in the bar (note the space): echo "75 " > /tmp/dialog-progressOr, you can set just the progress bar text, which will not change the bar length: echo "text" > /tmp/dialog-progress In commands, the value of a --progress element can be set using the internal set command (eg 'set progress1 "35 %"' or 'set progress1 pulse').
--hsep An --hsep element adds a horizontal line separator to the dialog. The line will extend the full width of whatever box the widget is packed into.
--vsep A --vsep element adds a vertical line separator to the dialog. The line will extend to the full height of whatever box the widget is packed into.
--timeout A --timeout element adds a Pause button to the dialog, which causes the dialog window to close automatically after DELAY seconds, unless the Pause button has been pressed. In commands, the timeout value can be changed while the dialog is running with 'set timeout1 VALUE'. In SpaceFM Dialog's output, if the window closes due to the timeout, "$dialog_pressed" will equal "timeout1", and "$dialog_pressed_index" will equal -3. (The timeout button is not indexed with the other buttons.)
| ||||||||||||||||||||||||||||||||||||
Contents |
List Elements
--drop A --drop element adds a drop-down list to the dialog, allowing the user to select a single option or item in the list. The contents of the list can be passed to SpaceFM Dialog as arguments on the command line or as a file. To pass the list on the command line: spacefm -g --drop "Item One" "Item Two" "Item Three" --Especially if there are any arguments following the list, be sure to end the list with a '--' argument as shown above. By default, the list will have no item selected. To select a default item, add it to the command line after '--': spacefm -g --drop "Item One" "Item Two" "Item Three" -- "Item Two"Or, pass the index of the default item with a plus sign (+) (indexing starts counting from zero): spacefm -g --drop "Item One" "Item Two" "Item Three" -- +1To instead read the list from the lines of a text file: # First, create a text file containing multiple lines of text: echo -e "Item One\nItem Two\nItem Three" > /tmp/dialog-drop # Tell spacefm to load the drop list from a file: spacefm -g --drop @/tmp/dialog-dropTo specify a default item, add the default item value or index number. For example: spacefm -g --drop @/tmp/dialog-drop +1The file /tmp/dialog-drop in the above example will be watched. When its contents change, the list contents will be updated to reflect the new list in the file. The default value, as an item value or a +N index, may also be read from the contents of a file: echo "Item Two" > /tmp/dialog-dropdef spacefm -g --drop @/tmp/dialog-drop @/tmp/dialog-dropdef \ --button okThe file /tmp/dialog-dropdef in the above example will NOT be watched - changing its contents while the dialog is running will have no effect. However, when the dialog is closed with any button except Cancel, the currently selected item in the list will be written to the file. This will cause the dialog to remember the selected value between sessions. If you run the above spacefm command multiple times, you will note that your selection is remembered from the previously closed dialog. If a command is included, the COMMAND(s) will be run whenever the list selection changes. (The command is NOT run when the default item is set during dialog creation.) To include a COMMAND, be sure to include a DEFAULT value on the command line, or "" for no default. In commands, the value of a --drop element (eg %drop1) will equal the currently selected item in the list. If internal command set is used on a --drop element, the command will set a new file to read the list from. Or, if the set value is not a file, will select an item in the list. The internal select command can also be used to select an item in the list. In SpaceFM Dialog's output, the selected item of a --drop element can be read from, for example, "$dialog_drop1", and its index from "$dialog_drop1_index". (An index of -1 indicates no item is selected.)
--combo A --combo element is similar to a --drop element, except that it adds a text entry box, so the user can either select an item from the list, or enter custom text. The list is created the same way as a --drop list, either with arguments on the command line, or reading the list from a file. However, the DEFAULT value will be set in the text entry box even if it isn't in the list. When the user presses Enter in the text entry box, one of several things may happen. If no COMMAND is associated with the input, then the right-most button at the bottom of the dialog will be automatically pressed. If the dialog has no buttons, nothing will happen. Or, if a command is included, the COMMAND(s) will be run when the user presses Enter in the text entry box, and no button will be automatically pressed. To include a COMMAND, be sure to include a DEFAULT value on the command line, or "" for no default. To run a command when the text entry box of a --combo element gets focus, add a --click element. In commands, the value of a --combo element (eg %combo1) will equal the text in the entry box. If internal command set is used on a --combo element, the command will set a new file to read the list from. Or, if the set value is not a file, will set the text in the entry box. The internal select command can also be used to set the text in the box, and the unselect command will clear the text. In SpaceFM Dialog's output, the entry box text of a --combo element can be read from, for example, "$dialog_combo1", and its index from "$dialog_combo1_index". The index will be set only if the user selects an item from the list, otherwise it will be -1 (even if the text in the entry box equals an item in the list).
--list A --list element adds a list box to the dialog, which includes a scroll bar when the list is long, and allows the user to select a single item or no item in the list. The list is created similarly to a --drop or --combo list, either with arguments on the command line, or reading the list from a file. However, no default item may be selected on the command line, and several additional, optional components may be added. To create a simple list: spacefm -g --list "Item One" "Item Two" "Item Three" --Or, in a script, you can create an array and populate the list from the array. For example: #!/bin/bash # This script creates a list from an array alist=( "Item One" "Item Two" "Item Three" ) eval "`spacefm -g --list "${alist[@]}" -- --button ok`" if (( dialog_list1_index != -1 )); then echo "Item selected: $dialog_list1" echo "Index selected: $dialog_list1_index = ${alist[dialog_list1_index]}" else echo "No item selected." fiThe above method has the advantage that the list indices match your array indices. Or, create a text file and read the list from it: # First, create a text file containing multiple lines of text: echo -e "Item One\nItem Two\nItem Three" > /tmp/dialog-list # Tell spacefm to load the list from a file: spacefm -g --list @/tmp/dialog-listThe file /tmp/dialog-list in the above example will be watched. When its contents change, the list contents will be updated to reflect the new list in the file. Lists can also contain multiple columns. Column headers are used to both set the column header label, and to define when a new column begins. A column header is an argument that begins with a caret (^). For example: spacefm -g --list ^Letter A B C ^Number 1 2 3 --The above command will create a list with three rows and two columns, where "Letter" and "Number" are column headers. By adding column headers, the list also becomes sortable - the user can click on a column header to sort by that column (and click again for a descending vs. ascending sort). You can also set a column width if desired. Include a --colwidth=WIDTH option anywhere after the start of a column. (Columns have a minimum width of 50.) For example: spacefm -g --list ^Letter A B C ^Number --colwidth=200 1 2 3 -- Usually it's easier to create a multi-column list using a file. For example, create a text file with these contents: ^Letter A B C ^Number --colwidth=200 1 2 3Save the above text to a file named '/tmp/dialog-list'. Note that the --colwidth option must be placed on a line by itself in a file. Then load the file: spacefm -g --list @/tmp/dialog-listIt's also possible to set a data type for a column. Data types include 'string' (the default type if none is specified), 'int' (integer), 'double' (a double-precision floating point number), and 'progress' (a progress bar with values ranging 0-100). Different data types will be displayed and sorted differently. To define a data type for a column, include it in the column header after a colon. For example, edit the '/tmp/dialog-list' so it contains this list with three columns: ^Job A B C ^Number:int 1 2 3 ^Complete:progress 35 75 90In the above example, the "Job" column is type 'string', the "Number" column contains integers, and the "Complete" column will show progress bars. Once again, show the list: spacefm -g --list @/tmp/dialog-listNote: If you want a column header to end with a colon (eg "Number:"), and you want to define a data type, use two colons (eg "Number::int"). If a command is included, the COMMAND(s) will be run when the user double-clicks an item in the list. If no COMMAND is included, double-clicking an item in the list will automatically press the right-most dialog button, if present. To detect single clicks in a list (item selection), add a --click element. In commands, the value of a --list element (eg %list1) will equal the currently selected item (first column data, or hidden column - see below). If internal command set is used on a --list element, the command will set a new file to read the list from. The internal select command will select an item in the list, and the unselect command will unselect any selection. In SpaceFM Dialog's output, the selected item can be read from, for example, "$dialog_list1", and its index from "$dialog_list1_index" (-1 if nothing is selected). It's also possible to set a hidden data column to be used for return values. Rather than returning the first column data of the selected item, the hidden column data will be returned. To set a hidden column, name the first column header "HIDE" (uppercase) (with optional data type :TYPE). For example: ^HIDE return1 return2 return3 ^Job A B C ^Number:int 1 2 3 ^Complete:progress 35 75 90The above list still has only three visible columns. The values in the "HIDE" column will be returned in the dialog's output, and in commands. For example, save the above list as '/tmp/dialog-list' and run: spacefm -g --list @/tmp/dialog-list bash -c 'echo "# %n = %v" >&2'When you double-click an item in the list, the return value will be printed to the terminal (eg "# list1 = return2"). bash -c is required to send the output to stderr instead of stdout. --mlist An --mlist element behaves like a --list except that multiple items may be selected. (To select more than one item, hold down Ctrl and click, or hold down Ctrl and press arrows keys and Space to select.) In SpaceFM Dialog's output, the --mlist element variable (eg "$dialog_mlist1") is set to an array containing all selected items, and the index variable (eg $dialog_mlist1_index) is set to an array containing the indices of all selected items. For example: #!/bin/bash # This script creates an mlist from an array alist=( Aaa Bbb Ccc Ddd Eee Fff Ggg Hhh ) eval "`spacefm -g --mlist "${alist[@]}" -- --button ok`" if [[ "${dialog_mlist1[0]}" != "" ]]; then echo "Selected items:" for item in "${dialog_mlist1[@]}"; do echo " $item" done else echo "No item selected." fiIn commands, the --mlist element's value (eg %v, %mlist1) is set to a list of quoted values (eg 'Aaa' 'Bcc' 'Ccc') which can be passed to an executable's command line. --chooser A --chooser element adds a GTK file chooser to the dialog, which includes a file list, recent places list, and other widgets as a group, allowing the user to select or enter the name of a file or directory. Filters can be added to control what types of files are displayed. To allow the user to select a file which already exists: spacefm -g --chooser If no path is specified, the chooser will open in "Recently Used". You can add a directory to the command line to make the chooser open in a default directory, or add a file path to select a file by default. For example: spacefm -g --chooser /etc/fstab The default file or directory can also be read from a file. For example: echo "/etc/fstab" > /tmp/dialog-chooser spacefm -g --chooser @/tmp/dialog-chooser \ --button okIn the above example, the file '/tmp/dialog-chooser' will be watched. When its contents change, the chooser will change directory and/or select a file to reflect the new value on the first line of the file. When the dialog is closed with any button except Cancel, the current directory of the chooser will be written to the file. Thus the next time the dialog opens, it will open to the same directory. To allow the user to select multiple files, add the --multi option (all options must precede any arguments): spacefm -g --chooser --multi /etc To allow the user to select a directory which already exists: spacefm -g --chooser --dirTo allow the user to select multiple directories: spacefm -g --chooser --dir --multi To allow the user to select an existing file, or enter a filename that doesn't exist (to save a file, for example): spacefm -g --chooser --save To allow the user to select an existing directory, or enter a directory name that doesn't exist (to create a directory, for example): spacefm -g --chooser --dir --saveNote that it is up to your script to determine if a file already exists before overwriting it, or to prompt the user for overwrite confirmation. Filters can be added to control what types of files are displayed. The F value in a filter can be a MIME type (eg "text/plain" or "video/*") or a filename pattern (eg *.txt). For example, to allow the user to choose only files with MIME type "text/plain": spacefm -g --chooser --filter text/plainOr to allow the user to select only files ending in ".avi": spacefm -g --chooser --filter '*.avi'Multiple filters can be added. The user will be able to select the desired filter from a drop-down list in the chooser. For example: spacefm -g --chooser --filter '*.avi' --filter video/x-matroskaA single filter can include multiple types or patterns separated by a colon. For example: spacefm -g --chooser --filter '*.avi:*.mpg:video/*'More than one --chooser element can be added to a dialog. If a command is included, the COMMAND(s) will be run when the user double-clicks a file in the list. In commands, the value of a --chooser element (eg %v, %chooser1) will equal the currently selected file or files. If internal command set is used on a chooser, the command will change directory (and/or select a file). The select and unselect commands can be used to select and unselect files. In SpaceFM Dialog's output, the selected file(s) can be read from, for example, "$dialog_chooser1", and the current directory from "$dialog_chooser1_dir". Note that in some cases, such as when the chooser is in "Recently Used", "$dialog_chooser1_dir" will be null. Also, if the --multi option is used, "$dialog_chooser1" will be an array containing the selected paths.
| ||||||||||||||||||||||||||||||||||||
Contents |
Non-Visible Elements
The following elements control how the dialog appears or behaves, and how other elements are packed into the dialog, but don't add a visible widget to the dialog: --prefix --prefix is a non-visible element which sets the base variable name that SpaceFM Dialog will use when writing output. By default, the base name is "dialog" (eg "$dialog_pressed"). In some cases you may want to use another name, especially if your script uses multiple dialogs. For example: spacefm -g --prefix varIn this case, the output will use variables such as "$var_pressed" instead. As with many elements, --prefix also accepts a file instead of a string, and will read the value from the first line of the file. For example: echo "var" > /tmp/dialog-prefix spacefm -g --prefix @/tmp/dialog-prefixThe "at" sign (@) indicates that a file path is being specified, and that SpaceFM Dialog should read the value from the first line of the file /tmp/dialog-prefix. The file is not watched or modified, but its value is not read until output is produced. --window-size The --window-size element sets a minimum WIDTH and/or HEIGHT for the dialog window. This element is used to make the window larger by default. If WIDTH or HEIGHT is negative, that dimension's minimum remains unchanged. For example, to make the minimum window size 800x600: spacefm -g --window-size 800x600Note that depending on the other elements added, the window may grow larger than the minimum size specified. Also, window managers are capable of overriding the default size request. Or, to only set a minimum width of 800, leaving the height at the default: spacefm -g --window-size 800x-1 A padding amount can also be included.. This sets the amount of empty space around widgets (0-20 is a reasonable range of values for PAD, 4 is the default). For example: spacefm -g --window-size "800x600 10"IMPORTANT: The --window-size element must come before other elements on the command line for the padding value to have an effect. The minimum window size and padding can also be read from a file: spacefm -g --window-size @/tmp/dialog-wsize \ --button okWhen the file is changed, the window will be resized to the specified size. As the dialog is running, in another terminal run: echo 500x500 > /tmp/dialog-wsizeand the window will be resized. (Note that the padding will not change once the dialog is running.) Also, when the dialog closes, the window size (and padding if specified) are written to the file. Thus when the dialog is next run, it will be at least whatever size the user last resized the window to. In commands, you can resize the window by using the internal set command on 'windowsize' (eg 'set windowsize 800x600'), even if you have not added a --window-size element. In SpaceFM Dialog's output, you can always read the window's last size (and padding if specified) from "$dialog_windowsize" (no numeric suffix), even if you have not added a --window-size element. To get the current size while the window is running, use the source command. See also: --title and --window-icon
--hbox The --hbox and --vbox elements allow to you create more sophisticated-looking dialogs. Instead of all elements being stacked vertically in the dialog, one after another, boxes also allow you to arrange elements horizontally in rows. You can also pack boxes within boxes. For example, a vertical box of small elements might be packed into a horizontal box of other elements. Boxes are invisible containers that hold elements - you can't actually see the box itself, only its affect on the elements within it. They come in two varieties: a vbox (vertical box) arranges its child elements in a vertical stack, while an hbox (horizontal box) arranges its child elements in a row. When you add an element to a dialog, it is packed into the current box of the dialog. The current box refers to whatever box was last added to the dialog. Or, if no boxes have been added, the current box is the default vbox of the dialog. Thus if you add no box elements, all elements are arranged vertically in a dialog. An --hbox element packs a new hbox into the current box. The hbox then becomes the new current box. Any widgets you add after the --hbox element will be packed into it, and thus arranged in a row. For example: spacefm -g --hbox \ --free-button "Button1" \ --free-button "Button2" \ --free-button "Button3"In the above command, the initial --hbox element is packed into the default vbox of the dialog. Then, the buttons are packed into the hbox, and are thus arranged in a row. When you are done adding elements to the hbox, you can close the box if you have other elements to add. When the box is closed, the current box becomes the previous box, in this case the default vbox of the dialog again. So any elements added after the box closure will again be stacked vertically in the dialog. For example: spacefm -g --hbox \ --free-button "Button1" \ --free-button "Button2" \ --free-button "Button3" \ --close-box \ --free-button "Button4" \ --free-button "Button5"You will notice that if you resize the above window, the row of buttons expand vertically. For some elements (like a --list or a --viewer) this is desirable, since the elements expand to fill the window. For other elements, such as buttons, you don't normally want this expansion. By default, an hbox will expand vertically consuming available window space, giving the extra space to its children, who in turn expand. If you don't want the hbox to consume extra vertical space in the window, include the --compact option: spacefm -g --hbox --compact \ --free-button "Button1" \ --free-button "Button2" \ --free-button "Button3" \ --close-box \ --free-button "Button4" \ --free-button "Button5"As with all elements, the --compact option determines how much window space a box will absorb. --compact tells the box not to expand in the other dimension. For an hbox, --compact will affect the vertical dimension (height), and for a vbox, --compact will affect the horizontal dimension (width). With --compact, the box will not consume extra window space beyond what its children require as a minimum, so the children will in turn not expand. The extra space in the window will be divided among other boxes (if they can expand), or will remain empty (as in the above example). Also, whether children expand in the same dimension (horizontally in an hbox or vertically in a vbox) depends on the type of elements in the box, and whether you have included --compact or --expand options for them. The box itself will expand in the same dimension, but its children may not (as seen in the above example). Note: A box with no children in it will take no space - it is effectively hidden. Finally, a PAD value may also be added to an hbox, which adds padding (empty space) between the children. For example: spacefm -g --hbox 30 \ --free-button "Button1" \ --free-button "Button2" \ --free-button "Button3" If an --hbox is hidden, all of its children become invisible.
--vbox For a general discussion of boxes, see --hbox. A --vbox element works similarly to an --hbox, except that the child elements in the box are stacked vertically rather than horizontally. The default box in a dialog is a vbox, so elements are added in a vertical stack. Adding a --vbox element to the dialog's default vbox will have no apparent effect. Thus these two commands create the same dialog: spacefm -g --free-button "Button1" \ --free-button "Button2" \ --free-button "Button3" # Produces the same dialog as: spacefm -g --vbox \ --free-button "Button1" \ --free-button "Button2" \ --free-button "Button3"To see the effects of a vbox, we need to pack it into an hbox containing other elements: spacefm -g --hbox \ --list AAA BBB CCC \ --vbox \ --check "Option Alpha" \ --check "Option Beta" \ --check "Option Gamma"In the above example, an hbox is first packed in the dialog. This hbox contains two elements: a list and a vbox. Since its an hbox, those elements are arranged side-by-side, in a row - the list and the vbox will be next to each other. Finally, three check options are packed into the vbox. Since its a vbox, they are stacked vertically. If we wanted to add another element below all of that, in the original default vbox of the dialog, we would first need to close the boxes we added: spacefm -g --hbox \ --list AAA BBB CCC \ --vbox \ --check "Option Alpha" \ --check "Option Beta" \ --check "Option Gamma" \ --close-box \ --close-box \ --drop itemA --close-box always closes the current box. In the above example, the first --close-box closes the vbox, and the second closes the hbox. (You cannot close the default vbox of the dialog, so an additional --close-box would be ignored.) As with an --hbox, a --compact option can be added to a --vbox to prevent it from expanding in the other dimension - horizontally. In our example this will compact the check options to the right side of the window, giving the list more horizontal space in the window: spacefm -g --hbox \ --list AAA BBB CCC \ --vbox --compact \ --check "Option Alpha" \ --check "Option Beta" \ --check "Option Gamma" \ --close-box \ --close-box \ --drop itemFinally, as with an --hbox, a PAD value may be added to a --vbox to add empty space between its children: spacefm -g --hbox \ --list AAA BBB CCC \ --vbox --compact 30 \ --check "Option Alpha" \ --check "Option Beta" \ --check "Option Gamma" \ --close-box \ --close-box \ --drop item If a --vbox is hidden, all of its children become invisible.
--close-box A --close-box element closes the current box of the dialog, as demonstrated in --hbox and --vbox. Elements after the --close-box will be added to the previous current box of the dialog.
--keypress A --keypress element associates a key combination with a COMMAND while the dialog is running. Pressing the key combination will run the COMMAND(s), which as always may be internal, external, or a mixture of both. For example, to associate Ctrl+K with a command that prints a value to the terminal and updates a label: spacefm -g --label "Press Ctrl+K" \ --keypress 0x6b 0x4 bash -c 'echo "# %n %v" >&2' -- \ set label1 "You pressed Ctrl+K"In the above example, "0x6b" is the KEYCODE for the 'k' key, and "0x4" is the MODIFIER for Ctrl. When Ctrl+K is pressed, "# keypress1 0x6b 0x4" is written to the terminal. Keycodes and modifiers may be obtained using SpaceFM's Design Mode Key Shortcut setting. Right-click on a menu or toolbar item in SpaceFM and select Key Shortcut. Press the desired key combination to see the keycode and modifier, then click Cancel. Multiple --keypress elements can be added to a dialog. In commands, the value of a --keypress element (eg %v, %keypress1) will equal the keycode and modifier.
--click A --click element will run the COMMAND(s) when some elements are clicked, focused, or change value. For --label, --input, --input-large, --password, --editor, and --viewer elements, COMMAND will be run whenever the element gets focus (is clicked or focused with keyboard). For --drop, --combo, --list, --mlist, and --chooser elements, COMMAND will be run whenever a selection is chosen, or a --combo element's text entry box gets focus. For other element types that get focus, COMMAND will not be run. In commands, the value of a --click element (eg %v, %click1) will equal the name of the element that was focused, a space, and one or more space-separated values for the element. For example, to print the value of whatever element is clicked: spacefm -g --label "Click HERE" \ --list 111 222 333 -- \ --input \ --click bash -c 'echo "%v" >&2'Running the above example, when you focus an element by clicking on it, its name and value will be printed. Multiple --click elements can be added to a dialog. Each one can run a different command when there is a click. Or, a single --click element can run multiple commands, like any element. Note that %v is passed to the command line as a single argument containing multiple quoted arguments. Thus you will generally want to run it through bash in order to expand the arguments into $1, $2, etc., even when running a script. This will also allow correct handling of filenames containing spaces, etc. For example, consider this script: #!/bin/bash echo "NAME: $1" >&2 name="$1" shift if [ "$name" == "chooser1" ]; then md5sum "$@" >&2 fiIf you run that script with this command: spacefm -g --chooser --multi --label Nothing \ --click bash -c 'md5.sh "%v"'Clicking on the "Nothing" label does nothing but print the name. Clicking on a file will show the file's md5sum. You can also click multiple files at once (using Ctrl+Click), and they will ALL be summed each time you click. Each filename is passed to the md5.sh script as a single argument ($1, $2, etc). --window-close A --window-close element runs COMMAND when the user attempts to close the dialog (usually by clicking the 'X' button in the upper right corner or using Alt-F4, etc.) The window closure will be inhibited, but COMMAND can be used to close it conditionally. For example: spacefm -g --label "You can't close this window unless you enter text:" \ --input \ --window-close close %input1In the above example, the internal close command is passed the contents of the --input element, which acts as a reversal to the close command. If %input1 is empty, the close command does nothing, otherwise it closes the window. --command A --command element causes SpaceFM Dialog to monitor a regular file or a pipe for internal commands. For example, to monitor a regular file: spacefm -g --command /tmp/dialog-cmdNo command will be read from the file during dialog creation even if it contains one. When you write a command to the first line of the file while the dialog is running, it will be run as an internal command. In another terminal run: echo "set title A Window Title" > /tmp/dialog-cmdNote that separate quotes should NOT be used around the third argument, even if it contains spaces. Or, to monitor a pipe: # First create the pipe: mkfifo /tmp/dialog-cmdpipe spacefm -g --command /tmp/dialog-cmdpipeThen in another terminal, write text to the pipe: echo "set windowsize 500x500" > /tmp/dialog-cmdpipe Multiple --command elements may be added if desired. This can help prevent race conditions when submitting commands rapidly, etc. You can use a command file or pipe from your script to get data from a running dialog by submitting a source command (eg 'source /tmp/dialog-source'). Then in your script, parse the source file: source /tmp/dialog-sourceNote that you may or may not need to add a small delay (eg sleep 0.1) for the source file to be written in response to your command, before reading the file. COMMAND, if included, specifies initialization commands for the dialog. COMMAND(s) associated with a --command element are run only once, just after the dialog is created. These are used to initialize the dialog, such as disabling or hiding some elements. (FILE|PIPE may be "" if you want to include an initialization COMMAND but don't want to watch a command file.)
| ||||||||||||||||||||||||||||||||||||
Contents |
Commands
One or more commands may be associated with a SpaceFM Dialog element if the element accepts COMMAND on its command line. Most commands are run when the element is activated - a user clicks a button, double-clicks an item in a list, presses Enter in a text box, etc. Commands may be internal (used to internally change aspects of the dialog while it's running) or external (an executable to be run). SpaceFM Dialog recognizes its internal commands by name; any commands which are not internal are run as external. The COMMAND argument may represent a single command followed by its command arguments, or multiple commands each with arguments. A "--" argument is used to separate multiple commands. Both internal and external may be mixed. For example: spacefm -g --label "Press Button" \ --button "Button" set label1 "Button was pressed" -- \ bash -c 'echo "# Button %n was pressed" >&2'The --button element above includes two commands with arguments, separated by a "--" argument. The first command (set label1 "Button was pressed") is an internal command. The second command (bash -c echo...) is an external command. When the button is pressed, both commands are run - the first changes the label internally, and the second runs echo to write text to stderr of the terminal. (Note that any output to stdout will be discarded because this may interfere with evaluating the output.) Although commands are run in the order presented, note that external commands are run asynchronously. SpaceFM Dialog runs and forgets the command, and doesn't wait for it to finish. This means later commands may run before an earlier command has finished. (To run an external command synchronously, run it inside an internal noop command's %(command) substitution.) Substitution Variables
%n %v %NAME %(command) spacefm -g --label \ --button 'Get Date' set label1 '%(date +%%D)'Generally, you will need to quote the '%(command)' argument as shown above when running spacefm, or the shell will misinterpret the parentheses. The command line "date +%D" (remember %% is changed to %) is run, and the output is substituted. IMPORTANT: Because the %(command) command line is run synchronously, SpaceFM Dialog will wait until it finishes. While it's waiting, the dialog GUI and other functions will be suspended. If the command takes an appreciable amount of time, you will notice the GUI lags or hangs. Thus fast commands work best. Also, if you want to run an external command synchronously, you can run it inside an internal command with %(command). The noop command, which does nothing except evaluate arguments, is good for this, eg noop '%(command)'. In this case, the stdout output will be discarded, but the command will be run synchronously. Note that a small bash script can be run directly inside a %(command) substitution. For example: spacefm -g --check Option 0 \ set label1 '%( echo -n Option is\ ; \ (( %v )) && echo checked || echo unchecked )' \ --label "Option is unchecked" | ||||||||||||||||||||||||||||||||||||
Contents |
Internal Commands
Internal commands are run internally by the dialog to change elements while the dialog is running. They can be included as part of an element's COMMAND arguments, or submitted from an external process using a --command element. The following internal commands may be used: noop The noop (no operation) command simply does nothing, but its arguments, if any, are evaluated. One use for a noop command is to prevent a dialog closing when a button or other element is activated. Buttons will automatically close the dialog when pressed if no COMMAND is included. Other elements, such as lists and inputs, will press the right-most dialog button to close the dialog when they are activated if no COMMAND is included. To prevent this behavior, you can set COMMAND to noop. For example: spacefm -g --button ok noopAnother use for the noop command is to evaluate arguments. This can be used to run an external command synchronously as detailed in %(command) substitution. For example: spacefm -g --button ok noop '%(myscript)' -- closeIn the above example, when the OK button is pressed, first 'myscript' will be run synchronously (an imaginary script which does something critical before closure). SpaceFM Dialog will wait for it to finish. Then and only then, the 'close' command will close the dialog. close The close command simply closes the dialog window, as if the user clicked the X in the top-right corner or used Alt+F4. $dialog_pressed_index will equal -2. REVERSE, if supplied and equal to "", "0", or "false", causes the close command to do nothing. This can be used with the value from another element, for example, to make the close command conditional. For example: spacefm -g --label "You can't close this window unless you enter text:" \ --input \ --window-close close %input1Note: Element @FILE values are NOT saved when the dialog is closed via the close command (or via a SIGQUIT signal, etc). You can perform a source command first if you want values to be written for @FILEs. [Note: In SpaceFM 0.9.3 and prior, the close command DID save element @FILE values.] press The press command presses a button in the dialog, just as if the user clicked it. It is passed the name of the button to press. For example: spacefm -g --icon gtk-ok press button1 \ --button okWhen the above command is run and the icon is clicked, the OK button will be pressed, closing the dialog ($dialog_pressed = button1). Other elements, if no COMMAND is included, will press the right-most dialog button when activated. The press command can also be used to press another button instead. set The set command sets a new VALUE for the element named NAME. What effect this has will depend on the type of element. For most elements, set will change what they are displaying or their state. For details on how a particular element handles set, see the element's documentation. For example: spacefm -g --label "Press Button" \ --button "Button" set label1 "Button was pressed" select The select command is used to select an item in any kind of list, or if no VALUE is supplied, all items are selected if possible. select can also be used to select a filename in a --chooser, or set the text in a --combo. For example: spacefm -g --list AAA BBB CCC \ --button "Select CCC" select list1 CCC \ --button ok unselect The unselect command is used to unselect an item in any kind of list, or if no VALUE is supplied, all items are unselected. unselect can also be used to unselect a filename in a --chooser, or clear the text in a --combo. For example: spacefm -g --mlist AAA BBB CCC \ --command "" select mlist1 \ --button "Unselect All" unselect mlist1 \ --button ok focus The focus command gives the element NAME the focus in the dialog. The focused element receives keyboard input. If no NAME argument is included, the dialog window is presented (this may mean raising the window in the stacking order, deiconifying it, and/or moving it to the current desktop, depending on window manager settings). REVERSE, if supplied and equal to "", "0", or "false", causes the focus command to do nothing. This can be used with the value from a --check element, for example, to make the focus command conditional. hide The hide command makes the element named NAME invisible. A hidden element takes no space, so other elements may shift position or size in response to an element being hidden. hide can be used to hide or show dialog elements conditionally in a certain mode or use of the dialog. REVERSE, if supplied and equal to "", "0", or "false", causes the hide command to have the reversed effect (it becomes a show command). This can be used with the value from a --check element, for example, to make the hide command conditional. show The show command makes the element named NAME visible. All elements are visible by default, so a show command only has an effect if an element was previously hidden with hide (or a reversed show). If no NAME argument is included, the dialog window is presented (this may mean raising the window in the stacking order, deiconifying it, and/or moving it to the current desktop, depending on window manager settings). REVERSE, if supplied and equal to "", "0", or "false", causes the show command to have the reversed effect (it becomes a hide command). This can be used with the value from a --check element, for example, to make the show command conditional. For example: spacefm -g --check "Show text" 1 show label1 %v \ --label "Some text" disable The disable command sets the element named NAME insensitive (grayed). A disabled element cannot be clicked or used by the user. REVERSE, if supplied and equal to "", "0", or "false", causes the disable command to have the reversed effect (it becomes an enable command). This can be used with the value from a --check element, for example, to make the disable command conditional. enable The enable command sets the element named NAME sensitive (not grayed). All elements are enabled by default, so an enable command only has an effect if an element was previously disabled with disable (or a reversed enable). REVERSE, if supplied and equal to "", "0", or "false", causes the enable command to have the reversed effect (it becomes a disable command). This can be used with the value from a --check element, for example, to make the enable command conditional. For example (you can't click OK unless you select a function): spacefm -g --label "Select a function and click OK:" \ --drop "Function A" "Function B" "Function C" -- "" \ enable button1 %v \ --button ok \ --command "" disable button1In the above example, the drop's %v equals "", reversing the enable, unless a function is selected. The --command element is used to initialize the dialog by disabling button1 when the dialog is first created. source When a dialog closes, it saves some @FILE values, and it writes output to stdout containing variables for use in a script. The source command is used to trigger this output to be written to a file while the dialog is still running. The file can then be used as a source file in bash or a similar script, providing the script with the current state of the dialog elements. The source command also saves @FILEs for some elements, such as --input, which are normally only saved when the dialog closes by the user pressing a button other than Cancel. It also saves the contents of an --editor or --viewer element to SAVEFILE. If FILE is omitted or equals "", the output is written to stderr by the dialog process (useful for debugging). To run source with no output use 'source /dev/null'.
| ||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
Contents
|
Introduction
SpaceFM socket commands allow external processes (including custom commands) to easily communicate with a running instance of SpaceFM. They can be used to gather information about the state of the GUI, make changes to the GUI, and to run utility commands. When used in event handlers, socket commands can respond to various events in the SpaceFM window. When a user's first instance of SpaceFM is started, either by the user opening a window, starting a daemon instance, or starting a desktop manager daemon instance, a socket is created in /tmp for this instance. This socket is used by SpaceFM to open additional windows or tabs, and is also used to process socket commands. This allows other processes owned by the same user to communicate with the running instance. For example, socket commands can be used to record or change the size of a SpaceFM window; show or hide panels or side panes; resize panels, panes, and columns; select files in a given window, panel, or tab; place text or files on the clipboard; read text or files from the clipboard; place text in a panel's status bar; update the progress bar and other information displayed about running tasks, and much more.
| ||||||||||||||||||||||||||||||||||||
Contents |
Invocation
To send a socket command and receive any reply, run SpaceFM with the -s (--socket-cmd) option. Any reply will be written to stdout and any errors or warnings to stderr. If an error occurs, the exit status will be set. To see the help reference for SpaceFM's socket commands, run: $ spacefm -s help SpaceFM socket commands permit external processes (such as command scripts) to read and set GUI property values and execute methods inside running SpaceFM windows. To handle events see View|Event Manager in the main menu bar. Usage: spacefm --socket-cmd|-s METHOD [OPTIONS] [ARGUMENT...] Example: spacefm -s set window_size 800x600 METHODS ------- spacefm -s set [OPTIONS] PROPERTY [VALUE...] Sets a property spacefm -s get [OPTIONS] PROPERTY Gets a property spacefm -s set-task [OPTIONS] TASKID TASKPROPERTY [VALUE...] Sets a task property spacefm -s get-task [OPTIONS] TASKID TASKPROPERTY Gets a task property spacefm -s run-task [OPTIONS] TASKTYPE ARGUMENTS Starts a new task spacefm -s emit-key [OPTIONS] KEYCODE [MODIFIER] Activates an item by emitting its shortcut key spacefm -s activate [OPTIONS] NAME Runs custom command or shows submenu named NAME spacefm -s add-event EVENT COMMAND ... Add asynchronous handler COMMAND to EVENT spacefm -s replace-event EVENT COMMAND ... Add synchronous handler COMMAND to EVENT, replacing default handler spacefm -s remove-event EVENT COMMAND ... Remove handler COMMAND from EVENT spacefm -s help|--help Shows this help reference. OPTIONS ------- Add options after METHOD to specify a specific window, panel, and/or tab. Otherwise the current tab of the current panel in the last window is used. --window WINDOWID Specify window. eg: spacefm -s set --window 0x104ca80 window_size 800x600 --panel PANEL Specify panel 1-4. eg: spacefm -s set --panel 2 bookmarks_visible true --tab TAB Specify tab 1-... eg: spacefm -s set --tab 3 selected_filenames fstab PROPERTIES ---------- Set properties with METHOD 'set', or get the value with 'get'. window_size eg '800x600' window_position eg '100x50' window_maximized 1|true|yes|0|false|no window_fullscreen 1|true|yes|0|false|no screen_size eg '1024x768' (read-only) window_vslider_top eg '100' window_vslider_bottom eg '100' window_hslider eg '100' window_tslider eg '100' focused_panel 1|2|3|4|prev|next|hide focused_pane filelist|devices|bookmarks|dirtree|pathbar current_tab 1|2|...|prev|next|close tab_count 1|2|... new_tab [DIR] Open DIR or default in a new tab devices_visible 1|true|yes|0|false|no bookmarks_visible 1|true|yes|0|false|no dirtree_visible 1|true|yes|0|false|no toolbar_visible 1|true|yes|0|false|no sidetoolbar_visible 1|true|yes|0|false|no hidden_files_visible 1|true|yes|0|false|no panel1_visible 1|true|yes|0|false|no panel2_visible 1|true|yes|0|false|no panel3_visible 1|true|yes|0|false|no panel4_visible 1|true|yes|0|false|no panel_hslider_top eg '100' panel_hslider_bottom eg '100' panel_vslider eg '100' column_width name|size|type|permission|owner|modified WIDTH sort_by name|size|type|permission|owner|modified sort_ascend 1|true|yes|0|false|no sort_natural 1|true|yes|0|false|no sort_case 1|true|yes|0|false|no sort_hidden_first 1|true|yes|0|false|no sort_first files|folders|mixed show_thumbnails 1|true|yes|0|false|no large_icons 1|true|yes|0|false|no show_dirsize 1|true|yes|0|false|no (aka Show Folder Sizes) statusbar_text eg 'Current Status: Example' pathbar_text [TEXT [SELSTART [SELEND]]] current_dir DIR eg '/etc' selected_filenames [FILENAME ...] selected_pattern [PATTERN] eg '*.jpg' clipboard_text eg 'Some\nlines\nof text' clipboard_primary_text eg 'Some\nlines\nof text' clipboard_from_file eg '~/copy-file-contents-to-clipboard.txt' clipboard_primary_from_file eg '~/copy-file-contents-to-clipboard.txt' clipboard_copy_files FILE ... Files copied to clipboard clipboard_cut_files FILE ... Files cut to clipboard TASK PROPERTIES --------------- status contents of Status task column (read-only) icon eg 'gtk-open' count text to show in Count task column folder text to show in Folder task column item text to show in Item task column to text to show in To task column progress Progress percent (1..100) or '' to pulse total text to show in Total task column curspeed text to show in Current task column curremain text to show in CRemain task column avgspeed text to show in Average task column avgremain text to show in Remain task column elapsed contents of Elapsed task column (read-only) started contents of Started task column (read-only) queue_state run|pause|queue|stop popup_handler COMMAND command to show a custom task dialog TASK TYPES ---------- cmd [--task] [--popup] [--scroll] [--terminal] [--icon ICON] \ [--dir DIR] COMMAND... Run COMMAND as USER in DIR copy|move|link [--dir DIR] FILE|DIR... TARGET Copy|Move|Link FILE(s) or DIR(s) to TARGET dir delete [--dir DIR] FILE|DIR... Recursively delete FILE(s) or DIR(s) refresh [DIR...] Refresh tab or specified DIR(s) edit [--as-root] FILE Open FILE in user's or root's text editor web URL Open URL in user's web browser mount DEVICE|URL Mount DEVICE or URL unmount DEVICE|DIR Unmount DEVICE or mount point DIR EVENTS ------ evt_start Instance start %e evt_exit Instance exit %e evt_win_new Window new %e %w %p %t evt_win_focus Window focus %e %w %p %t evt_win_move Window move/resize %e %w %p %t evt_win_click Mouse click %e %w %p %t %b %m %f evt_win_key Window keypress %e %w %p %t %k %m evt_win_close Window close %e %w %p %t evt_pnl_focus Panel focus %e %w %p %t evt_pnl_show Panel show/hide %e %w %p %t %f %v evt_pnl_sel Selection changed %e %w %p %t evt_tab_new Tab new %e %w %p %t evt_tab_chdir Tab change dir %e %w %p %t %d evt_tab_focus Tab focus %e %w %p %t evt_tab_close Tab close %e %w %p %t evt_device Device change %e %f %v Event COMMAND Substitution Variables: %e event name (evt_start|evt_exit|...) %w window ID %p panel number (1-4) %t tab number (1-...) %d quoted directory ('/etc') %b mouse button (0=double 1=left 2=middle 3=right ... %k key code (eg 0x63) %m modifier key (eg 0x4 used with clicks and keypresses) %f focus element (panelN|filelist|devices|bookmarks|dirtree|pathbar) %v focus element is visible (0 or 1, or device state change) Examples: window_size="$(spacefm -s get window_size)" spacefm -s set window_size 1024x768 spacefm -s set column_width name 100 spacefm -s set-task $fm_my_task progress 25 spacefm -s run-task --window $fm_my_window cmd --task --popup ls /etc spacefm -s run-task copy --dir /etc fstab hosts /destdir spacefm -r /etc; sleep 0.3; spacefm -s set selected_filenames fstab hosts spacefm -s set clipboard_copy_files /etc/fstab /etc/hosts spacefm -s emit-key 0xffbe 0 # press F1 to show Help spacefm -s activate --window $fm_my_window "Custom Menu" spacefm -s add-event evt_pnl_sel 'spacefm -s set statusbar_text "$fm_file"' #!/bin/bash eval copied_files="$(spacefm -s get clipboard_copy_files)" echo "These files have been copied to the clipboard:" i=0 while [ "${copied_files[i]}" != "" ]; do echo " ${copied_files[i]}" (( i++ )) done if (( i != 0 )); then echo "MD5SUMS:" md5sum "${copied_files[@]}" fi | ||||||||||||||||||||||||||||||||||||
Contents |
Methods
Methods represent different kinds of socket commands: set The set method sets a property to one or more values. Different properties accept different kinds of values. To see what values a property accepts, look the property up in the Help Reference. As with all methods, by default the set method will apply to the current tab in the current panel of the last used SpaceFM window. You can also specify a particular window, panel, and/or tab using the --window, --panel, and/or --tab OPTIONS. (The WINDOWID used by the --window option is obtained from the $fm_my_window bash variable.) For example: spacefm -s set --window $fm_my_window --panel 3 --tab 2 pathbar_text "/" Examples using the set method: # Set the size of the last used SpaceFM window: spacefm -s set window_size 1024x768 # Set the size of my tasks's SpaceFM window spacefm -s set --window $fm_my_window window_size 1024x768 # Maximize the window: spacefm -s set window_maximized 1 # Show panel 3: spacefm -s set panel3_visible true # Focus panel 3: spacefm -s set focused_panel 3 # Hide the Dir Tree: spacefm -s set dirtree_visible 0 # Set the position of the vertical slider between panels 1 and 2: spacefm -s set window_vslider_top 400 # Set the width of the Name column: spacefm -s set column_width name 100 # Set the text in panel 2's status bar: spacefm -s set --panel 2 statusbar_text "Custom Status" # Remove the custom text in panel 2's status bar: spacefm -s set --panel 2 statusbar_text # Set the text in the pathbar: spacefm -s set pathbar_text "/etc" # Set the text in the pathbar and select it: spacefm -s set pathbar_text "/etc" 0 # Focus the pathbar (put cursor there): spacefm -s set focused_pane pathbar # Change to directory '/etc': spacefm -s set current_dir '/etc' # Select files named 'fstab' and 'hosts', unselect others: spacefm -s set selected_files 'fstab' 'hosts' # Unselect all files: spacefm -s set selected_files # Select all files: spacefm -s set selected_pattern '*' # Select all jpg files, unselect others: spacefm -s set selected_pattern '*.jpg' # Copy text to the clipboard: spacefm -s set clipboard_text 'Some text' # Copy multiple lines of text to the clipboard: spacefm -s set clipboard_text 'Some\nlines\nof text' # Copy the contents of a text file to the clipboard: spacefm -s set clipboard_from_file /etc/fstab # Copy text to the primary (middle-click) clipboard: spacefm -s set clipboard_primary_text 'Some primary text' # Copy files to the clipboard: spacefm -s set clipboard_copy_files /etc/fstab /etc/hosts # Cut files to the clipboard: spacefm -s set clipboard_cut_files /etc/fstab /etc/hosts # Adjust sort settings: spacefm -s set sort_by size spacefm -s set sort_by name spacefm -s set sort_ascend false spacefm -s set sort_natural true spacefm -s set sort_first folders get The get method gets a property's value. The reply is written to stdout. As with all methods, by default the get method will apply to the current tab in the current panel of the last used SpaceFM window. You can also specify a particular window, panel, and/or tab using the --window, --panel, and/or --tab OPTIONS. The reply to a get can be saved in a bash variable directly: size="$(spacefm -s get window_size)" echo "$size"Or, the reply can be tested directly: if [ "$(spacefm -s get clipboard_text)" == "" ]; then echo "The clipboard is empty" fi Examples using the get method: # Is the window maximized? spacefm -s get window_maximized # Is panel 3 shown? spacefm -s get panel3_visible # Which panel is focused? spacefm -s get focused_panel # Is the Bookmarks pane shown in panel 4? spacefm -s get --panel 4 bookmarks_visible # Get the position of the vertical slider between panels 1 and 2: spacefm -s get window_vslider_top # Get the width of the Size column: spacefm -s get column_width size # Get the text in panel 2's status bar: spacefm -s get --panel 2 statusbar_text # Get the current directory of tab 2: spacefm -s get --tab 2 current_dir # Get the text on the clipboard: spacefm -s get clipboard_text # Get the text on the clipboard and write it to a file: spacefm -s get clipboard_text > /tmp/clipboard-contents.txt When the clipboard contains cut or copied files, clipboard_text will contain the paths of the files, one per line, as text. Or, when getting the value of clipboard_copy_files or clipboard_cut_files, SpaceFM will reply with an array of quoted paths. For example: # First copy some files to the clipboard: spacefm -s set clipboard_copy_files /etc/fstab /etc/hosts # Now get the files on the clipboard: spacefm -s get clipboard_copy_files ('/etc/fstab' '/etc/hosts' )The returned value in the above example is intended to be saved to a bash array using eval. For example, the following script reads the copied files into an array, prints each member of the array, one per line, then calculates the MD5 sums of the files by passing the array to md5sum as a list: #!/bin/bash # Read the copied files into an array: eval copied_files="$(spacefm -s get clipboard_copy_files)" echo "These files have been copied to the clipboard:" i=0 while [ "${copied_files[i]}" != "" ]; do echo " ${copied_files[i]}" (( i++ )) done if (( i != 0 )); then echo "MD5SUMS:" md5sum "${copied_files[@]}" fiNote that when files have been copied to the clipboard, clipboard_copy_files will contain the list, and clipboard_cut_files will be empty. When files have been cut to the clipboard, clipboard_cut_files will contain the list, and clipboard_copy_files will be empty. Traditionally, when cut files are successfully copied to another location, you should then delete them from their original location, whereas files which have merely been copied to the clipboard are never deleted. Likewise, when getting the value of selected_filenames, SpaceFM will reply with an array of quoted filenames. For example: #!/bin/bash # Read the selected filenames into an array: eval sel_files="$(spacefm -s get selected_filenames)" echo "These filenames are selected:" i=0 while [ "${sel_files[i]}" != "" ]; do echo " ${sel_files[i]}" (( i++ )) done if (( i != 0 )); then cd "$(spacefm -s get current_dir)" echo "MD5SUMS:" md5sum "${sel_files[@]}" fi set-task The set-task method is used to change the display values for a task, and also to stop, pause, queue, or resume a task, by setting a task property. Different task properties accept different kinds of values. To see what values a task property accepts, look the task property up in the Help Reference. Display values for a task are shown in the Task Manager, and also in task popup dialogs. These include such things as the Item, Total, Current, Remain, and other columns, the progress bar percentage, etc. As with all methods, by default the set-task method will apply to the current tab in the current panel of the last used SpaceFM window. You can also specify a particular window, panel, and/or tab using the --window, --panel, and/or --tab OPTIONS. The set-task method requires a TASKID, which indicates what task is being modified. There are two ways to obtain the TASKID. One is to use the exported bash variable $fm_my_task, which refers to the current command task. The other is to use $fm_task_id, which refers to the task currently selected in the task list when the current task is run. Note that a TASKID is only valid in the window in which the task is currently running, so it's generally appropriate to specify a WINDOWID ($fm_my_window) with the --window option to ensure the correct window is accessed. Note that when using $fm_my_task, the TASKID will not be valid when the command is first run - it usually takes about a half second for a task to appear in the task manager. If your script uses $fm_my_task immediately, it should plan for the socket command to fail until the task is shown in the task manager, or it can use a small delay (sleep 0.75) before sending task-related socket commands. Also, if a custom command is run from the SpaceFM desktop manager menu, note that there is no task manager or window associated with the task, so the TASKID will not be valid in socket commands. Examples using the set-task method: # Set my task's progress bar to 25%: spacefm -s set-task --window $fm_my_window $fm_my_task progress 25 # Set the current item being processed in my task: spacefm -s set-task --window $fm_my_window $fm_my_task item "File 2" # Set the average speed displayed for my task (any text is valid): spacefm -s set-task --window $fm_my_window $fm_my_task avgspeed "10 M/s" # Pause my task: spacefm -s set-task --window $fm_my_window $fm_my_task queue_state pause The task property 'popup_handler', which accepts a bash command line, allows you to set a command to be run when the user clicks on the task in the Task Manager. Normally a click opens a task's popup dialog, but if popup_handler is set, that command will be run instead. This allows you to integrate your custom command's dialog into SpaceFM. The following script, to be run as a custom command script in SpaceFM, demonstrates this property's use: #!/bin/bash # Set a custom task dialog in SpaceFM. # Run this script as a SpaceFM custom command script. $fm_import # make a command pipe to talk to the dialog cmdpipe=/tmp/spacefm-task-dialog.pipe rm -f "$cmdpipe" mkfifo "$cmdpipe" # must wait for this task to be shown in manager before setting property ( sleep .75; \ spacefm -s set-task $fm_my_task popup_handler "echo show > '$cmdpipe'" ) & # show dialog spacefm -g --label "\nThis window will be shown when you click on this \ task in SpaceFM's Task Manager." \ --button close rm "$cmdpipe" -- close \ --command "$cmdpipe" \ --window-close rm "$cmdpipe" -- close > /dev/null # cleanup spacefm -s set-task $fm_my_task popup_handler rm -f "$cmdpipe" exitRunning the above command script within SpaceFM will show the dialog. Anytime you click on the task in the list, the dialog will be raised. Note that the popup_handler command is only run when the user clicks on the task in the list. It is not run when the normal task popup dialog is raised due to a task's Popup settings. When popup_handler is set, the additional Show Output menu item will appear in the right-click context menu for the task, which opens the normal popup dialog. get-task The get-task method gets a task property's value. The reply is written to stdout. For instructions on saving the reply to a variable or testing it directly, see the examples in get. As with the set-task method, get-task requires a TASKID, and passing a WINDOWID is also recommended. Examples using the get-task method: # Get my task's progress bar value: spacefm -s get-task --window $fm_my_window $fm_my_task progress # Get the current status of my task (this is a read-only value): spacefm -s get-task --window $fm_my_window $fm_my_task status # Get the running state of my task (run|pause|queue): spacefm -s get-task --window $fm_my_window $fm_my_task queue_state run-task The run-task method is used to tell a running SpaceFM window to start a new task. A task may run an asynchronous command (run and forget), a command run as a SpaceFM task (shown in the Task Manager if it runs for more than one half second), or an internal task to copy, move, or delete files, or create links. A task can also be used to run a command in the user's configured terminal, open a file in the user's configured text editor, or open a URL in the user's web browser. To run a task in a particular SpaceFM window, or with the exported bash variables of a particular tab, --window, --panel, and --tab OPTIONS may be included. Each TASKTYPE accepts a different set of TYPEOPTIONS and ARGUMENTS, as detailed below. NOTE: The run-task method was added in SpaceFM 0.8.7. If sharing a plugin the user's current SpaceFM version can be examined with cmd [--task] [--popup] [--scroll] [--terminal] [--icon ICON] [--dir DIR] COMMAND... The cmd (or 'command') TASKTYPE is used to run a program or bash command. Exported bash variables may be used in any COMMAND - just remember to include the $fm_import line in your command or script. Note that the contents of the variables will reflect the window, panel, and tab active for the socket command, not necessarily the focused tab of SpaceFM. By default COMMAND is run asynchronously (run and forgotten). It will not appear in the Task Manager, and no popup will be shown. For example: spacefm -s run-task cmd touch /tmp/a_new_filecmd also accepts the following TYPEOPTIONS:
If the --task or --popup options are used, meaning the task is run as a SpaceFM task, the command will return values for $new_task_id and $new_task_window, to be used in future socket commands for this running task. For example: spacefm -s run-task cmd --popup 'while true; do date; sleep 1; done' #!/bin/bash # Note: $new_task_id not valid until approx one half second after task start new_task_window=0x207a030 new_task_id=0x2343150The output can be evaluated in one step like so (note the double-quoted backticks): eval "`spacefm -s run-task cmd --popup 'while true; do date; sleep 1; done'`" echo "Task window is $new_task_window and ID is $new_task_id." Task window is 0x207a030 and ID is 0x23432a0.Note when attempting to use $new_task_id in socket commands, the task ID will not be recognized until the task is listed in the Task Manager, which takes about one half second (if the command runs that long). copy|move|link [--dir DIR] FILE|DIR... TARGET The copy, move, and link TASKTYPEs start an internal SpaceFM task to copy, move, or create links to files and folders. The task will be listed in the Task Manager if it runs for longer than one half second. If files already exist in the TARGET directory, the SpaceFM overwrite query dialog will be shown as usual. FILE(s) and DIR(s) may be specified as absolute paths. Or, if the --dir DIR option is used to specify an (absolute) source directory, they may be relative to DIR. Each FILE and DIR specified must exist. TARGET, which is required as the last argument, specifies an absolute destination directory. For example: spacefm -s run-task copy /etc/fstab /etc/hosts /tmpThe above command will copy the files 'fstab' and 'hosts' from /etc to /tmp. Also, the following command is equivalent: spacefm -s run-task copy --dir /etc fstab hosts /tmpIn the above case, a source directory is specified so that simple filenames may be used in place of absolute paths. Another example, to create links to files and folders: spacefm -s run-task link /etc /etc/fstab /tmpThe above command will create links to the folder /etc and the file /etc/fstab, placing them in /tmp. As with the cmd TASKTYPE, copy, move, and link TASKTYPEs will output $new_task_window and $new_task_id for evaluation and later use. delete [--dir DIR] FILE|DIR... The delete TASKTYPE starts an internal SpaceFM task to recursively delete files and folders. The task will be listed in the Task Manager if it runs for longer than one half second. FILE(s) and DIR(s) may be specified as absolute paths. Or, if the --dir DIR option is used to specify an (absolute) source directory, they may be relative to DIR. Each FILE and DIR must exist. WARNING: No confirmation dialog is shown to the user before files are deleted permanently. If you want a confirmation dialog, your command or script must show one itself. Also note that any specified folders are deleted recursively. For example, to delete the links created in the previous example: spacefm -s run-task delete /tmp/etc /tmp/fstab As with the cmd TASKTYPE, the delete TASKTYPE will output $new_task_window and $new_task_id for evaluation and later use. The refresh TASKTYPE will refresh the directory of the current or specified tab, or tabs containing specified DIR(s). All tabs displaying affected directories will be reloaded. Examples: spacefm -s run-task refresh spacefm -s run-task refresh /etc /home spacefm -s run-task --tab 2 refresh The edit TASKTYPE opens FILE in the user's configured text editor (set in View|Preferences|Advanced). Or, if the --as-root option is included, FILE is opened in the user's configured root editor. This task type is always asynchronous (run and forgotten). For example: spacefm -s run-task edit /etc/fstabIMPORTANT: If sharing a plugin which does anything as root, please be sure to include this information clearly in the plugin's description. The web TASKTYPE opens URL in the user's configured or auto-discovered web browser (set in Help|Options|Browser). This task type is always asynchronous (run and forgotten). For example: spacefm -s run-task web http://ignorantguru.github.io/spacefm/IMPORTANT: If sharing a plugin which open URLs in the user's browser, please be sure to include this information clearly in the plugin's description. The mount TASKTYPE uses the appropriate device or protocol handler to mount a DEVICE (eg /dev/sdd1) or URL (eg ftp://mirrors.kernel.org/). This task type may produce an error pop-up message, but does not set an error status on failure. For example: spacefm -s run-task mount /dev/sdd1Note: If you want to both mount and open a device or URL in SpaceFM's file manager, consider using: spacefm /dev/sdd1 or spacefm ftp://mirrors.kernel.org/ The unmount TASKTYPE uses the appropriate device or protocol handler to unmount a DEVICE (eg /dev/sdd1) or mount point DIR. This task type may produce an error pop-up message, but does not set an error status on failure. For example: spacefm -s run-task unmount /dev/sdd1 emit-key The emit-key method activates the menu or toolbar item with the given shortcut key, as if the user had pressed the key combination. The KEYCODE and MODIFIER for a given key combination can be seen by right-clicking on an item, selecting Key Shortcut, and pressing the key combination. For example, to activate the menu item associated with Ctrl+C (associated with Copy by default): spacefm -s emit-key 0x63 0x4The KEYCODE and MODIFIER may also be specifed as decimal numbers by omitting the '0x' hexadecimal prefix. activate The activate method is used to activate (run) a custom command, bookmark, or application from any menu or toolbar. Or, if the named item is a custom submenu, the submenu will be shown as a popup menu. NAME is the name of the item or submenu as it appears in the menu (underscores may be omitted). If multiple items have NAME as their name, only one will be activated. Alternatively, you can specify the internal name of the command, found in the command directory name, such as "cstm_782d52a7". For example, add a submenu anywhere named "My Gizmos", and add one or more commands inside the submenu. To make it popup: spacefm -s activate 'My Gizmos' When using activate to open a popup menu from within an evt_win_click event handler for the file list, a small delay may be needed before the menu is shown to prevent it from closing immediately when the mouse button is released: *if [ "%b" != "2" ]; then exit 1; fi; ( sleep .2; spacefm -s activate "A-C" ) &Because the sleep and spacefm commands are within parentheses, they are both backgrounded by the ampersand (&), preventing a lag in the GUI. NOTE: Prior to SpaceFM 1.0.4, the 'activate' method was called 'show-menu', and only worked for submenus, not commands. As of 1.0.4, 'show-menu' is deprecated yet still accepted in lieu of 'activate'. add-event The add-event method is used to dynamically add an asynchronous handler command to an event, such that when EVENT occurs, COMMAND will be run asynchronously (SpaceFM won't wait for it to finish). COMMAND is a bash command line. If any arguments follow it, they are added to the command before it is passed to bash. For all events except evt_start, evt_exit, evt_tab_close, and evt_device, the exported bash variables can be used in the command. COMMAND also accepts event substitution variables, which will vary with the event type. add-event may be used any number of times to add additional event handler commands to the same or different event types. Note that COMMAND will continue to run anytime EVENT occurs during the lifetime of the current SpaceFM instance, so be sure to remove the handler when your script is finished using it. In addition to adding dynamic event handlers, you can also set static event handlers using the View|Event Manager menu. Note that a single SpaceFM instance may open multiple windows, so your handler will run when events occur in any window. The handler can test for a specific window using the %w (window ID) substitution variable in the command (which will correspond to a task's $fm_my_window bash variable). For example, the following command will add a handler to the evt_pnl_sel (selection has changed) event, such that anytime the user changes the selection of files in the file list, the status bar will be set to display the first selected file's path: spacefm -s add-event evt_pnl_sel 'spacefm -s set statusbar_text "$fm_file"'Note that to preserve the quotes and dollar sign for bash to evaluate, the entire command is single-quoted and passed as a single argument. Alternatively, escaping those characters yields the same result: spacefm -s add-event evt_pnl_sel spacefm -s set statusbar_text \"\$fm_file\" replace-event The replace-event method is used to dynamically add a synchronous handler command to an event, such that when EVENT occurs, COMMAND will be run synchronously (SpaceFM will wait for it to finish, and will examine the exit status). Because the command is run synchronously, SpaceFM's GUI will freeze while the command is being run. Your command should return a quick exit status to make this freeze minimal, then spawn a process to continue to perform whatever actions are desired. For event types evt_win_click (a mouse click), evt_win_key (a keypress), and evt_pnl_sel (file selection changed), SpaceFM will use the exit status of your command to determine whether SpaceFM's built-in handler for the event type should run after your command. If the exit status is zero, this will inhibit the built-in handler. For example, if the user clicks the right mouse button, and your command returns zero exit status, SpaceFM will not show the right-click context menu normally shown by the built-in handler. If more than one replace-event is set for a evt_win_click, evt_win_key, or evt_pnl_sel event type (including one set in the View|Event Manager menu), any zero exit status will inhibit the built-in handler. Using replace-event to set a handler for an event type other than evt_win_click, evt_win_key or evt_pnl_sel will cause the command to run synchronously (SpaceFM will wait for it and it will freeze the GUI until it exits) but the exit status will have no effect. (These events are notification only, so there is no built-in handler to inhibit.) COMMAND is a bash command line. If any arguments follow it, they are added to the command before it is passed to bash. Exported bash variables may NOT be used in COMMAND. COMMAND also accepts event substitution variables, which will vary with the event type. replace-event may be used any number of times to add additional synchronous event handler commands to the same or different event types. Note that COMMAND will continue to run anytime EVENT occurs during the lifetime of the current SpaceFM instance, so be sure to remove the handler when your script is finished using it. For example, the following command will add a handler to the evt_win_click event. If the user clicks a button other than the middle mouse button (%b = 2), the command returns exit status 1, so the built-in handler is used. But if the user clicks the middle mouse button, then a dialog message is displayed, and the command returns 0 (the default status on success), inhibiting the built-in handler. spacefm -s replace-event evt_win_click 'if [ "%b" != "2" ]; then exit 1; fi; \ spacefm -g --label "\nMiddle button was clicked" --button ok &'Note the ampersand (&) after the 'spacefm -g' command. This runs the command asynchronously (run and forget) so the exit status is returned immediately and it doesn't cause a lag in the GUI. remove-event The remove-event method removes an event handler previously set with the add-event or replace-event methods. You must pass remove-event the exact same EVENT and COMMAND that you passed when adding the handler. Because all handlers continue to run for the lifetime of the current SpaceFM instance, your scripts should remove all handlers they have added before finishing. When the SpaceFM instance exits, all dynamic event handlers are automatically removed. (If you want dynamic handlers to always be present, use the evt_start event to add them.) remove-event cannot remove static handlers set in the View|Event Manager menu.
| ||||||||||||||||||||||||||||||||||||
Contents |
Events
Events represent actions or changes in the GUI, such as the user closing a tab, selecting a file, or opening a new window. SpaceFM has built-in handlers for these events, which update the GUI, open menus, or take other actions. You can also add your own handlers for events, commands which are run to take a custom action after the event occurs. In some cases your custom handler can replace the action normally taken by SpaceFM's built-in handler, allowing you to modify the default behavior in the GUI. Event handlers can be added in the Event Manager menu. Those handler commands always run until you remove them. Dynamic event handlers can also be added using the add-event or replace-event socket methods. These handlers will remain in effect until you remove them with the remove-event method, or until the SpaceFM instance exits. The following events are available. The name in parentheses is the event name as found in the Event Manager menu. Any event substitution variables available with the event are shown after it (eg %e). evt_start (Instance|Start) %e evt_exit (Instance|Exit) %e evt_win_new (Window|New) %e %w %p %t evt_win_focus (Window|Focus) %e %w %p %t evt_win_move (Window|Move) %e %w %p %t evt_win_click (Window|Click) %e %w %p %t %b %m %f If a handler set for the evt_win_click event is synchronous (has an asterisk prefix or is added with the replace-event method), and it returns a zero exit status, the built-in handler for the event will be inhibited. When using activate to show a popup menu from within an evt_win_click event handler, a small delay may be needed before the menu is shown to prevent it from closing immediately when the mouse button is released: *if [ "%b" != "2" ]; then exit 1; fi; ( sleep .2; spacefm -s activate "A-C" ) &Because the sleep and spacefm command are within parentheses, they are both backgrounded by the ampersand (&), preventing a lag in the GUI. evt_win_key (Window|Keypress) %e %w %p %t %k %m If a handler set for the evt_win_key event is synchronous (has an asterisk prefix or is added with the replace-event method), and it returns a zero exit status, the built-in handler for the event will be inhibited (SpaceFM will not react to the keypress in most cases, even if it's assigned to a menu item). evt_win_close (Window|Close) %e %w %p %t evt_pnl_focus (Panel|Focus) %e %w %p %t evt_pnl_show (Panel|Show) %e %w %p %t %f %v evt_pnl_sel (Panel|Select) %e %w %p %t If a handler set for the evt_pnl_sel event is synchronous (has an asterisk prefix or is added with the replace-event method), and it returns a zero exit status, the built-in handler for the event will be inhibited. (The built-in handler for evt_pnl_sel updates the contents of the panel's status bar, so if you want to handle this yourself, you can inhibit it.) evt_tab_new (Tab|New) %e %w %p %t evt_tab_chdir (Tab|Change Dir) %e %w %p %t %d evt_tab_focus (Tab|Focus) %e %w %p %t evt_tab_close (Tab|Close) %e %w %p %t Note that exported bash variables cannot be used in the handler commands for evt_tab_close. evt_device (Device) %e %f %v Note that exported bash variables cannot be used in the handler commands for evt_device.
| ||||||||||||||||||||||||||||||||||||
Contents
|
Event Manager
The Event Manager submenu, located in the main menu bar's View menu, is used to configure static event handler commands to be run when events occur. Each item in this menu opens a dialog in which a program name or bash command line can be entered. The dialog for each event type also explains when the event occurs and what event substitution variables are available for use in the command for that event. Socket commands are of particular use in these command lines. For example, to alter the default text in the status bar so that it shows only the filename of the first selected file, set Events|Panel|Select (an event which occurs when the file selection in a panel changes) to: spacefm -s set statusbar_text "$fm_filename" Any command line set in the Event Manager menu which is prefixed with an asterisk (*) as the first character, will be run synchronously, as if it was added with the replace-event method. (The asterisk is removed before the command is run.) This means the GUI will freeze while SpaceFM waits for the command to exit. For evt_win_click, evt_win_key, and evt_pnl_sel event types, a zero exit status will also inhibit the built-in handler. In addition to setting commands in the Event Manager menu, you can also add event handler commands dynamically using the add-event or replace-event socket command methods.
| ||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
Contents
|
/home
Your entire SpaceFM configuration, including settings and custom menu and toolbar items, is stored in the config directory: ~/.config/spacefm/ (unless you use If the config directory doesn't exist, and /etc/xdg/spacefm/ does exist, the contents of /etc/xdg/spacefm/ will be copied to the new config directory on startup. Files in ~/.config/spacefm/ include: session session-last & session-prior session.tmp bookmarks plugin-data/ scripts/ Because SpaceFM is highly configurable, you may have much time and effort invested in your SpaceFM config folder, so it's a good idea to keep an up-to-date backup! scripts/default-script Other locations in your home folder used by SpaceFM include: ~/.config/mimeapps.list ~/.local/share/applications/ ~/.templates/ | ||||||||||||||||||||||||||||||||||||
Contents
|
/etc
The first time you click OK in the View|Preferences dialog, and anytime you change your terminal or root editor in that dialog, SpaceFM will ask to save some settings as root to /etc/spacefm/ Although optional, this is recommended to help secure your use of SpaceFM's perform-as-root commands. Also, anytime you run a perform-as-root command, such as to format a partition, these settings may be updated. Without these settings saved as root, your system security may be more easily compromised. The following files may be found in /etc/spacefm/: spacefm.conf
USERNAME-as-root /etc/xdg/spacefm/ sudo cp -r /home/USER/.config/spacefm /etc/xdg/spacefm sudo chmod -R ugo+rX /etc/xdg/spacefmTo test, start SpaceFM with a test config directory which doesn't exist: killall spacefm rm -rf /tmp/spacefm-test-config spacefm --config-dir /tmp/spacefm-test-config If you want to install plugins by default, install them uncompressed to /usr/share/spacefm/plugins/, just as SpaceFM does when you select Plugins|Install. In the user's configuration, plugins can be copied to other menus as well. Or you can simply import plugins into the user's menus before copying the config dir to /etc/xdg/spacefm.
| ||||||||||||||||||||||||||||||||||||
Contents
|
/tmp
SpaceFM writes small files to the temporary directory (which can be changed in spacefm.conf). These include: .spacefm-socketDISPLAY-USERNAME spacefm.tmp/ spacefm-USERNAME-RANDOM.tmp/ spacefm*.tmp/ID-tmp.sh $fm_import # OR source ID-tmp.sh spacefm*.tmp/ID/ | ||||||||||||||||||||||||||||||||||||
Contents
|
/usr
The parent folder (--prefix=) for files listed below may be '/usr' or '/usr/local' depending on how you installed SpaceFM. With the exception of plugins installed by the user, all files stored in /usr are created only when SpaceFM is installed, and are not changed by SpaceFM. These include: bin/spacefm bin/spacefm-auth bin/spacefm-installer share/doc/spacefm/spacefm-manual-en.html share/spacefm/plugins/ share/spacefm/ui/ share/icons/hicolor/48x48/apps/spacefm.png & spacefm-root.png Note: If configure option --enable-pixmaps is used during build, icons will be installed to share/pixmaps/ instead. share/locale/*/LC_MESSAGES/spacefm.mo share/applications/ share/applications/spacefm.desktop share/applications/spacefm-find.desktop share/applications/spacefm-folder-handler.desktop share/mime/packages/spacefm-mime.xml |
Copyright (C) 2018 IgnorantGuru
DISCLAIMER: While the authors, copyright holders, and maintainers of this software endeavour to keep all content up to date and valuable, we make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the software or the information, communications, products, services, or related graphics for any purpose. Any reliance you place on such content is therefore strictly AT YOUR OWN RISK.
Updated 2018-03-04 (SpaceFM version 1.0.6+alpha)