A customisable client for Discord rich presence using simple Lua configuration.

Related tags

System tools Disco
Overview

Installation | Usage | Configuration | Example

Disco

Github Crates.io Unlicense

Disco is a customisable client for Discord rich presence using simple Lua configuration.

Installation

Disco can be installed from crates.io or manually installed from GitHub.

Creates.io

Assuming you already have the rust toolchain installed, you can simply install disco by running

cargo install disco-rpc

To allow Lua to call external C libraries, the unsafe feature flag also needs to be enabled.

cargo install disco-rpc --features unsafe

GitHub

Prebuilt binaries are currently provided for x86_64-linux-gnu both with and without the unsafe flag. Disco can also be built from source via cargo

git clone https://github.com/KaitlynEthylia/Disco
cd Disco
cargo install --path .

As with the crates.io installation, --features unsafe my optionally be appended to the final command.

Usage

Running the command disco will automatically look for a Lua file to read configuration from as described in the configuration section. There are a handful of arguments that may be passed to the command to adjust how it runs.

Naturally, the -h, --help and -V, --version flags exist. As well, there is a -p --print-config-path flag, which will prevent the programme from running and print the location that it would otherwise look for a configuration file. The other flags that actually affect the programme are:

-c, --config : Overrides the default path to look for configuration.
-i, --client-id <CLIENT_ID>: Sets the ID of the application to connect as. Takes precedent over Lua configuration.
-r, --retry-after : If connecting to Discord fails, retry after DELAY seconds [default: 0]
-q, --quiet: Don't print any text to the console.

Configuration

Disco will look for a config file by first seeing if one has been given in the command line via the -c flag. If not, it will look at the DISCO_CONFIG environment variable. If that is not set, it will then check $XDG_CONFIG_HOME/disco.lua and lastly $HOME/disco.lua.

If it still cannot find a config file, it will error. There is no default configuration.

The rich presence is made up of a series of variable that can be set in the config file.

Variable Type Description
Active boolean Whether or not to display the rich presence.
Details string The first line of the rich presence.
State string The second line of the rich presence.
Timestaamp Timestamp A timestamp to count up or count down, appears in the same location as State. Note that the timestamp can be buggy. If the rich presence is not displaying, you may have set this value incorrectly, remove it and see if that solves the issue.
LargeImage Image The main image on the left hand side of the presence.
SmallImage Image The image in the bottom left corner of the large image.
Button1 Button A button that can direct to a URL.
Button2 Button A second button that can direct to a URL. Discord only supports a maximum of 2.

the types Timestamp, Image, and Button are not part of lua, they each represent:

Type Explanation Examples
Timestamp a table containing an option start key, and an optional _end key. alternatively, a single integer equivelelent to setting start but not _end. { start = 12345, _end = 23456 } or 10000.
Image a URL to the image or a table whose first element is a URL, and with a key text representing the text that appears when hovering over the image. 'https://example.com/image.png' or { 'https://example.com/image.png', text = "Some Image" }.
Button a URL to be directed to, or a table whose first element is the text to display on the image, and with a key url which is the url to be directed to. 'https://example.org' or { 'Example Website', url = 'https://example.org' }.

Each of these variables can be set in 3 different ways:

  • It can be set simply by assigning the variable the value. We will call this a 'static' variable, because its value will not change throughout the programme.
State = "Some Text"
  • It can be set via a table. The second element being a function that returns the value, and the first element being the number of seconds between successive calls of this function. This we will call a 'polled' variable.
State = { 60, function()
    return os.date("%H:%M")
end }

Here it runs the os.date() function every 60 seconds to get the system time.

  • Lastly, it can be set via a coroutine. This coroutine will continually be resumed, and should yield a value to set each time.
State = coroutine.create(function()
    for i = 1, 10, 1 do
        coroutine.yield("Number: " .. i)
    end
end)

In this example, the coroutine counts up to ten and then stops returning. Once it stops, the final value remains. This example is contrived, but a more complex example can be seen in the example section

Disco may also call external lua libraries, however, if that library requires C libraries, the unsafe feature flag will need to be enabled.

-- requires the `http` library to be installed, as well as the
-- `unsafe` feature to be enabled.
local request = require 'http.request'

local _, stream = request.new_from_uri('https://api.rot26.org/encrypt/test'):go()
State = stream:get_body_as_string()

Example

Here is my personal configuration that I use on my Arch Linux + Hyprland setup so show some details. This isn't exactly what I use but I have modified it slightly to demonstrate some features that I didn't use, such as polling.

-- ID of the client I created for ArchLinux via
-- https://discord.com/developers/applications
ClientID = 1137762526541656105

-- Display the rich presence
Active = true

-- Show what time it is on my machine on the first line, rerun
-- the function every 60 seconds.
Details = { 60, function()
	return "My Time: " .. os.date("%H:%M")
end }

-- Plug into the Hyprland socket to show which window is currently
-- active, and update every time I switch window.
State = coroutine.create(function()
	local handle = io.popen([[
		socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - |
		stdbuf -o0 awk -F '>>|,' '/^activewindow>>/{ $2 = toupper(substr($2, 1, 1)) substr($2, 2); print $2}'
	]])
	if not handle then return end
	for line in handle:lines() do
		coroutine.yield("Using: " .. line)
	end
end)

-- Display the Arch Linux logo
LargeImage = {
	'https://seeklogo.com/images/A/arch-linux-logo-3C25E68BA9-seeklogo.com.png',
	text = 'Arch Linux',
}

-- Include the Hyprland logo in the corner
SmallImage = {
	'https://i.imgur.com/PanwaBQ.png',
	text = 'Hyprland',
}

-- A really cool button
Button1 = {
	'Press This Button!',
	url = 'https://youtu.be/dQw4w9WgXcQ',
}

Before Release

Things that intend to be done before i could be happy calling this a 1.0.0 project.

  • Provide extra utilitly functions to make some tasks easier.
  • Test compaility on non x86_64-linux-gnu machines, and fix where possible.
  • Provide bash, zsh, and fish completions with the releases.
  • Provide template systemd and potentially runit and openrc services for running on startup.
  • Fix bugs that are more than likely to show up, and provide friendlier error handling.

None of these goals are particularly quick and easy, so they are likely to only end up completed if enough interest is shown in the tool.

You might also like...
An abstraction build on top of discord-rich-presence that makes possible to use it in a more declarative way

Declarative Discord Rich Presence This library is an abstraction build on top of discord-rich-presence crate that allows you to use it in a more decla

Discord Rich Presence for Creative Apps
Discord Rich Presence for Creative Apps

Show your friends what you're working on, be it in Adobe Suite, Autodesk Suite, Cinema 4D or many more! Currently supported: C4D, Adobe Suite, Davinci Resolve, Maya, 3Ds Max, Sony Vegas, Substance suite, Isotropix suite, FL, Ableton, Blender, Cavalry,

Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

Wealthy Rich ported to Rust! This aims to be a crate for rich text and beautiful formatting in the terminal

Wealthy Rich ported to Rust! This aims to be a crate for rich text and beautiful formatting in the terminal

Rich terminals. follows Python's rich conventions
Rich terminals. follows Python's rich conventions

richterm use richterm::print; use richterm::text; use richterm::track; use richterm::progress; use std::{thread, time}; fn main() { let vec = ve

Lua bytecode parser written in Rust using nom, part of metaworm's lua decompiler

luac-parser (中文) lua字节码解析器, 目前支持 lua51, lua53, lua54 这是目前效果最好的lua反编译器 metaworm's luadec 的一部分 可以基于此代码定制你所需的lua字节码解析器,编译成WASM,让metaworm's luadec加载使用,来反编

A cross-platform application for custom presence on Discord.
A cross-platform application for custom presence on Discord.

Discord Presence ⚠️ macOS is NOT supported. This is due the package for setting the presence being broken on mac. It may work for some people (only wh

Customisable CLI agents to answer all your quick questions. ⚙️

Agent Smith 🕵️‍♂️ Your ally in the battle for mental space between you and the multiverse of CLI tools. 👽 Setup OpenAI API Token You need to set the

Swayidle alternative to handle wayland idle notifications, sleep and lock events in Rust with Lua scripting based configuration language

swayidle-rs This is intended as a replacement of sway's idle management daemon. I use it as a tool to understand rust message passing and state manage

A rust layered configuration loader with zero-boilerplate configuration management.

salak A layered configuration loader with zero-boilerplate configuration management. About Features Placeholder Key Convension Cargo Features Default

A systemd-boot configuration and boot entry configuration parser library

A systemd-boot configuration and boot entry configuration parser library

Kusion Configuration Language (KCL) is an open source configuration language mainly used in Kusion Stack

Kusion Configuration Language (KCL) is an open source configuration language mainly used in Kusion Stack. KCL is a statically typed language for configuration and policy scenarios, based on concepts such as declarative and Object-Oriented Programming (OOP) paradigms.

wireguard tool to manage / generate configuration. Maintain one yaml configuration file to quickly build wireguard network.

wgx wireguard tool to manage / generate configuration. Maintain one yaml configuration file to quickly build wireguard network. Usage wgx --h USAGE:

Envful is a CLI tool that verifies the presence of environment variables
Envful is a CLI tool that verifies the presence of environment variables

Envful is a CLI tool that verifies the presence of environment variables. It looks inside your .env file and the host system. You can use it to run any process while ensuring all the variables are set.

A small discord bot to archive the messages in a discord text channel.

discord-channel-archiver A small discord bot to archive the messages in a discord text channel. This is still WIP. The HTML and JSON modes are vaguely

A Discord bot focused on addressing the inherent problems with Discord, to allow a more socialist/anarchist organization of servers.

ACABot A Discord bot focused on addressing the inherent problems with Discord, to allow a more socialist/anarchist organization of servers (or "guilds

A rust(serenity) based discord bot for the hacksquad discord server

A Discord Bot for Hacksquad How to Deploy? Requirements Docker Docker Compose Steps To Run Copy the docker-compose.yml and .env.example files to your

A fast & light weight Discord Client made with love using the Rust programming language.
A fast & light weight Discord Client made with love using the Rust programming language.

LemonCord A fast & light-weight Discord Client written in Rust using the wry crate. Features Fast, light-weight, easy to use. 100% Open sourced. No su

Safe and rich Rust wrapper around the Vulkan API
Safe and rich Rust wrapper around the Vulkan API

Vulkano See also vulkano.rs. Vulkano is a Rust wrapper around the Vulkan graphics API. It follows the Rust philosophy, which is that as long as you do

Releases(0.1.0)
Owner
KaitlynEthylia
Biblically accurate code
KaitlynEthylia
📊 Fetch & monitor your server's resource usage through Lua

?? gmsv_serverstat Simple serverside binary module which can expose information about system resource usage to Lua. Installation Download the relevant

William 21 Jul 30, 2022
Everyday-use client-side map-aware Arch Linux mirror ranking tool

Rate Arch Mirrors This is a tool, which fetches mirrors, skips outdated/syncing Arch Linux mirrors, then uses info about submarine cables and internet

Nikita Almakov 196 Jan 2, 2023
A client-side gRPC channel implementation for tonic

ginepro ginepro provides client-side gRPC load-balancing out of the box by enriching tonic ‘s channel with periodic service discovery. Overview ginepr

TrueLayer 92 Jan 3, 2023
A tool for quickly switching between different file configurations, using symbolic links.

config-loader A tool for quickly switching between different file configurations, using symbolic links. Usage To use it, download the latest release f

Zacchary Dempsey-Plante 3 Aug 22, 2022
A small linktree style app using Yew.

Links This is a small website built using Yew. It uses trunk to run locally, and build for deployment. I wanted to explore this library and see how it

Josh Finnie 4 Aug 29, 2022
A simple and fast download accelerator, written in Rust

zou A simple and fast download accelerator, written in Rust Zou is a Snatch fork by @k0pernicus. Snatch is a fast and interruptable download accelerat

Antonin Carette 173 Dec 4, 2022
A simple, fast and user-friendly alternative to 'find'

fd [中文] [한국어] fd is a program to find entries in your filesytem. It is a simple, fast and user-friendly alternative to find. While it does not aim to

David Peter 25.8k Dec 30, 2022
A simple rust-based tool for fetching system information

?? azf a simple rust-based tool for fetching system information you need a patched nerd font and the material design icons font ?? compiling you can c

Pedro Henrique 3 Dec 17, 2022
A Discord Rich Presence for cmus player using rust 🦀💙

A Discord Rich Presence for cmus player with ?? Require cmus Install from crates.io crago install cmus-rpc-rs Options: Option Description Values -h or

Anas Elgarhy 14 Dec 3, 2022
Discord RIch Presence in Rust, with native Bevy support

Discord Presence The root project for both Bevy Discord Presence and regular Discord Presence, both contained in the crates directory. TODO Allow invi

Juliette Cordor 22 Nov 29, 2022