Skip to content

gvfs.yazi uses gvfs and gio from glib to transparently mount and unmount devices in read/write mode, allowing you to navigate inside, view, and edit individual or groups of files.

License

Notifications You must be signed in to change notification settings

Neintonine/gvfs.yazi

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gvfs.yazi

gvfs.yazi uses gvfs and gio from glib to transparently mount and unmount devices in read/write mode, allowing you to navigate inside, view, and edit individual or groups of files.

Supported protocols: MTP, Hard disk/drive, SMB, SFTP, NFS, GPhoto2 (PTP), FTP, Google Drive (via GOA), One drive (via GOA), DNS-SD, DAV (WebDAV), AFP, AFC. You need to install corresponding packages to use them.

Tested: MTP, Hard disk/drive (Encrypted and Unencrypted), GPhoto2 (PTP), DAV, SFTP, FTP, Google Drive, One Drive. You may need to unlock and turn screen on to mount some devices (Android MTP, etc.)

By default, mount will automatically shows devices which have one of these protocals (MTP, GPhoto2, AFC, Hard disk/drive) or list of added scheme/mount URI. For other protocols (smb, ftp, sftp, etc), use add-mount action with Schemes URI format.

Note

  • This plugin only supports Linux
  • Needs D-bus session to work. For headless session (non-active console like connect to a computer via SSH, etc.) Try this workaround: HEADLESS_WORKAROUND.md
  • If you have any problems with one of the protocols, please manually mount the device with gio mount SCHEMES. List of supported schemes. Then create an issue ticket with the output of gio mount -li and list of the mount paths under /run/user/1000/gvfs/XYZ and /run/media/USERNAME
  • Put files in Trash bin won't work on some protocols (Android MTP), use permanently delete instead.
  • Scheme/Mount URIs shouldn't contain password, because they are saved as plain text in yazi/config/gvfs.private.
  • MTP, GPhoto2, AFC, Hard disk/drive are listed automatically. So you also don't need to add them via add-mount
  • Google Drive, One drive are mounted automatically via GNOME Online Accounts (GOA). So you don't need to add them via add-mount. Guide to setup GNOME_ONLINE_ACCOUNTS_GOA.md

Preview

output_720p.mp4

Features

  • Support all gvfs schemes/protocols (mtp, smb, ftp, sftp, nfs, gphoto2, afp, afc, sshfs, dav, davs, dav+sd, davs+sd, dns-sd)
  • Mount hardware device or saved scheme/mount URI (use --mount)
  • Can unmount and eject hardware device (use --eject)
  • Auto jump to a device or saved scheme/mount URI mounted location after successfully mounted (use --jump)
  • Auto select the first device or saved scheme/mount URI if there is only one listed.
  • Jump to device or saved scheme/mount URI's mounted location (use jump-to-device action)
  • After jumped to mounted location, jump back to the previous location with a single keybind. Make it easier to copy/paste files. (use jump-back-prev-cwd)
  • Add/Edit/Remove scheme/mount URI (use add-mount, edit-mount, remove-mount). Check this for schemes/mount URI format: schemes.html
  • (Optional) Remember passwords using Keyring or Password Store (need secret-tool + keyring or pass + gpg installed)

Note

There is a bug with yazi, which prevent mounted folders from refreshing after unmounted. If you encounter this issue, try create new tab, or move cursor up and down a little bit for yazi to refresh.

Requirements

  1. yazi >= 25.5.31

  2. This plugin only supports Linux, and requires having GLib, gvfs (need D-Bus Session)

    # Ubuntu
    sudo apt install gvfs libglib2.0-dev
    
    # Fedora (Not tested, please report if it works)
    sudo dnf install gvfs glib2-devel
    
    # Arch
    sudo pacman -S gvfs glib2
  3. And other gvfs protocol packages, choose what you need, all of them are optional:

    # Ubuntu
    # This included all protocols
    sudo apt install gvfs-backends gvfs-libs
    
    # Fedora (Not tested, please report if it works)
    sudo dnf install gvfs-mtp gvfs-archive gvfs-goa gvfs-gphoto2 gvfs-smb gvfs-afc gvfs-dnssd
    
    # Arch
    sudo pacman -S gvfs-mtp gvfs-afc gvfs-google gvfs-gphoto2 gvfs-nfs gvfs-smb gvfs-afc gvfs-dnssd gvfs-goa gvfs-onedrive gvfs-wsdd
  4. For headless session (non-active console, Like connect to a computer via SSH, etc.) If you see GVFS.yazi can only run on DBUS session error message, please refer to HEADLESS_WORKAROUND.md for a workaround.

  5. (Optional) Store passwords with Keyring or Password Store (secret-tool + keyring or pass + gpg) There are two methods to securely store passwords. Please refer to SECURE_SAVED_PASSWORD.md for more information.

Installation

ya pkg add boydaihungst/gvfs

Modify your ~/.config/yazi/init.lua to include:

require("gvfs"):setup({
  -- (Optional) Allowed keys to select device.
  which_keys = "1234567890qwertyuiopasdfghjklzxcvbnm-=[]\\;',./!@#$%^&*()_+{}|:\"<>?",

  -- (Optional) Save file.
  -- Default: ~/.config/yazi/gvfs.private
  save_path = os.getenv("HOME") .. "/.config/yazi/gvfs.private",

  -- (Optional) input position. Default: { "top-center", y = 3, w = 60 },
  -- Position, which is a table:
  -- 	`1`: Origin position, available values: "top-left", "top-center", "top-right",
  -- 	     "bottom-left", "bottom-center", "bottom-right", "center", and "hovered".
  --         "hovered" is the position of hovered file/folder
  -- 	`x`: X offset from the origin position.
  -- 	`y`: Y offset from the origin position.
  -- 	`w`: Width of the input.
  -- 	`h`: Height of the input.
  input_position = { "center", y = 0, w = 60 },

  -- (Optional) Select where to save passwords. Default: nil
  -- Available options: "keyring", "pass", or nil
  password_vault = "keyring",

  -- (Optional) Only need if you set password_vault = "pass"
  -- Read the guide at SECURE_SAVED_PASSWORD.md to get your key_grip
  key_grip = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB",

  -- (Optional) save password automatically after mounting. Default: false
  save_password_autoconfirm = true,
})

Usage

Add this to your ~/.config/yazi/keymap.toml:

[mgr]
prepend_keymap = [
    # gvfs plugin
    { on = [ "M", "m" ], run = "plugin gvfs -- select-then-mount", desc = "Select device then mount" },
    # or this if you want to jump to mountpoint after mounted
    { on = [ "M", "m" ], run = "plugin gvfs -- select-then-mount --jump", desc = "Select device to mount and jump to its mount point" },
    # This will remount device under cwd (e.g. cwd = /run/user/1000/gvfs/DEVICE_1/FOLDER_A, device mountpoint = /run/user/1000/gvfs/DEVICE_1)
    { on = [ "M", "R" ], run = "plugin gvfs -- remount-current-cwd-device", desc = "Remount device under cwd" },
    { on = [ "M", "u" ], run = "plugin gvfs -- select-then-unmount", desc = "Select device then unmount" },
    # or this if you want to unmount and eject device. Ejected device can safely be removed.
    # Ejecting a device will unmount all paritions/volumes under it.
    # Fallback to normal unmount if not supported by device.
    { on = [ "M", "u" ], run = "plugin gvfs -- select-then-unmount --eject", desc = "Select device then eject" },
    # Also support force unmount/eject.
    # force = true -> Ignore outstanding file operations when unmounting or ejecting
    { on = [ "M", "U" ], run = "plugin gvfs -- select-then-unmount --eject --force", desc = "Select device then force to eject/unmount" },

    # Add|Edit|Remove mountpoint: smb, sftp, ftp, nfs, dns-sd, dav, davs, dav+sd, davs+sd, afp, afc, sshfs
    # Read more about the schemes here: https://wiki.gnome.org/Projects(2f)gvfs(2f)schemes.html
    # For example: smb://[email protected]/share, sftp://[email protected]/, ftp://192.168.1.2/
    # - Scheme/Mount URIs shouldn't contain password.
    # - Google Drive, One drive are mounted automatically via GNOME Online Accounts (GOA). Avoid adding them. Use GOA instead: ./GNOME_ONLINE_ACCOUNTS_GOA.md
    # - MTP, GPhoto2, AFC, Hard disk/drive are listed automatically. Avoid adding them
    { on = [ "M", "a" ], run = "plugin gvfs -- add-mount", desc = "Add a GVFS mount URI" },
    # Edit or remove a GVFS mount URI will clear saved passwords for that mount URI.
    { on = [ "M", "e" ], run = "plugin gvfs -- edit-mount", desc = "Edit a GVFS mount URI" },
    { on = [ "M", "r" ], run = "plugin gvfs -- remove-mount", desc = "Remove a GVFS mount URI" },

    # Jump
    { on = [ "g", "m" ], run = "plugin gvfs -- jump-to-device", desc = "Select device then jump to its mount point" },
    { on = [ "`", "`" ], run = "plugin gvfs -- jump-back-prev-cwd", desc = "Jump back to the position before jumped to device" },
]

It's highly recommended to add these lines to your ~/.config/yazi/yazi.toml, because GVFS is slow that can make yazi freeze when it preloads or previews a large number of files. Replace 1000 with your real user id (run id -u to get user id). Replace USER_NAME with your real user name (run whoami to get username).

[plugin]
preloaders = [
  # Do not preload files in mounted locations:
  # Environment variable won't work here.
  # Using absolute path instead.
  { name = "/run/user/1000/gvfs/**/*", run = "noop" },

  # For mounted location for hard disk/drive
  { name = "/run/media/USER_NAME/**/*", run = "noop" },
  #... the rest of preloaders
]
previewers = [
  # Allow to preview folder.
  { name = "*/", run = "folder", sync = true },
  # Do not previewing files in mounted locations (uncomment to except text file):
  # { mime = "{text/*,application/x-subrip}", run = "code" },
  # Using absolute path.
  { name = "/run/user/1000/gvfs/**/*", run = "noop" },

  # For mounted hard disk.
  { name = "/run/media/USER_NAME/**/*", run = "noop" },
  #... the rest of previewers
]

About

gvfs.yazi uses gvfs and gio from glib to transparently mount and unmount devices in read/write mode, allowing you to navigate inside, view, and edit individual or groups of files.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%