Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dev/linux/flatpak/net.nullsum.JelliumDesktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ finish-args:
- --device=dri
- --talk-name=org.freedesktop.ScreenSaver
- --own-name=org.mpris.MediaPlayer2.JelliumDesktop
- --filesystem=xdg-run/discord-ipc-0
- --filesystem=xdg-run/app/com.discordapp.Discord:ro
# The base org.freedesktop.Platform//25.08 libavcodec ships WITHOUT the
# patent-encumbered h264/hevc decoders (freedesktop moved them out of the base
# runtime in 25.08 — 24.08 still had h264). Those decoders live only in the
Expand Down
Binary file added resources/discord/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/discord/pause.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"color",
"compositor_core",
"config",
"discord",
"gpu_paint",
"input",
"jellyfin",
Expand Down
69 changes: 68 additions & 1 deletion src/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ struct SettingsData {
force_transcoding: bool,
window_decorations: Option<WindowDecorations>,
hide_scrollbar: bool,
discord_rich_presence: bool,
discord_application_id: String,
}

impl Default for SettingsData {
Expand All @@ -77,6 +79,8 @@ impl Default for SettingsData {
force_transcoding: false,
window_decorations: None,
hide_scrollbar: true,
discord_rich_presence: false,
discord_application_id: String::new(),
}
}
}
Expand Down Expand Up @@ -154,6 +158,12 @@ impl SettingsData {
if let Some(b) = v.get("hideScrollbar").and_then(Value::as_bool) {
self.hide_scrollbar = b;
}
if let Some(b) = v.get("discordRichPresence").and_then(Value::as_bool) {
self.discord_rich_presence = b;
}
if let Some(s) = v.get("discordApplicationId").and_then(Value::as_str) {
self.discord_application_id = s.into();
}
}

fn to_json(&self) -> Value {
Expand Down Expand Up @@ -223,6 +233,15 @@ impl SettingsData {
if !self.device_name.is_empty() {
o.insert("deviceName".into(), Value::String(self.device_name.clone()));
}
if self.discord_rich_presence {
o.insert("discordRichPresence".into(), Value::Bool(true));
}
if !self.discord_application_id.is_empty() {
o.insert(
"discordApplicationId".into(),
Value::String(self.discord_application_id.clone()),
);
}
Value::Object(o)
}

Expand Down Expand Up @@ -265,6 +284,14 @@ impl SettingsData {
if !self.device_name.is_empty() {
o.insert("deviceName".into(), Value::String(self.device_name.clone()));
}
o.insert(
"discordRichPresence".into(),
Value::Bool(self.discord_rich_presence),
);
o.insert(
"discordApplicationId".into(),
Value::String(self.discord_application_id.clone()),
);
o.insert(
"deviceNameDefault".into(),
Value::String(default_device_name()),
Expand Down Expand Up @@ -517,6 +544,18 @@ bool_accessors!(
transparent_titlebar
);
bool_accessors!(force_transcoding, set_force_transcoding, force_transcoding);
bool_accessors!(
discord_rich_presence,
set_discord_rich_presence,
discord_rich_presence
);
pub fn discord_application_id() -> String {
state().lock().data.discord_application_id.clone()
}

pub fn set_discord_application_id(v: &str) {
state().lock().data.discord_application_id = v.trim().to_string();
}
/// The user's explicit decoration choice, unresolved; `None` when unset.
pub fn configured_window_decorations() -> Option<WindowDecorations> {
state().lock().data.window_decorations
Expand Down Expand Up @@ -590,10 +629,38 @@ fn normalize_device_name(raw: &str, platform_default: &str) -> String {

#[cfg(test)]
mod tests {
use super::normalize_device_name;
use super::{SettingsData, Value, normalize_device_name};

const PLATFORM: &str = "platform-host";

#[test]
fn discord_settings_survive_a_load_save_cycle() {
let mut d = SettingsData::default();
d.overlay_json(&serde_json::json!({
"discordRichPresence": true,
"discordApplicationId": "1533503787145363616",
}));
assert!(d.discord_rich_presence);
assert_eq!(d.discord_application_id, "1533503787145363616");

let out = d.to_json();
assert_eq!(
out.get("discordRichPresence").and_then(Value::as_bool),
Some(true)
);
assert_eq!(
out.get("discordApplicationId").and_then(Value::as_str),
Some("1533503787145363616")
);
}

#[test]
fn saving_drops_keys_the_running_binary_does_not_know() {
let mut d = SettingsData::default();
d.overlay_json(&serde_json::json!({ "someFutureKey": "value" }));
assert!(d.to_json().get("someFutureKey").is_none());
}

#[test]
fn trims_leading_and_trailing_whitespace() {
assert_eq!(normalize_device_name(" foo ", PLATFORM), "foo");
Expand Down
21 changes: 21 additions & 0 deletions src/discord/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "jfn-discord"
version.workspace = true
edition.workspace = true
publish.workspace = true

[lib]
name = "jfn_discord"
crate-type = ["rlib"]

# Deliberately not target-gated: Discord's local RPC transport exists on all
# three platforms, so unlike jfn-mpris this crate is real code everywhere.
[dependencies]
jfn-config = { path = "../config" }
jfn-playback = { path = "../playback" }
parking_lot.workspace = true
serde_json.workspace = true
tracing.workspace = true

[lints]
workspace = true
Loading