Thanks to visit codestin.com
Credit goes to github.com

Skip to content

thatmagicalcat/sfetch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sfetch

A CLI fetch tool for your currently playing Spotify track.


sfetch is a command-line utility written in Rust that displays information about the song you are currently listening to on Spotify. It renders the album art directly in your terminal (if supported) alongside track details, mimicking the aesthetic of tools like neofetch.

Features

  • Now Playing: Fetches real-time data for the current track.
  • Album Art: Displays high-quality album covers in the terminal using viuer.
  • Customizable: Fully configurable colors, layout, and formatting via a TOML config file.
  • Hyperlinks: Generates clickable links to the track and album cover directly in the terminal output.

Prerequisites

To use sfetch, you need:

  1. Rust & Cargo: Installed on your system to build the project.
  2. Spotify Developer Credentials: You need to create an app in the Spotify Developer Dashboard to get a Client ID and Client Secret.
  3. Terminal Support: A terminal emulator that supports image protocols (like Kitty, iTerm2, or Sixel) is recommended for album art display.

Installation

Clone the repository and install using Cargo:

git clone https://github.com/thatmagicalcat/sfetch.git
cd sfetch
cargo install --path .

Or build it locally:

cargo build --release
# Binary will be at ./target/release/sfetch

Configuration

1. Spotify Authentication

sfetch requires Spotify API credentials to access your current playback. You can provide these via environment variables or a .env file in the directory where you run the tool.

Create a .env file:

RSPOTIFY_CLIENT_ID="your_client_id_here"
RSPOTIFY_CLIENT_SECRET="your_client_secret_here"
RSPOTIFY_REDIRECT_URI="http://localhost:8888/callback"

Note: On the first run, sfetch will open your browser to authenticate and authorize the application. It caches the token in ~/.cache/.spotify_token_cache.json.

2. Customizing Output (config.toml)

You can customize the appearance of sfetch by creating a configuration file. The tool looks for a config file in the following locations (in order of precedence):

  1. config.toml in the current directory.
  2. ~/.config/sfetch/config.toml

Default Configuration:

image_width = 30
padding = 4

# Colors: black, red, green, yellow, blue, magenta, cyan, white, grey
# Variations: dark_grey, dark_red, dark_green, etc.
track_color = "green"
type_color = "dark_yellow"
artists_color = "blue"
album_color = "magenta"
popularity_color = "cyan"
duration_color = "yellow"
explicit_color = "red"

# Define the order and presence of fields
order = [
    "Track",
    "Type",
    "Artists",
    "Album",
    "Popularity",
    "Duration",
    "Explicit"
]

Usage

Simply run the command in your terminal while playing music on Spotify:

sfetch

If nothing is playing or the track cannot be identified, sfetch will let you know and exit gracefully.

License

MIT

About

Spotify fetch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published