Skip to content

pinpinroku/termin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

termin

Target License: GPL-3.0 Build Status

termin is a lightweight Rust library designed to detect installed terminal emulators and execute commands within them. It is specifically tailored for CachyOS (Arch Linux) to ensure seamless integration with the distribution's preferred environment.

✨ Features

  • Auto-Detection: Scans the system for available terminals based on a predefined priority list (Alacritty, Foot, Konsole, etc.).
  • Smart Execution: Handles terminal-specific flags (e.g., -e, --wait) automatically.
  • Privilege Escalation: Built-in support for pkexec to run commands as root.
  • Environment Aware: Respects the $TERMINAL environment variable.

🚀 Installation

Add termin to your Cargo.toml:

[dependencies]
termin = { git = "[https://github.com/pinpinroku/termin](https://github.com/pinpinroku/termin)" }

🛠 Usage

The simplest way to run a command in the user's preferred terminal:

use termin;

fn main() {
    // Run a system update in a new terminal window
    let success = termin::run_command("pacman -Syu", true);

    if !success {
        eprintln!("Could not find a supported terminal emulator.");
    }
}

Advanced Usage

If you need more control over the detection logic:

use termin::Terminal;

fn main() {
    // 1. Detection based on priority list
    let term = termin::get().expect("No terminal found");

    // 2. Build a custom command
    let cmd = term.build_cmd("echo 'Hello CachyOS!'", false);

    // 3. Spawn the process
    term.spawn(cmd).unwrap();
}

📋 Priority List

termin searches for terminals in the following order to match the CachyOS experience:

  1. Alacritty (Performance)
  2. Foot (Wayland optimized)
  3. Konsole (KDE default)
  4. Kgx (Modern GNOME)
  5. ...and many more (Xfce4, Kitty, Ghostty, etc.)

🤝 Contributing

Contributions are welcome! If you want to add support for a new terminal:

  1. Open an issue with the binary name and spawn flags.
  2. Or submit a Pull Request by adding a new variant to the Terminal enum.

Please see the documentation for more technical details.

⚖️ License

This project is licensed under the GPL-3.0-only. See the LICENSE file for details.

About

A utility to detect installed terminal emulators and spawn commands within them, tailored for CachyOS.

Resources

License

Stars

Watchers

Forks

Contributors

Languages