recentfiles

package
v0.2.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package recentfiles tracks recently used files in the XDG recently-used.xbel format (TOML-free, XML as the spec says), so lys-ui apps share the recents list with the desktop's other citizens. The manager keeps the list bounded, most-recent first, and writes atomically; a missing or corrupt file starts an empty list.

Load, Save, Add and Remove wait on the disk. An application drives a Manager through Post, which runs everything in order off the loop.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() string

DefaultPath is the spec's location under the user data directory, honoring XDG_DATA_HOME.

Types

type Entry

type Entry struct {
	Path string
	App  string
	When time.Time
}

Entry is one recently used file: its path (decoded from the file:// URI on disk), the owning application's name, and when it was last used.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager reads and writes one recents list. It is not safe for concurrent use: whoever posts to it touches it only through Post.

func New

func New(path string) *Manager

New returns the manager for the given xbel path (DefaultPath for the desktop's shared list).

func (*Manager) Add

func (m *Manager) Add(app string, paths ...string) error

Add moves paths to the front of the list under app, the last one first, stamps them now, and persists once. Errors persisting are reported once here; a failed write never loses the in-memory list.

func (*Manager) List

func (m *Manager) List() []Entry

List returns the entries, most recent first.

func (*Manager) Load

func (m *Manager) Load() error

Load reads the xbel file; a missing file is an empty list, a corrupt one is an empty list plus the error (the next Add rewrites it clean). Entries whose URIs are not local file:// paths are skipped.

func (*Manager) Post added in v0.2.5

func (m *Manager) Post(work func()) bool

Post queues work to run off the caller's goroutine, in order, and reports whether it was taken: a full or stopped queue refuses it.

func (*Manager) Remove

func (m *Manager) Remove(path string) error

Remove drops path from the list and persists.

func (*Manager) Save

func (m *Manager) Save() error

Save writes the list atomically (temp file + rename); an empty list writes an empty xbel, not a deletion, so a shared desktop list does not flap between present and absent.

func (*Manager) Stop added in v0.2.5

func (m *Manager) Stop(limit time.Duration) bool

Stop refuses later posts, lets queued work finish within limit, and reports whether it did.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL