LinuxCommandLibrary

gvfs-set-attribute

Set file attributes using the GVFS system

SYNOPSIS

gvfs-set-attribute [-h] [-b] [-t type] [--version] location attribute value

PARAMETERS

-h, --help
    Display help information and exit.

-b, --binary
    Treat value as binary data (default: UTF-8 string).

-t type, --type=type
    Set attribute type: string (default), uint32, uint64, stringv (string list), byte-string, unset.

--version
    Print version information and exit.

DESCRIPTION

The gvfs-set-attribute command is part of the GVFS (GNOME Virtual File System) toolkit, enabling users to set extended attributes or metadata on files and directories via GVFS URIs. GVFS supports diverse backends like local files (file://), network shares (smb://, ftp://), and special locations like trash.

Attributes are key-value pairs, often namespaced (e.g., metadata::custom-icon, gio::has-preview), used for desktop metadata such as icons, thumbnails, or emulation flags. On local Unix filesystems, these map to extended attributes (xattrs), requiring write permissions. Remote backends store them differently, depending on support.

Invoke as gvfs-set-attribute location attribute value. Values can be strings (default), binary, numbers, or lists. Common uses include tagging files for GNOME Shell/Nautilus, like setting trash item metadata or preview availability.

This tool integrates with GIO, facilitating programmatic file property management in GNOME environments. It's essential for scripting desktop behaviors without direct xattr manipulation.

CAVEATS

Requires write access to location; not all GVFS backends support attributes (e.g., some HTTP). Local files use xattrs, limited by filesystem (e.g., ext4 max 64KB). Attribute names must follow GIO conventions.

EXAMPLES

gvfs-set-attribute trash:/// metadata::custom-icon file:///path/to/icon.png
gvfs-set-attribute -t uint32 file:///path/file gio::uid 1000
gvfs-set-attribute -b -t byte-string file:///path/file access::icon <base64data>

HISTORY

Introduced in GVFS 0.1 (2008) with GNOME 2.22; evolved for GIO metadata in GNOME 3+. Remains stable in modern GNOME releases.

SEE ALSO

gvfs-get-attribute(1), gio(1), setfattr(1)

Copied to clipboard