TUI for Telegram written in Rust
A simple TUI for Telegram
[!NOTE]
tgtwas created before the AI era as a personal project to learn Rust.
tgt is a terminal user interface for Telegram, written in Rust.
From crates.io
cargo install tgt
From source downloading the tdlib
cargo build --release --features download-tdlib
After the installation, you can run tgt with the following command:
tgt --help
Build features can be combined (e.g. cargo build --release --features download-tdlib,chafa-dyn).
| Feature | Description |
|---|---|
default |
Enables download-tdlib and voice-message. |
download-tdlib |
Download and use TDLib automatically (recommended for most users). |
local-tdlib |
Use TDLib from path in LOCAL_TDLIB_PATH. |
pkg-config |
Find TDLib via pkg-config. |
static |
Statically link tdjson (use with download-tdlib or local-tdlib). No runtime tdjson dependency needed. |
voice-message |
Play Telegram voice notes (OGG Opus) and other audio (e.g. MP3). Requires CMake to build the Opus dependency. Enabled by default; use --no-default-features and then add back only the features you need (e.g. --features download-tdlib) to disable voice. |
chafa-dyn |
Enable chafa-based image rendering in the photo viewer (dynamic linking). Requires the chafa library installed on the system. Not supported on Windows ARM. |
chafa-static |
Same as chafa-dyn but links chafa statically. Not supported on Windows ARM. |
Voice messages
If you build with the default features (or with voice-message enabled), you must have CMake installed so the Opus library can be built. Other audio formats (e.g. MP3) use rodio only; only Telegram voice notes (Opus) need this. If you build with --no-default-features and do not enable voice-message, voice playback is disabled and the app will show a message when you try to play a voice note.
Installation methods for CMake (when using voice-message)
brew install cmakesudo apt install cmake (Debian/Ubuntu), sudo dnf install cmake (Fedora), sudo pacman -S cmake (Arch)winget install Kitware.CMakeChafa (image rendering)
The chafa-dyn and chafa-static features use the chafa library to display images in the terminal. You must have chafa installed to use these features.
Installation methods for chafa
sudo apt install chafa (Debian/Ubuntu/Kali)sudo dnf install chafa (Fedora)sudo pacman -S chafa (Arch Linux)sudo zypper in chafa (openSUSE)sudo emerge media-gfx/chafa (Gentoo)brew install chafasudo port install chafascoop install chafawinget install hpjansson.ChafaThanks to x-leehe for creating the AUR package. You can install tgt from the AUR:
yay -S tgt-client-git
From flake.nix
Config directories are created automatically on first run, or you can generate initial config with tgt init-config (see CONFIG.md). Then you have two installation options:
nix run:nix run github:FedericoBruzzone/tgt
tgt to your system packages:Add the following to your flake.nix:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"
tgt.url = "github:FedericoBruzzone/tgt";
tgt.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { nixpkgs, tgt, ... }: { /* ... */ }
}
Then add it to your environment.systemPackages:
{pkgs, tgt, ...}: {
environment = {
systemPackages = [
(tgt.packages.${pkgs.system}.default)
];
};
}
To use a specific version of the program, override the src attribute:
{pkgs, tgt, ...}: {
environment = {
systemPackages = [
(tgt.packages.${pkgs.system}.default.overrideAttrs (old: {
src = pkgs.fetchFromGitHub {
owner = old.src.owner;
repo = old.src.repo;
rev = "00000000000000000000000000000000000000";
sha256 = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};
cargoHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
}))
];
};
}
The Docker image is built using rust:1.91-trixie as the base.
Run Docker image in interactive mode to open a bash shell. Specify a container name to reuse when required.
docker run -it --name ghcr.io/FedericoBruzzone/tgt:
tgt command from bash shell.tgt
docker container start
tgt by opening interactive shell from the containerdocker exec -it bash
tgt is fully customizable. Config uses XDG-style paths (e.g. ~/.config/tgt on Linux) with backwards compatibility for the legacy ~/.tgt folder. The app creates config directories at startup if missing, and bundles default configs so it works out of the box after cargo install. Configs are versioned and the program adds missing keybindings on upgrade. Use tgt init-config to generate initial config files and tgt clear --config (or --data / --logs / --all) to remove them for a fresh start.
For config locations, versioning, CLI commands, keybindings, and per-file details, see CONFIG.md.
Contributions to this project are welcome! If you have any suggestions, improvements, or bug fixes, feel free to submit a pull request. For more information, do not hesitate to contact us (see the Contact section).
Build instructions
There are three ways to build tgt:
download-tdlib feature of tdlib-rs you do not need to set any environment variable. Then you can compile tgt using cargo build --features download-tdlib.tgt assumes that you have the tdlib built and the LOCAL_TDLIB_PATH environment variable set to the path of the tdlib directory. You can set the environment variable with the following command: export LOCAL_TDLIB_PATH="/path/to/tdlib". Then you can compile tgt using cargo build or cargo build --feature default.pkg-config to find the path of the library. In this case see the CONTRIBUTING.md file for more information. Then you can compile tgt using cargo build --features pkg-config.You can also add static to statically link tdjson, so the final binary does not require tdjson installed at runtime (e.g. cargo build --features download-tdlib,static).
The CONTRIBUTING.md file contains information for building tgt and the steps to configure the tdlib in your local environment, starting from the compilation to the configuration of the environment variables.
You can find the road map of the project here (in the pinned issues).
You can use make or cargo, as build tools.
If you want to use cargo, please make sure to read the the Makefile to understand the flags used for each command.
Here are the available commands:
make COMMAND
COMMAND:
all # Run fmt, clippy and test
build # Build the project
run # Run the project
test # Run the tests
clippy # Run clippy
fmt # Run rustfmt
clean # Clean the project
This repository is licensed under either of
Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Please review the license file provided in the repository for more information regarding the terms and conditions of the license.
If you have any questions, suggestions, or feedback, do not hesitate to contact me.
Maintainers:
No open issues yet, or sync has not completed.