mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
Add option to show playing icon in Discord RPC (#1699)
* feat: add option to show playing/paused icon in Discord RPC
This commit is contained in:
@@ -788,6 +788,8 @@
|
|||||||
"discordRichPresence_description": "enable playback status in {{discord}} rich presence. Image keys are: {{icon}}, {{playing}}, and {{paused}}",
|
"discordRichPresence_description": "enable playback status in {{discord}} rich presence. Image keys are: {{icon}}, {{playing}}, and {{paused}}",
|
||||||
"discordServeImage": "serve {{discord}} images from server",
|
"discordServeImage": "serve {{discord}} images from server",
|
||||||
"discordServeImage_description": "share cover art for {{discord}} rich presence from server itself, only available for Jellyfin and Navidrome. {{discord}} uses a bot to fetch images, so your server must be reachable from the public internet",
|
"discordServeImage_description": "share cover art for {{discord}} rich presence from server itself, only available for Jellyfin and Navidrome. {{discord}} uses a bot to fetch images, so your server must be reachable from the public internet",
|
||||||
|
"discordStateIcon": "show playing icon",
|
||||||
|
"discordStateIcon_description": "show a small playing icon in the rich presence status. the paused icon is always shown when \"Show rich presence when paused\" is enabled",
|
||||||
"discordUpdateInterval": "{{discord}} rich presence update interval",
|
"discordUpdateInterval": "{{discord}} rich presence update interval",
|
||||||
"discordUpdateInterval_description": "the time in seconds between each update (minimum 15 seconds)",
|
"discordUpdateInterval_description": "the time in seconds between each update (minimum 15 seconds)",
|
||||||
"enableAutoTranslation_description": "enable translation automatically when lyrics are loaded",
|
"enableAutoTranslation_description": "enable translation automatically when lyrics are loaded",
|
||||||
|
|||||||
@@ -109,8 +109,18 @@ export const useDiscordRpc = () => {
|
|||||||
instance: false,
|
instance: false,
|
||||||
largeImageKey: 'icon',
|
largeImageKey: 'icon',
|
||||||
largeImageText: truncate(stationName || 'Radio'),
|
largeImageText: truncate(stationName || 'Radio'),
|
||||||
smallImageKey: current[2] === PlayerStatus.PLAYING ? 'playing' : 'paused',
|
smallImageKey:
|
||||||
smallImageText: sentenceCase(current[2]),
|
current[2] === PlayerStatus.PLAYING
|
||||||
|
? discordSettings.showStateIcon
|
||||||
|
? 'playing'
|
||||||
|
: undefined
|
||||||
|
: 'paused',
|
||||||
|
smallImageText:
|
||||||
|
current[2] === PlayerStatus.PLAYING
|
||||||
|
? discordSettings.showStateIcon
|
||||||
|
? sentenceCase(current[2])
|
||||||
|
: undefined
|
||||||
|
: sentenceCase(current[2]),
|
||||||
state: truncate(artist),
|
state: truncate(artist),
|
||||||
statusDisplayType: StatusDisplayType.STATE,
|
statusDisplayType: StatusDisplayType.STATE,
|
||||||
type: discordSettings.showAsListening ? 2 : 0,
|
type: discordSettings.showAsListening ? 2 : 0,
|
||||||
@@ -199,7 +209,7 @@ export const useDiscordRpc = () => {
|
|||||||
(song?.album && song.album.padEnd(2, ' ')) || 'Unknown album',
|
(song?.album && song.album.padEnd(2, ' ')) || 'Unknown album',
|
||||||
),
|
),
|
||||||
smallImageKey: undefined,
|
smallImageKey: undefined,
|
||||||
smallImageText: sentenceCase(current[2]),
|
smallImageText: undefined,
|
||||||
state: truncate((artists && artists.padEnd(2, ' ')) || 'Unknown artist'),
|
state: truncate((artists && artists.padEnd(2, ' ')) || 'Unknown artist'),
|
||||||
statusDisplayType: statusDisplayMap[discordSettings.displayType],
|
statusDisplayType: statusDisplayMap[discordSettings.displayType],
|
||||||
// I would love to use the actual type as opposed to hardcoding to 2,
|
// I would love to use the actual type as opposed to hardcoding to 2,
|
||||||
@@ -247,9 +257,13 @@ export const useDiscordRpc = () => {
|
|||||||
activity.endTimestamp = end;
|
activity.endTimestamp = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.smallImageKey = 'playing';
|
if (discordSettings.showStateIcon) {
|
||||||
|
activity.smallImageKey = 'playing';
|
||||||
|
activity.smallImageText = sentenceCase(current[2]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
activity.smallImageKey = 'paused';
|
activity.smallImageKey = 'paused';
|
||||||
|
activity.smallImageText = sentenceCase(current[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (discordSettings.showServerImage && song) {
|
if (discordSettings.showServerImage && song) {
|
||||||
@@ -349,6 +363,7 @@ export const useDiscordRpc = () => {
|
|||||||
[
|
[
|
||||||
discordSettings.showAsListening,
|
discordSettings.showAsListening,
|
||||||
discordSettings.showServerImage,
|
discordSettings.showServerImage,
|
||||||
|
discordSettings.showStateIcon,
|
||||||
discordSettings.showPaused,
|
discordSettings.showPaused,
|
||||||
lastfmApiKey,
|
lastfmApiKey,
|
||||||
discordSettings.clientId,
|
discordSettings.clientId,
|
||||||
|
|||||||
@@ -98,6 +98,28 @@ export const DiscordSettings = memo(() => {
|
|||||||
postProcess: 'sentenceCase',
|
postProcess: 'sentenceCase',
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
control: (
|
||||||
|
<Switch
|
||||||
|
checked={settings.showStateIcon}
|
||||||
|
onChange={(e) => {
|
||||||
|
setSettings({
|
||||||
|
discord: {
|
||||||
|
showStateIcon: e.currentTarget.checked,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
description: t('setting.discordStateIcon', {
|
||||||
|
context: 'description',
|
||||||
|
postProcess: 'sentenceCase',
|
||||||
|
}),
|
||||||
|
isHidden: !isElectron(),
|
||||||
|
title: t('setting.discordStateIcon', {
|
||||||
|
postProcess: 'sentenceCase',
|
||||||
|
}),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
control: (
|
control: (
|
||||||
<Switch
|
<Switch
|
||||||
|
|||||||
@@ -261,6 +261,7 @@ const DiscordSettingsSchema = z.object({
|
|||||||
showAsListening: z.boolean(),
|
showAsListening: z.boolean(),
|
||||||
showPaused: z.boolean(),
|
showPaused: z.boolean(),
|
||||||
showServerImage: z.boolean(),
|
showServerImage: z.boolean(),
|
||||||
|
showStateIcon: z.boolean(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const FontSettingsSchema = z.object({
|
const FontSettingsSchema = z.object({
|
||||||
@@ -986,6 +987,7 @@ const initialState: SettingsState = {
|
|||||||
showAsListening: false,
|
showAsListening: false,
|
||||||
showPaused: true,
|
showPaused: true,
|
||||||
showServerImage: false,
|
showServerImage: false,
|
||||||
|
showStateIcon: true,
|
||||||
},
|
},
|
||||||
font: {
|
font: {
|
||||||
builtIn: 'Inter',
|
builtIn: 'Inter',
|
||||||
|
|||||||
Reference in New Issue
Block a user