Skip to content

Lightweight native Discord client for Windows, Linux and macOS, written in Rust. No Electron, no browser engine.

Build RustCord for Linux

VRonGitHub818d25c78695
diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
new file mode 100644
index 0000000..b34c30b
--- /dev/null
+++ b/.github/workflows/linux.yml
@@ -0,0 +1,63 @@
+# Builds RustCord for Linux on GitHub's machines. Every push gets a download
+# under the run's "Artifacts"; a published release also gets the .tar.gz
+# attached next to the Windows installer.
+name: Linux build
+
+on:
+ push:
+ branches: [main, linux]
+ pull_request:
+ release:
+ types: [published]
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+jobs:
+ build:
+ # The oldest supported Ubuntu with WebKitGTK 4.1: the binary then runs on
+ # Ubuntu 22.04+, Debian 12+, Fedora 36+ and other distributions this new.
+ runs-on: ubuntu-22.04
+ permissions:
+ contents: write
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Install the system libraries
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y --no-install-recommends \
+ pkg-config cmake nasm \
+ libwebkit2gtk-4.1-dev libgtk-3-dev \
+ libasound2-dev libdbus-1-dev libssl-dev libxdo-dev
+
+ - uses: dtolnay/rust-toolchain@stable
+
+ - uses: Swatinem/rust-cache@v2
+
+ - name: Build
+ # The badge registry's address comes from a repository secret, like
+ # registry-url.local on Windows; without it the build has no registry.
+ env:
+ RUSTCORD_REGISTRY_URL: ${{ secrets.RUSTCORD_REGISTRY_URL }}
+ run: cargo build --locked --release -p rustcord
+
+ - name: Package
+ run: sh packaging/linux/package.sh
+
+ - uses: actions/upload-artifact@v4
+ with:
+ name: rustcord-linux-x86_64
+ path: |
+ dist/*.tar.gz
+ dist/*.tar.gz.sha256
+
+ - name: Attach to the release
+ if: github.event_name == 'release'
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: gh release upload "${{ github.event.release.tag_name }}" dist/*.tar.gz dist/*.tar.gz.sha256 --clobber
+
+ - name: Test
+ run: cargo test --locked -p discord -p rencord -p voice -p rustcord
diff --git a/Cargo.lock b/Cargo.lock
index 81c892b..5126b28 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -699,6 +699,15 @@ dependencies = [
"hybrid-array",
]
+[[package]]
+name = "block-padding"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93"
+dependencies = [
+ "generic-array",
+]
+
[[package]]
name = "block2"
version = "0.5.1"
@@ -849,6 +858,15 @@ dependencies = [
"wayland-client",
]
+[[package]]
+name = "cbc"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6"
+dependencies = [
+ "cipher",
+]
+
[[package]]
name = "cc"
version = "1.11.0"
@@ -1388,6 +1406,36 @@ dependencies = [
"tracing",
]
+[[package]]
+name = "dbus"
+version = "0.9.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ab69f03cc8c4340c9c8e315114e1658e6775a9b16a04357973aa21cec22b32e"
+dependencies = [
+ "libc",
+ "libdbus-sys",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "dbus-secret-service"
+version = "4.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f09471353f53b2f583ca422638cfe48a375050cdcb9e46a442b04123e74163f5"
+dependencies = [
+ "aes",
+ "block-padding",
+ "cbc",
+ "dbus",
+ "fastrand",
+ "hkdf",
+ "libc",
+ "num",
+ "once_cell",
+ "sha2",
+ "zeroize",
+]
+
[[package]]
name = "defmt"
version = "1.2.0"
@@ -3216,6 +3264,7 @@ version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"
dependencies = [
+ "block-padding",
"generic-array",
]
@@ -3418,8 +3467,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eebcc3aff044e5944a8fbaf69eb277d11986064cba30c468730e8b9909fb551c"
dependencies = [
"byteorder",
+ "dbus-secret-service",
"linux-keyutils",
"log",
+ "secret-service",
"security-framework 2.11.1",
"security-framework 3.7.0",
"windows-sys 0.60.2",
@@ -3464,6 +3515,15 @@ version = "0.2.191"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
+[[package]]
+name = "libdbus-sys"
+version = "0.2.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "328c4789d42200f1eeec05bd86c9c13c7f091d2ba9a6ea35acdf51f31bc0f043"
+dependencies = [
+ "pkg-config",
+]
+
[[package]]
name = "libloading"
version = "0.8.9"
@@ -3826,6 +3886,20 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
+[[package]]
+name = "num"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23"
+dependencies = [
+ "num-bigint",
+ "num-complex",
+ "num-integer",
+ "num-iter",
+ "num-rational",
+ "num-traits",
+]
+
[[package]]
name = "num-bigint"
version = "0.4.8"
@@ -3872,6 +3946,16 @@ dependencies = [
"num-traits",
]
+[[package]]
+name = "num-iter"
+version = "0.1.46"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c92800bd69a1eac91786bcfe9da64a897eb72911b8dc3095decbd07429e8048b"
+dependencies = [
+ "num-integer",
+ "num-traits",
+]
+
[[package]]
name = "num-rational"
version = "0.4.2"
@@ -5417,6 +5501,7 @@ dependencies = [
"embed-resource",
"env_logger",
"flate2",
+ "gtk",
"image",
"keyring",
"libmimalloc-sys",
@@ -5622,6 +5707,25 @@ dependencies = [
"zeroize",
]
+[[package]]
+name = "secret-service"
+version = "4.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e4d35ad99a181be0a60ffcbe85d680d98f87bdc4d7644ade319b87076b9dbfd4"
+dependencies = [
+ "aes",
+ "cbc",
+ "futures-util",
+ "generic-array",
+ "hkdf",
+ "num",
+ "once_cell",
+ "rand 0.8.8",
+ "serde",
+ "sha2",
+ "zbus 4.4.0",
+]
+
[[package]]
name = "security-framework"
version = "2.11.1"
diff --git a/apps/rustcord/Cargo.toml b/apps/rustcord/Cargo.toml
index 5e682b1..1859733 100644
--- a/apps/rustcord/Cargo.toml
+++ b/apps/rustcord/Cargo.toml
@@ -20,7 +20,10 @@ env_logger = "0.11"
# READY snapshot cache (zlib) and memory-mapped system fonts.
flate2 = "1"
memmap2 = "0.9"
-keyring = { version = "3", features = ["windows-native", "apple-native", "linux-native"] }
+# The saved login: Windows Credential Manager, the macOS Keychain, and on Linux
+# the desktop's keyring (Secret Service: GNOME Keyring, KWallet), which survives
+# a restart, unlike the kernel keyring alone.
+keyring = { version = "3", features = ["windows-native", "apple-native", "linux-native-sync-persistent", "crypto-rust"] }
log = "0.4"
mimalloc = { version = "0.1", default-features = false }
# mi_collect / statistics (handing freed memory back to Windows when idle).
@@ -54,6 +57,11 @@ dev-hooks = []
[build-dependencies]
embed-resource = "2"
+[target.'cfg(target_os = "linux")'.dependencies]
+# The embedded web pages are WebKitGTK views there: GTK is started and pumped
+# by src/linux.rs. The version wry 0.57 uses.
+gtk = "0.18"
+
[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.59", features = ["Win32_Foundation", "Win32_System_Diagnostics_Debug", "Win32_System_Kernel", "Win32_System_LibraryLoader", "Win32_UI_WindowsAndMessaging", "Win32_UI_Shell", "Win32_Graphics_Gdi", "Win32_Graphics_Dwm", "Win32_UI_Input_KeyboardAndMouse", "Win32_System_Registry",
# Sealing the on-disk caches (DPAPI, see src/cache.rs).
diff --git a/apps/rustcord/src/app.rs b/apps/rustcord/src/app.rs
index 077ebda..14a0ad6 100644
--- a/apps/rustcord/src/app.rs
+++ b/apps/rustcord/src/app.rs
@@ -3685,6 +3685,11 @@ impl eframe::App for RustCord {
v.place(rect, clip, ctx.pixels_per_point());
}
}
+ #[cfg(target_os = "linux")]
+ {
+ let web_page_open = self.login_view.is_some() || self.retired_login_view.is_some() || self.captcha.as_ref().is_some_and(|c| c.view.is_some()) || self.embed_view.is_some();
+ crate::linux::pump(ctx, web_page_open);
+ }
self.tray_actions(ctx);
// Ctrl + R reloads the client, like Discord. (Not AltGr + R, which is
// Ctrl + Alt on Windows and types a letter on some layouts; holding
diff --git a/apps/rustcord/src/captcha_view.rs b/apps/rustcord/src/captcha_view.rs
index 273d6c6..6b7f362 100644
--- a/apps/rustcord/src/captcha_view.rs
+++ b/apps/rustcord/src/captcha_view.rs
@@ -98,6 +98,8 @@ fn script(challenge: &Challenge, capability: &str) -> String {
impl CaptchaView {
pub fn open(parent: &impl HasWindowHandle, challenge: &Challenge, rect: egui::Rect, pixels_per_point: f32) -> Result<Self, String> {
+ #[cfg(target_os = "linux")]
+ crate::linux::web_pages_available()?;
let (send, answers) = sync_channel(1);
let capability: String = (0..32).map(|_| format!("{:02x}", rand::random::<u8>())).collect::<String>() + ":";
let prefix = capability.clone();
diff --git a/apps/rustcord/src/diagnostics.rs b/apps/rustcord/src/diagnostics.rs
index 0a7f84b..3d02e80 100644
--- a/apps/rustcord/src/diagnostics.rs
+++ b/apps/rustcord/src/diagnostics.rs
@@ -245,6 +245,10 @@ pub fn working_set_mb() -> u64 {
return (c.working_set / (1024 * 1024)) as u64;
}
}
+ #[cfg(target_os = "linux")]
+ if let Some(p) = linux_proc::read(std::process::id()) {
+ return p.working_set / (1024 * 1024);
+ }
0
}
@@ -439,12 +443,71 @@ pub fn process_tree() -> Vec<ProcessInfo> {
{
win_mem::process_tree()
}
- #[cfg(not(windows))]
+ #[cfg(target_os = "linux")]
+ {
+ linux_proc::process_tree()
+ }
+ #[cfg(not(any(windows, target_os = "linux")))]
{
Vec::new()
}
}
+/// The Process Viewer's numbers on Linux, from /proc.
+#[cfg(target_os = "linux")]
+mod linux_proc {
+ use super::ProcessInfo;
+
+ /// The kernel's clock ticks per second for /proc's processor times
+ /// (USER_HZ, 100 on every Linux in use).
+ const TICKS: f64 = 100.0;
+
+ /// One process; None once it has gone.
+ pub fn read(pid: u32) -> Option<ProcessInfo> {
+ let dir = std::path::PathBuf::from(format!("/proc/{pid}"));
+ let stat = std::fs::read_to_string(dir.join("stat")).ok()?;
+ // The name sits in parentheses and may itself contain them: the
+ // fields after it start past the last ')'.
+ let fields: Vec<&str> = stat.get(stat.rfind(')')? + 2..)?.split_whitespace().collect();
+ let field = |i: usize| fields.get(i).and_then(|v| v.parse::<u64>().ok()).unwrap_or(0);
+ let status = std::fs::read_to_string(dir.join("status")).unwrap_or_default();
+ let kb = |key: &str| {
+ status.lines().find_map(|l| l.strip_prefix(key)?.trim().strip_suffix("kB")?.trim().parse::<u64>().ok()).map(|v| v * 1024)
+ };
+ Some(ProcessInfo {
+ pid,
+ // (state, ppid, …: fields 3 and 4 of `stat`, counted from 1.)
+ parent: field(1) as u32,
+ name: std::fs::read_to_string(dir.join("comm")).map(|s| s.trim().to_string()).unwrap_or_default(),
+ threads: field(17) as u32,
+ working_set: kb("VmRSS:").unwrap_or(0),
+ peak_working_set: kb("VmHWM:").unwrap_or(0),
+ private_working_set: kb("RssAnon:"),
+ committed: kb("VmData:").unwrap_or(0),
+ handles: std::fs::read_dir(dir.join("fd")).map(|d| d.count() as u32).unwrap_or(0),
+ cpu_seconds: (field(11) + field(12)) as f64 / TICKS,
+ })
+ }
+
+ /// RustCord and everything it started (the WebKit helpers behind its web
+ /// pages), RustCord first.
+ pub fn process_tree() -> Vec<ProcessInfo> {
+ let me = std::process::id();
+ let Some(first) = read(me) else { return Vec::new() };
+ let all: Vec<ProcessInfo> = std::fs::read_dir("/proc")
+ .map(|d| d.flatten().filter_map(|e| e.file_name().to_str()?.parse::<u32>().ok()).filter(|&p| p != me).filter_map(read).collect())
+ .unwrap_or_default();
+ let mut tree = vec![first];
+ let mut i = 0;
+ while i < tree.len() {
+ let parent = tree[i].pid;
+ tree.extend(all.iter().filter(|p| p.parent == parent).cloned());
+ i += 1;
+ }
+ tree
+ }
+}
+
#[cfg(windows)]
mod win_mem {
use super::ProcessInfo;
diff --git a/apps/rustcord/src/embed_view.rs b/apps/rustcord/src/embed_view.rs
index 8af8528..8e0d6a4 100644
--- a/apps/rustcord/src/embed_view.rs
+++ b/apps/rustcord/src/embed_view.rs
@@ -113,6 +113,8 @@ fn is_wrapper(url: &str) -> bool {
impl EmbedView {
/// A hidden webview showing `html`, at `b` (physical pixels).
fn create(parent: &impl HasWindowHandle, html: String, bg: egui::Color32, b: [i32; 4]) -> Result<Self, String> {
+ #[cfg(target_os = "linux")]
+ crate::linux::web_pages_available()?;
let (send, events) = sync_channel(8);
let send_popup = send.clone();
let html = Arc::new(Mutex::new(html));
diff --git a/apps/rustcord/src/features.rs b/apps/rustcord/src/features.rs
index c038c59..09c45cd 100644
--- a/apps/rustcord/src/features.rs
+++ b/apps/rustcord/src/features.rs
@@ -1287,10 +1287,18 @@ impl RustCord {
self.toast(format!("Couldn't start text-to-speech: {e}"), true);
}
}
- #[cfg(not(windows))]
+ // speech-dispatcher, which most desktops have. Its rate runs -100..100.
+ #[cfg(target_os = "linux")]
+ {
+ let rate = (self.prefs.tts_rate.clamp(-10, 10) * 10).to_string();
+ if let Err(e) = std::process::Command::new("spd-say").args(["-r", &rate, "--", &text]).spawn() {
+ self.toast(format!("Couldn't start text-to-speech (spd-say): {e}"), true);
+ }
+ }
+ #[cfg(not(any(windows, target_os = "linux")))]
{
let _ = text;
- self.toast("Speak Message is only available on Windows for now.", false);
+ self.toast("Speak Message isn't available on this system yet.", false);
}
}
diff --git a/apps/rustcord/src/linux.rs b/apps/rustcord/src/linux.rs
new file mode 100644
index 0000000..a5bb182
--- /dev/null
+++ b/apps/rustcord/src/linux.rs
@@ -0,0 +1,63 @@
+//! What RustCord needs on Linux that Windows does by itself.
+//!
+//! The embedded web pages (Discord's login page, captchas, media players) are
+//! WebKitGTK views. wry places them inside RustCord's window through X11, so
+//! RustCord runs as an X11 window (XWayland on a Wayland desktop), and GTK has
+//! to be started on the UI thread and given its events every frame.
+
+use std::sync::atomic::{AtomicBool, Ordering};
+
+static GTK_READY: AtomicBool = AtomicBool::new(false);
+
+static FORCED_X11: AtomicBool = AtomicBool::new(false);
+
+/// First thing in `main`, before any other thread exists (changing the
+/// environment isn't safe once one does): winit and GTK pick Wayland when they
+/// can, and the child web views need X11.
+pub fn prefer_x11() {
+ if std::env::var_os("WAYLAND_DISPLAY").is_some() && std::env::var_os("DISPLAY").is_some() {
+ std::env::remove_var("WAYLAND_DISPLAY");
+ std::env::set_var("GDK_BACKEND", "x11");
+ FORCED_X11.store(true, Ordering::Relaxed);
+ }
+}
+
+/// Before the window exists, on the UI thread: start GTK. Without it (no
+/// display, libraries missing) everything but the embedded pages still works.
+pub fn init() {
+ if FORCED_X11.load(Ordering::Relaxed) {
+ log::info!("linux: running as an X11 window (XWayland), for the embedded web pages");
+ }
+ match gtk::init() {
+ Ok(()) => GTK_READY.store(true, Ordering::Relaxed),
+ Err(e) => log::warn!("linux: GTK didn't start ({e}); Discord's login page and web players are unavailable"),
+ }
+}
+
+/// `Err` with a message for the person when web pages can't be shown.
+pub fn web_pages_available() -> Result<(), String> {
+ if GTK_READY.load(Ordering::Relaxed) {
+ Ok(())
+ } else {
+ Err("Web pages need GTK and WebKitGTK (webkit2gtk 4.1), which couldn't be started.".into())
+ }
+}
+
+/// Each frame: hand GTK its pending events. While a web page is open the
+/// window keeps drawing (about 60 times a second) so the page stays live.
+pub fn pump(ctx: &eframe::egui::Context, web_page_open: bool) {
+ if !GTK_READY.load(Ordering::Relaxed) {
+ return;
+ }
+ while gtk::events_pending() {
+ gtk::main_iteration_do(false);
+ }
+ if web_page_open {
+ ctx.request_repaint_after(std::time::Duration::from_millis(16));
+ }
+}
+
+/// Open a folder in the file manager.
+pub fn open_folder(dir: &std::path::Path) {
+ let _ = std::process::Command::new("xdg-open").arg(dir).spawn();
+}
diff --git a/apps/rustcord/src/login_view.rs b/apps/rustcord/src/login_view.rs
index cc42ee8..27016e9 100644
--- a/apps/rustcord/src/login_view.rs
+++ b/apps/rustcord/src/login_view.rs
@@ -60,6 +60,8 @@ impl LoginView {
/// `background` shows until the page draws (no white flash). Anything the
/// page sends wakes `ctx`, so a login is picked up at once.
pub fn open(parent: &impl HasWindowHandle, ctx: &egui::Context, rect: egui::Rect, pixels_per_point: f32, background: egui::Color32) -> Result<Self, String> {
+ #[cfg(target_os = "linux")]
+ crate::linux::web_pages_available()?;
let (send, tokens) = sync_channel(1);
let (send_note, notes) = sync_channel(16);
let (send_link, links) = sync_channel(8);
diff --git a/apps/rustcord/src/main.rs b/apps/rustcord/src/main.rs
index 6289446..a9e5dfc 100644
--- a/apps/rustcord/src/main.rs
+++ b/apps/rustcord/src/main.rs
@@ -31,6 +31,8 @@ mod shortcodes;
mod spellcheck;
mod highlight;
mod hotkey;
+#[cfg(target_os = "linux")]
+mod linux;
mod markdown;
mod media_copy;
mod store;
@@ -62,6 +64,8 @@ fn app_icon() -> egui::IconData {
}
fn main() -> eframe::Result<()> {
+ #[cfg(target_os = "linux")]
+ linux::prefer_x11();
// The uninstaller's "delete my saved login": end every saved session at
// Discord and forget it, with no window.
if std::env::args().any(|a| a == "--logout-all") {
@@ -70,6 +74,8 @@ fn main() -> eframe::Result<()> {
}
diagnostics::tune_allocator();
diagnostics::init();
+ #[cfg(target_os = "linux")]
+ linux::init();
diagnostics::close_other_instances();
diagnostics::idle::start();
let demo = std::env::args().any(|a| a == "--demo");
@@ -81,6 +87,8 @@ fn main() -> eframe::Result<()> {
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
.with_title(if demo { "RustCord (demo)" } else { "RustCord" })
+ // Linux: matches rustcord.desktop, so the dock shows RustCord's icon.
+ .with_app_id("rustcord")
.with_inner_size([1280.0, 800.0])
.with_min_inner_size([940.0, 560.0])
// Discord's desktop app draws its own title bar.
diff --git a/apps/rustcord/src/rpc.rs b/apps/rustcord/src/rpc.rs
index a0413d7..055697e 100644
--- a/apps/rustcord/src/rpc.rs
+++ b/apps/rustcord/src/rpc.rs
@@ -70,11 +70,52 @@ where
}
}
-#[cfg(not(windows))]
-pub async fn serve<F>(_user: SharedUser, _on_event: F)
+/// Linux and macOS: Discord's `discord-ipc-N` Unix socket, in the runtime folder
+/// where games look for it.
+#[cfg(unix)]
+pub async fn serve<F>(user: SharedUser, on_event: F)
where
F: Fn(RpcEvent) + Send + Sync + Clone + 'static,
{
+ use tokio::net::UnixListener;
+ let dir = ["XDG_RUNTIME_DIR", "TMPDIR", "TMP", "TEMP"]
+ .iter()
+ .find_map(std::env::var_os)
+ .map(std::path::PathBuf::from)
+ .unwrap_or_else(|| "/tmp".into());
+ let mut chosen = None;
+ for n in 0..10 {
+ let path = dir.join(format!("discord-ipc-{n}"));
+ // A socket left behind by a client that quit without cleaning up:
+ // nobody answers on it any more, so it can go.
+ if path.exists() && std::os::unix::net::UnixStream::connect(&path).is_err() {
+ let _ = std::fs::remove_file(&path);
+ }
+ if let Ok(listener) = UnixListener::bind(&path) {
+ chosen = Some((path, listener));
+ break;
+ }
+ }
+ let Some((path, listener)) = chosen else {
+ log::warn!("rpc: every discord-ipc socket is in use; Rich Presence is off");
+ return;
+ };
+ log::info!("rpc: serving Rich Presence on {}", path.display());
+ let mut next = 1u64;
+ loop {
+ match listener.accept().await {
+ Ok((conn, _)) => {
+ let id = next;
+ next += 1;
+ let (user, on_event) = (user.clone(), on_event.clone());
+ tokio::spawn(async move { handle(conn, id, user, on_event).await });
+ }
+ Err(e) => {
+ log::warn!("rpc: accept failed: {e}");
+ tokio::time::sleep(std::time::Duration::from_secs(1)).await;
+ }
+ }
+ }
}
async fn read_frame<S: tokio::io::AsyncRead + Unpin>(s: &mut S) -> std::io::Result<(u32, Value)> {
diff --git a/apps/rustcord/src/style.rs b/apps/rustcord/src/style.rs
index 2c25f1d..e97364f 100644
--- a/apps/rustcord/src/style.rs
+++ b/apps/rustcord/src/style.rs
@@ -806,6 +806,17 @@ pub fn install_fonts(ctx: &egui::Context) {
("yu-gothic", "C:\\Windows\\Fonts\\YuGothR.ttc", false),
("malgun", "C:\\Windows\\Fonts\\malgun.ttf", false),
]
+ } else if cfg!(target_os = "linux") {
+ // Symbols and other scripts, where each distribution keeps them
+ // (Debian/Ubuntu, Arch, Fedora); the ones not installed are skipped.
+ &[
+ ("dejavu-sans", "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", false),
+ ("dejavu-sans-arch", "/usr/share/fonts/TTF/DejaVuSans.ttf", false),
+ ("dejavu-sans-fedora", "/usr/share/fonts/dejavu-sans-fonts/DejaVuSans.ttf", false),
+ ("noto-cjk", "/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc", false),
+ ("noto-cjk-arch", "/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc", false),
+ ("noto-cjk-fedora", "/usr/share/fonts/google-noto-sans-cjk-fonts/NotoSansCJK-Regular.ttc", false),
+ ]
} else {
&[]
};
diff --git a/apps/rustcord/src/ui/settings.rs b/apps/rustcord/src/ui/settings.rs
index 2f9e5a9..58863ca 100644
--- a/apps/rustcord/src/ui/settings.rs
+++ b/apps/rustcord/src/ui/settings.rs
@@ -3349,7 +3349,12 @@ impl RustCord {
}
if button_row(ui, t, "Log files", "This run's log, and the one before it.", "Open Folder", false) {
if let Some(dir) = crate::diagnostics::log_path().and_then(|p| p.parent()) {
+ #[cfg(windows)]
let _ = std::process::Command::new("explorer").arg(dir).spawn();
+ #[cfg(target_os = "linux")]
+ crate::linux::open_folder(dir);
+ #[cfg(target_os = "macos")]
+ let _ = std::process::Command::new("open").arg(dir).spawn();
}
}
let confirm_id = egui::Id::new("settings_voice_reset");
diff --git a/packaging/linux/install.sh b/packaging/linux/install.sh
new file mode 100755
index 0000000..53e043a
--- /dev/null
+++ b/packaging/linux/install.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+# Installs RustCord for you only (no root needed): the program in ~/.local/bin,
+# plus its entry and icon in the app menu. Run it again to update.
+# `./install.sh --uninstall` removes it again.
+set -eu
+
+here=$(cd "$(dirname "$0")" && pwd)
+bin="${XDG_BIN_HOME:-$HOME/.local/bin}"
+data="${XDG_DATA_HOME:-$HOME/.local/share}"
+icon="$data/icons/hicolor/256x256/apps/rustcord.png"
+entry="$data/applications/rustcord.desktop"
+
+if [ "${1:-}" = "--uninstall" ]; then
+ rm -f "$bin/rustcord" "$entry" "$icon"
+ echo "RustCord is uninstalled. Your settings and login stay in ~/.config/rustcord,"
+ echo "~/.cache/rustcord and your keyring until you delete them."
+ exit 0
+fi
+
+mkdir -p "$bin" "$(dirname "$icon")" "$(dirname "$entry")"
+install -m 755 "$here/rustcord" "$bin/rustcord"
+install -m 644 "$here/rustcord.png" "$icon"
+sed "s|^Exec=.*|Exec=\"$bin/rustcord\"|" "$here/rustcord.desktop" > "$entry"
+chmod 644 "$entry"
+command -v update-desktop-database >/dev/null 2>&1 && update-desktop-database -q "$(dirname "$entry")" || true
+
+echo "RustCord is installed: find it in your app menu, or run $bin/rustcord"
diff --git a/packaging/linux/package.sh b/packaging/linux/package.sh
new file mode 100755
index 0000000..08d7eab
--- /dev/null
+++ b/packaging/linux/package.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+# Packs a release build into dist/RustCord-<version>-linux-x86_64.tar.gz with
+# its .sha256. Run from the repository root after
+# `cargo build --release -p rustcord`.
+set -eu
+
+version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n 1)
+name="RustCord-$version-linux-x86_64"
+stage="dist/$name"
+
+rm -rf "$stage"
+mkdir -p "$stage"
+install -m 755 target/release/rustcord "$stage/rustcord"
+install -m 644 apps/rustcord/assets/icon-256.png "$stage/rustcord.png"
+install -m 644 packaging/linux/rustcord.desktop "$stage/rustcord.desktop"
+install -m 755 packaging/linux/install.sh "$stage/install.sh"
+install -m 644 LICENSE "$stage/LICENSE"
+install -m 644 THIRD_PARTY_NOTICES.md "$stage/THIRD_PARTY_NOTICES.md"
+
+tar -C dist -czf "dist/$name.tar.gz" "$name"
+(cd dist && sha256sum "$name.tar.gz" > "$name.tar.gz.sha256")
+rm -rf "$stage"
+echo "dist/$name.tar.gz"
diff --git a/packaging/linux/rustcord.desktop b/packaging/linux/rustcord.desktop
new file mode 100644
index 0000000..6e6b2c6
--- /dev/null
+++ b/packaging/linux/rustcord.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Type=Application
+Name=RustCord
+GenericName=Discord Client
+Comment=A lightweight, native Discord client
+Exec=rustcord
+Icon=rustcord
+Terminal=false
+Categories=Network;InstantMessaging;Chat;
+StartupWMClass=rustcord