Skip to content
Merged
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
26 changes: 26 additions & 0 deletions Config/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,32 @@ private static void SetValues(Dictionary<string, object> properties)
}


public static void SaveCurrentConfig(string filePath)
{
try
{
// Get current values from ConfigValues properties
var properties = typeof(ConfigValues)
.GetProperties()
.Where(prop => Attribute.IsDefined(prop, typeof(DefaultValueAttribute)))
.ToDictionary(
prop => prop.Name,
prop => prop.GetValue(null) // Get current value, not default
);

// Serialize the current properties to JSON
string json = JsonConvert.SerializeObject(properties, Formatting.Indented);

// Write to file
File.WriteAllText(filePath, json);
}
catch (Exception ex)
{
Console.WriteLine($"Error saving current configuration: {ex.Message}", Color.Red);
Utils.LogException(ex, "SaveCurrentConfig");
}
}

public static void SaveConfig(string filePath)
{
try
Expand Down
116 changes: 87 additions & 29 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public static class Program
// System tray icon
private static NotifyIcon _trayIcon;

// Mutex for single-instance checking
private static Mutex _mutex;

// Initialize a placeholder, because we don't want null reference exceptions
private static RichPresence _RPC = new RichPresence()
{
Expand Down Expand Up @@ -95,6 +98,20 @@ static void InitializeTrayIcon()
// Create context menu
var contextMenu = new ContextMenuStrip();

// Secret mode toggle
var secretModeItem = new ToolStripMenuItem("Secret Mode (Hide Project Name)");
secretModeItem.Checked = SecretMode;
secretModeItem.Click += (s, e) =>
{
SecretMode = !SecretMode;
secretModeItem.Checked = SecretMode;
// Save the current setting to config
SaveCurrentConfig(ConfigPath);
};
contextMenu.Items.Add(secretModeItem);

contextMenu.Items.Add(new ToolStripSeparator());

// Auto-startup toggle
var autoStartItem = new ToolStripMenuItem("Start with Windows");
autoStartItem.Checked = IsAutoStartEnabled();
Expand Down Expand Up @@ -172,42 +189,63 @@ static void RunRPCLoop()
// Save default config with default values (also load it at startup, the function is already called in SaveConfig)
SaveConfig(ConfigPath);

// Initialize the Rich Presence
InitializeRPC();
bool wasRunning = false;

// Initialize a timestamp if it's enabled in the config
if (ShowTimestamp)
{
_RPC.Timestamps = new Timestamps()
{
Start = DateTime.UtcNow
};
}

// If client is valid, continue the loop
while (_Client != null)
// Continuous monitoring loop
while (true)
{
try
{
// Retrieve the FL Studio data constantly, so that we're up to date
// Retrieve the FL Studio data constantly
FLInfo FLStudioData = GetFLInfo();

// Invoke event handlers
_Client.Invoke();

// Check if AppName and ProjectName are both empty or null
bool NoProject = string.IsNullOrEmpty(FLStudioData.AppName) && string.IsNullOrEmpty(FLStudioData.ProjectName);

// Set details and state based on conditions
_RPC.Details = NoProject ? "FL Studio (inactive)" : FLStudioData.AppName;
_RPC.State = NoProject ? "No project" : FLStudioData.ProjectName ?? "Empty project";
// Check if FL Studio is running
bool isRunning = !string.IsNullOrEmpty(FLStudioData.AppName) || !string.IsNullOrEmpty(FLStudioData.ProjectName);

// Check if secret mode is enabled and set the state accordingly
if (SecretMode)
_RPC.State = "Working on a hidden project";

// Finally, set the presence
_Client?.SetPresence(_RPC);
if (isRunning)
{
// FL Studio is running
if (!wasRunning)
{
// FL Studio just started - initialize RPC
InitializeRPC();

// Initialize timestamp if enabled
if (ShowTimestamp)
{
_RPC.Timestamps = new Timestamps()
{
Start = DateTime.UtcNow
};
}

wasRunning = true;
}

// Update presence with current FL Studio info
_RPC.Details = FLStudioData.AppName;
_RPC.State = FLStudioData.ProjectName ?? "Empty project";

// Check if secret mode is enabled
if (SecretMode)
_RPC.State = "Working on a hidden project";

// Invoke event handlers and set presence
_Client?.Invoke();
_Client?.SetPresence(_RPC);
}
else
{
// FL Studio is not running
if (wasRunning)
{
// FL Studio just closed - clear presence and dispose client
_Client?.ClearPresence();
_Client?.Dispose();
_Client = null;
wasRunning = false;
}
}

// Sleep for the interval defined in the config file
Thread.Sleep(UpdateInterval);
Expand All @@ -223,6 +261,22 @@ static void RunRPCLoop()
[STAThread]
static void Main(string[] args)
{
// Check if another instance is already running
bool createdNew;
_mutex = new Mutex(true, "FLStudioRPC_SingleInstance", out createdNew);

if (!createdNew)
{
// Another instance is already running
MessageBox.Show(
"FL Studio Discord RPC is already running.\n\nCheck your system tray for the icon.",
"Already Running",
MessageBoxButtons.OK,
MessageBoxIcon.Information
);
return; // Exit this instance
}

// Enable auto-start by default if not already configured
if (!IsAutoStartEnabled())
{
Expand All @@ -241,5 +295,9 @@ static void Main(string[] args)

// Keep the application running (for the tray icon)
Application.Run();

// Release the mutex when application exits
_mutex?.ReleaseMutex();
_mutex?.Dispose();
}
}
129 changes: 81 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,108 @@
# FL Studio Discord RPC
<h1 align="center">
<br>
<a href="https://github.com/zfi2/FL-Studio-Discord-RPC"><img src="https://raw.githubusercontent.com/zfi2/FL-Studio-Discord-RPC/refs/heads/main/FLStudioRPC.ico" alt="FL Studio Discord RPC" width="200"></a>
<br>
FL Studio Discord RPC
<br>
</h1>

<h4 align="center">A simple, yet cool way to show off your FL Studio projects to your friends and others.</h4>

<p align="center">
<a href="#key-features">Key Features</a> •
<a href="#how-to-use">How To Use</a> •
<a href="#download">Download</a> •
<a href="#building-from-source">Building From Source</a> •
<a href="#packages-used">Packages Used</a> •
<a href="#license">License</a> •
<a href="#feedback">Feedback</a>
</p>

<p align="center"><img src="https://i.imgur.com/viJFFoI.png"></p>

## Key Features

* **System Tray Integration** - Runs invisibly in the background
* **Auto-Startup** - Optionally launches with Windows (configurable via tray menu)
* **Secret Mode** - Hide your project names from others
* **Conditional RPC** - Only shows Discord activity when FL Studio is actually running
* **Single Instance** - Prevents multiple copies from running simultaneously
* **Accurate Version Display** - Show exact FL Studio version (e.g., FL Studio 20.8.4.1873)
* **JSON Configuration** - Easy-to-manage settings
* **Lightweight & Efficient** - Minimal resource usage

## How To Use

### Installation

A simple, yet cool way to show off your FL Studio projects to your friends and others.


## Features

- Runs invisibly in the background with a system tray icon
- Optionally launches with Windows (configurable via tray menu)
- Secret mode (meaning others can't see what project you're working on)
- Display optional accurate FL Studio version (ex. FL Studio 20.8.4.1873)
- A JSON-based easy-to-manage configuration system

## Pros
- Very lightweight and resource efficient
- Uses only 3 external packages
- Almost everything is commented, so the code is easily manageable and readable

## Cons
- No integration into actual FL Studio (meaning it must run in the background while FL Studio is running)

## Screenshots

![RPC Screenshot 2](https://i.imgur.com/viJFFoI.png)

## Installation

### Using the Installer (Recommended)
1. Download `FLStudioRPC_Setup.exe` from the [Releases](https://github.com/zfi2/FL-Studio-Discord-RPC/releases) page
2. Run the installer
3. Choose installation location (optional)
4. Select options:
3. Choose your installation location (optional)
4. Select your preferences:
- Open FL Studio Discord RPC on startup (recommended)
- Create a desktop icon (optional)
5. Click Install

The app will run in your system tray. Right-click the tray icon to access settings or exit.

### Manual Installation
You can also simply run the pre-compiled release, or build it yourself! This project uses .NET Framework 4.8.1
## Feedback
The app will automatically start and run in your system tray.

If you have any feedback, reach out to me on discord - my username is on my website, which is on my github profile


## Usage
### Usage

Once installed, FL Studio Discord RPC runs automatically in the background:

1. **System Tray Icon** - Look for the FL Studio Discord RPC icon in your system tray (bottom-right, near the clock)
1. **System Tray Icon** - Look for the icon in your system tray (bottom-right, near the clock)
2. **Right-click the icon** to access:
- Open FL Studio Discord RPC on startup - Toggle auto-start
- Secret Mode (Hide Project Name) - Toggle project name visibility
- Start with Windows - Toggle auto-startup
- About - Opens the GitHub repository
- Exit - Closes the application

The app will automatically detect when FL Studio is running and update your Discord status.
The app will automatically detect when FL Studio is running and update your Discord status accordingly.

> **Note**
> When FL Studio is closed, your Discord activity will be cleared automatically.

## Download

You can [download](https://github.com/zfi2/FL-Studio-Discord-RPC/releases) the latest installer for Windows.

## Features that may (or may not) be added in the future
**System Requirements:**
- Windows 10/11
- .NET Framework 4.8.1 (usually pre-installed)
- Discord running on your PC

- Actual FL Studio integration
- More features
## Building From Source

This project uses .NET Framework 4.8.1 and can be built with Visual Studio 2022 or MSBuild.

**Prerequisites:**
- Visual Studio 2022 (Community Edition or higher) OR Visual Studio Build Tools
- .NET Framework 4.8.1 SDK

## Packages used
**Steps:**
1. Clone the repository
2. Open `FLStudioRPC.sln` in Visual Studio
3. Build the solution (Ctrl+Shift+B)
4. The executable will be in `bin\Release\FLStudioRPC.exe`

[DiscordRichPresence](https://github.com/Lachee/discord-rpc-csharp)\
[Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json)\
[Colorful.Console](https://github.com/tomakita/Colorful.Console)
**Creating the Installer:**
1. Install [Inno Setup](https://jrsoftware.org/isdl.php)
2. Right-click `installer.iss` and select "Compile"
3. The installer will be created in `installer_output\FLStudioRPC_Setup.exe`

## Feedback

If you have any feedback, reach out to me on discord (which is available on [my website](https://lain.ovh/))

## Packages Used

[DiscordRichPresence](https://github.com/Lachee/discord-rpc-csharp) - Discord Rich Presence library
[Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) - JSON serialization
[Colorful.Console](https://github.com/tomakita/Colorful.Console) - Console output formatting

## License

This project is licensed under the [MIT](https://opensource.org/license/mit/) License - see the [LICENSE](LICENSE) file for details.

---

> GitHub [@zfi2](https://github.com/zfi2)
Binary file modified installer_output/FLStudioRPC_Setup.exe
Binary file not shown.