Skip to content

abenz1267/elephant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Elephant ๐Ÿ˜

Elephant - cuz it's phat - is a powerful data provider service and backend for building custom application launchers and desktop utilities. It provides various data sources and actions through a plugin-based architecture, communicating via Unix sockets and Protocol Buffers.

Discord License: GPL v3

Overview

Elephant acts as a unified backend service that aggregates data from various sources (desktop applications, files, clipboard history, etc.) and provides a consistent interface for frontend applications like custom launchers, productivity tools, or desktop widgets.

Features

Current Providers

  • ๐Ÿš€ Desktop Applications

    • Auto-detection of uwsm or app2unit
    • Application launch history
    • Desktop entry parsing
  • ๐Ÿ“ Files

    • File preview (text/image)
    • File operations: open, copy path, copy content
    • Directory navigation
  • ๐Ÿ“‹ Clipboard

    • Text and image clipboard history
    • Clipboard content management
  • โšก Runner

    • Command execution from explicit lists
    • $PATH scanning for executables
  • ๐Ÿ”ฃ Symbols/Emojis

    • Multi-locale emoji and symbol support
    • Unicode character database
  • ๐Ÿงฎ Calculator/Unit Conversion

    • Mathematical calculations with history
    • Unit conversion using qalc
  • ๐Ÿ“‹ Custom Menus

    • User-defined menu creation
    • Custom action definitions
  • ๐Ÿ“Š Provider List

    • Dynamic listing of all loaded providers and menus
  • ๐ŸŒ Websearch

    • ... define custom search engines

Installation

Installing on Arch

yay -S elephant

# Providers, f.e.

yay -S elephant-desktopapplications

Building from Source

# Clone the repository
git clone https://github.com/abenz1267/elephant
cd elephant

# Build and install the main binary
cd cmd
go install elephant.go

# Create configuration directories
mkdir -p ~/.config/elephant/providers

# Build and install a provider (example: desktop applications)
cd ../internal/providers/desktopapplications
go build -buildmode=plugin
cp desktopapplications.so ~/.config/elephant/providers/

Usage

Starting the Service

# Start elephant with default configuration
elephant

# Start with debug logging
elephant --debug

# Use custom configuration directory
elephant --config /path/to/config

Command Line Interface

Elephant includes a built-in client for testing and basic operations:

Querying Data

# Query provider (providers;query;limit;exactsearch)
elephant query "files;documents;10;false"

Activating Items

# activate item (qid;provider;identifier;action;query)
elephant activate "1;files;<identifier>;open;"

Other Commands

# List all installed providers
elephant listproviders

# Open a custom menu, requires a subscribed frontend.
elephant menu "screenshots"

# Show version
elephant version

# Generate configuration documentation
elephant generatedoc

Configuration

Elephant uses a configuration directory structure:

~/.config/elephant/
โ”œโ”€โ”€ elephant.toml        # Main configuration
โ”œโ”€โ”€ .env                 # Environment variables
โ””โ”€โ”€ providers/           # Provider plugins
    โ”œโ”€โ”€ files.so
    โ”œโ”€โ”€ desktopapplications.so
    โ””โ”€โ”€ ...

API & Integration

Communication Protocol

Elephant uses Unix domain sockets for IPC and Protocol Buffers for message serialization. The main message types are:

  • Query Messages: Request data from providers
  • Activation Messages: Execute actions
  • Menu Messages: Request custom menu data
  • Subscribe Messages: Listen for real-time updates

Building Client Applications

To integrate with Elephant, your application needs to:

  1. Connect to the Unix socket (typically at /tmp/elephant.sock)
  2. Send Protocol Buffer messages
  3. Handle responses and updates

See the pkg/pb/ directory for Protocol Buffer definitions.

Development

Project Structure

elephant/
โ”œโ”€โ”€ cmd/                 # Main application entry point
โ”œโ”€โ”€ internal/
โ”‚   โ”œโ”€โ”€ comm/           # Communication layer (Unix sockets, protobuf)
โ”‚   โ”œโ”€โ”€ common/         # Shared utilities and configuration
โ”‚   โ”œโ”€โ”€ providers/      # Data provider plugins
โ”‚   โ””โ”€โ”€ util/          # Helper utilities
โ”œโ”€โ”€ pkg/pb/            # Protocol Buffer definitions
โ””โ”€โ”€ flake.nix          # Nix development environment

Creating Custom Providers

Providers are Go plugins that implement the provider interface. See existing providers in internal/providers/ for examples.

Building from Source

# Clone repository
git clone https://github.com/abenz1267/elephant
cd elephant

# Install dependencies
go mod download

# Build main binary
go build -o elephant cmd/elephant.go

# Run tests
go test ./...

Development Environment

A Nix flake is provided for reproducible development:

nix develop

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

Please ensure your code follows Go best practices and includes appropriate documentation.

Current Status

โš ๏ธ Work in Progress: This project is in active development and the API may change. Use with caution in production environments.

License

This project is licensed under the GNU General Public License v3.0. See LICENSE for details.

Support