Skip to main content

Terminal user interface for SomaFM internet radio

Project description

SomaFM TUI Player

AUR Version License: MIT Python 3.8+

SomaFM TUI Player is a modern terminal application for listening to SomaFM โ€” the legendary internet radio with over 40 unique channels.

The app combines a minimalist interface, rich features, and low resource consumption, making it ideal for terminal-based workflows.


๐ŸŒŸ Features

Core Features

  • ๐Ÿ“ป 40+ Radio Channels โ€” Access all SomaFM channels directly from your terminal
  • ๐ŸŽต Track Metadata โ€” Real-time display of artist and track title
  • โค๏ธ Favorites โ€” Save favorite channels with local persistence
  • ๐ŸŽจ Color Themes โ€” 10+ built-in themes (dark and light)
  • ๐Ÿ”Š Volume Control โ€” Adjust volume and mute toggle
  • โฑ Sleep Timer โ€” Auto-shutdown with configurable timer
  • ๐Ÿ” Search โ€” Quick channel search by name and description
  • ๐Ÿ“Š Usage-Based Sorting โ€” Channels sorted by listening history

System Integration

  • ๐ŸŽง MPRIS/D-Bus โ€” Linux media keys integration (play/pause/next/previous)
  • ๐Ÿ–ฅ System Tray โ€” System tray support (via compatible environments)
  • โŒจ๏ธ Vim Navigation โ€” j/k key navigation for Vim users
  • ๐Ÿ“ฆ AUR Package โ€” Easy installation on Arch Linux via AUR

๐Ÿ“ฆ Installation

Arch Linux (Recommended)

Install from AUR (Arch User Repository):

paru -S somafm_tui
# or
yay -S somafm_tui

Manual installation from AUR:

git clone https://aur.archlinux.org/somafm_tui.git
cd somafm_tui
makepkg -si

After installation, run the app with:

somafm-tui

Installation from Source

# Clone the repository
git clone https://github.com/zsh-ncursed/somafm_tui.git
cd somafm_tui

# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Run the application
python -m somafm_tui

Installation via pip

Install directly from PyPI (when available):

pip install somafm-tui

Or install from the repository:

pip install git+https://github.com/zsh-ncursed/somafm_tui.git

After pip installation, the somafm-tui command will be available in your PATH.

Shell Scripts

Quick launch using provided scripts:

# Fish shell
./somafm.fish

# Bash/Zsh
./somafm.sh

Dependencies

  • Python 3.8+
  • MPV โ€” Media player for stream playback
  • python-requests โ€” HTTP client for API requests
  • python-mpv โ€” MPV Python bindings
  • python-dbus-next โ€” D-Bus integration for MPRIS (optional)

Installing Dependencies on Different Distributions

Arch Linux:

sudo pacman -S python mpv python-requests python-mpv python-dbus-next

Ubuntu/Debian:

sudo apt-get install python3 python3-pip mpv libmpv-dev
pip install requests mpv dbus-next

Fedora:

sudo dnf install python3 python3-pip mpv mpv-libs
pip install requests mpv dbus-next

โŒจ๏ธ Controls

Interactive Mode

Launch the application:

somafm-tui

Navigation

Key Action
โ†‘ / โ†“ or j / k Navigate channel list
Enter or l Play selected channel
PgUp / PgDn or v / b Increase/decrease volume
/ Search channels
? Toggle help window
Esc Exit search / close help
f Toggle favorite status
t Cycle through color themes
q Quit application

Playback

Key Action
Space Toggle play/pause
h Stop playback
r Cycle bitrate (if available)
s Set sleep timer

Command-Line Interface

The application supports various CLI arguments for automation and quick actions:

# Show help
somafm-tui --help

# List all available channels
somafm-tui --list-channels

# Search for channels
somafm-tui --search "drone"

# Show favorite channels
somafm-tui --favorites

# List available themes
somafm-tui --list-themes

# Play specific channel with custom settings
somafm-tui --play dronezone --volume 70 --theme dracula

# Set sleep timer from command line
somafm-tui --sleep 30

# Disable MPRIS integration
somafm-tui --no-dbus

# Combine multiple options
somafm-tui -p groovesalad -v 50 -t monochrome -s 60

MPRIS (Media Keys)

When D-Bus support is enabled (dbus_allowed: true in config), the app responds to system media keys:

  • Play/Pause โ€” Toggle playback
  • Next โ€” Next channel
  • Previous โ€” Previous channel
  • Stop โ€” Stop playback

โš™๏ธ Configuration

Config File

Configuration is stored in ~/.somafm_tui/somafm.cfg

# Configuration file for SomaFM TUI Player
#
# theme: Color theme
# dbus_allowed: Enable MPRIS/D-Bus support for media keys (true/false)
# dbus_send_metadata: Send channel metadata over D-Bus (true/false)
# dbus_send_metadata_artworks: Send channel picture with metadata over D-Bus (true/false)
# dbus_cache_metadata_artworks: Cache channel picture locally for D-Bus (true/false)
# volume: Default volume (0-100)
#
[somafm]
theme = default
dbus_allowed = false
dbus_send_metadata = false
dbus_send_metadata_artworks = false
dbus_cache_metadata_artworks = true
volume = 100

Configuration Examples

Basic setup with custom volume:

[somafm]
theme = dracula
volume = 80
dbus_allowed = false

Full MPRIS integration (Linux desktop):

[somafm]
theme = github-dark
dbus_allowed = true
dbus_send_metadata = true
dbus_send_metadata_artworks = true
dbus_cache_metadata_artworks = true
volume = 70

Minimal configuration (no D-Bus, default theme):

[somafm]
theme = default
dbus_allowed = false
volume = 100

Available Themes

Run somafm-tui --list-themes to see all available themes:

Theme Description
default Default Dark โ€” Classic dark theme
dracula Dracula โ€” Popular dark theme
github-dark GitHub Dark โ€” GitHub's dark theme
gruvbox Gruvbox โ€” Retro terminal theme
monokai Monokai โ€” Vibrant dark theme
nord Nord โ€” Arctic blue theme
one-dark One Dark โ€” Atom's dark theme
solarized-dark Solarized Dark โ€” Balanced contrast
tokyo-night Tokyo Night โ€” Deep blue theme
and more See themes.json for full list

Enabling MPRIS

For Linux media keys integration, set:

dbus_allowed = true
dbus_send_metadata = true

The app will then appear in media control systems (GNOME, KDE, etc.)


๐Ÿ“ Data Structure

Directories

Path Purpose
~/.somafm_tui/somafm.cfg Configuration file
~/.somafm_tui/channel_favorites.json Favorite channels
~/.somafm_tui/channel_usage.json Listening history
/tmp/.somafmtmp/ Temporary files and cache
/tmp/.somafmtmp/cache/ Channel cache

Data Formats

Favorites (channel_favorites.json):

["dronezone", "beatblender", "groovesalad"]

History (channel_usage.json):

{
  "dronezone": 1709481600,
  "beatblender": 1709395200
}

๐Ÿ”ง Troubleshooting

Error: "MPV player is not installed"

Ensure MPV is installed on your system:

# Check installation
mpv --version

# Install (Arch Linux)
sudo pacman -S mpv

# Install (Ubuntu/Debian)
sudo apt-get install mpv

# Install (Fedora)
sudo dnf install mpv

Error: "Failed to fetch channels"

Check your internet connection and SomaFM API availability:

# Test API connectivity
curl https://api.somafm.com/channels.json

# Check DNS resolution
ping api.somafm.com

# If using a firewall, ensure outbound HTTPS (port 443) is allowed

Solutions:

  1. Check your internet connection
  2. Verify SomaFM API is accessible: curl -I https://api.somafm.com/channels.json
  3. If behind a proxy, set environment variables:
    export HTTP_PROXY=http://proxy:port
    export HTTPS_PROXY=https://proxy:port
    
  4. Clear channel cache and retry:
    rm -rf /tmp/.somafmtmp/cache/channels.json
    somafm-tui
    

Error: "No channel playing" or playback issues

  1. Check stream URL availability:

    # Test stream connectivity
    mpv --really-verbose "https://ice1.somafm.com/dronezone-128-mp3"
    
  2. Reset configuration:

    rm ~/.somafm_tui/somafm.cfg
    somafm-tui
    
  3. Check audio output:

    • Ensure system volume is not muted
    • Verify audio device is selected correctly in MPV

Emojis Display Incorrectly

The app automatically uses ASCII symbols in terminals without Unicode support. To force ASCII, ensure TERM is set correctly:

export TERM=xterm-256color

Add to your shell configuration (~/.bashrc or ~/.zshrc):

export TERM=xterm-256color

MPRIS Not Working

  1. Ensure dbus_allowed = true in config
  2. Verify python-dbus-next is installed:
    pip show dbus-next
    
  3. Check D-Bus service is running:
    systemctl --user status dbus
    
  4. Verify app appears in media controllers:
    playerctl --list-all
    
  5. Restart the application after configuration changes

Sleep Timer Not Working

  1. Maximum sleep timer is 480 minutes (8 hours)
  2. Check if timer is active: look for โฑ MM:SS in bottom right corner
  3. Cancel and re-set timer if needed:
    • Press s to open sleep overlay
    • Enter minutes (1-480)
    • Press Enter to confirm

High CPU Usage

  1. Disable MPRIS if not needed:

    dbus_allowed = false
    
  2. Reduce cache update frequency (if applicable)

  3. Check for background processes:

    ps aux | grep somafm
    

Logs and Debugging

Enable verbose logging:

somafm-tui --verbose

View logs:

# Real-time log viewing
tail -f /tmp/.somafmtmp/somafm.log

# Last 50 lines
tail -n 50 /tmp/.somafmtmp/somafm.log

Common log messages:

  • Using cached channels โ€” Cache is working correctly
  • Timeout fetching โ€” Network issues, retrying automatically
  • MPRIS service disabled โ€” D-Bus integration is off (expected if dbus_allowed = false)

๐Ÿ“Š Screenshots

(Add screenshots to the docs/ folder)


๐Ÿค Contributing

We welcome contributions! Please read CONTRIBUTING.md before submitting pull requests.

Reporting Bugs

  • Check existing issues first
  • Include app version (somafm-tui --version or from PKGBUILD)
  • Attach logs from /tmp/.somafmtmp/somafm.log

Feature Requests

  • Describe the desired functionality
  • Explain how it improves user experience

๐Ÿ“„ License

Distributed under the MIT License. See LICENSE for details.


๐Ÿ™ Acknowledgments

  • SomaFM โ€” For amazing radio and open API
  • python-mpv โ€” For excellent MPV Python bindings
  • dbus-next โ€” For modern D-Bus library for Python

๐Ÿ“ฌ Contact


๐Ÿ—บ Roadmap

  • Listening history export
  • Last.fm integration (scrobbling)
  • Support for other streaming services
  • GUI settings via ncurses dialogs

Made with โค๏ธ for quality internet radio lovers

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

somafm_tui-0.5.10.tar.gz (47.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

somafm_tui-0.5.10-py3-none-any.whl (47.4 kB view details)

Uploaded Python 3

File details

Details for the file somafm_tui-0.5.10.tar.gz.

File metadata

  • Download URL: somafm_tui-0.5.10.tar.gz
  • Upload date:
  • Size: 47.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for somafm_tui-0.5.10.tar.gz
Algorithm Hash digest
SHA256 6ae62a56687c7125235bf6635166ac4d1133ca3a185fbdcc666bb6f202bb69d9
MD5 4d15fad6c0c3435a9ad27f1613b7264f
BLAKE2b-256 65f789c2449e9a8d2fd61111dadda6993f9c434e1db5864e6a84096396edac4d

See more details on using hashes here.

File details

Details for the file somafm_tui-0.5.10-py3-none-any.whl.

File metadata

  • Download URL: somafm_tui-0.5.10-py3-none-any.whl
  • Upload date:
  • Size: 47.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for somafm_tui-0.5.10-py3-none-any.whl
Algorithm Hash digest
SHA256 fee6bea7485e4318173877d6c4a1ba316b365778e8718acf8c3ce9a0723a81a1
MD5 60044d9fcfed6701968f7e3795dedbd9
BLAKE2b-256 f3c0de3858effbfc03506ffff1814844f0411f6a7c052a3112df63de265e69bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page