-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from Myuuiii/trayicon-live12
Tray Icon Application & Live 12 Support BETA
- Loading branch information
Showing
31 changed files
with
871 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="Publish" type="DotNetFolderPublish" factoryName="Publish to folder"> | ||
<riderPublish configuration="Release" platform="Any CPU" produce_single_file="true" runtime="win-x64" target_folder="G:/BUILD" target_framework="net8.0-windows" uuid_high="-6518831478130717984" uuid_low="-7892830845003068016" /> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
using DAWPresence; | ||
|
||
IHost host = Host.CreateDefaultBuilder(args) | ||
.UseWindowsService(options => { options.ServiceName = "DAW Rich Presence"; }) | ||
.ConfigureServices(services => { services.AddHostedService<Worker>(); }) | ||
.Build(); | ||
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args); | ||
|
||
// Require admin rights | ||
// if (!new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator)) | ||
// { | ||
// Console.WriteLine("Please run this program as an administrator"); | ||
// Console.ReadKey(); | ||
// return; | ||
// } | ||
|
||
builder.Services.AddHostedService<Worker>(); | ||
|
||
IHost host = builder.Build(); | ||
host.Run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@echo off | ||
REM Change to the directory of the script | ||
pushd "%~dp0" | ||
|
||
REM get the full path of the DAWPresence.exe | ||
for /f "tokens=*" %%a in ('dir /s /b DAWPresence.exe') do set DAWPresencePath=%%a | ||
|
||
REM create a scheduled task to run DAWPresence.exe with highest privileges in the background | ||
schtasks /create /tn "DAWPresence" /tr "\"%DAWPresencePath%\"" /sc onstart /rl highest /f | ||
|
||
echo DAWPresence scheduled task created | ||
pause | ||
|
||
REM Revert to the previous directory | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@echo off | ||
|
||
REM delete the scheduled task named "DAWPresence" | ||
schtasks /delete /tn "DAWPresence" /f | ||
|
||
echo DAWPresence scheduled task deleted | ||
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
namespace DAWPresence; | ||
|
||
public class AppConfiguration | ||
{ | ||
/// <summary> | ||
/// Interval at which the app will check if the DAW is (still) running and update the presence accordingly. | ||
/// </summary> | ||
public TimeSpan UpdateInterval { get; set; } = new(0, 0, 3); | ||
|
||
/// <summary> | ||
/// Time offset to add to the current time when displaying the elapsed time. | ||
/// </summary> | ||
public TimeSpan Offset { get; set; } = new(0, 0, 0); | ||
|
||
/// <summary> | ||
/// Text to show when no project is open | ||
/// </summary> | ||
public string IdleText { get; set; } = "Not working on a project"; | ||
|
||
/// <summary> | ||
/// Text to show before the project name when a project is open | ||
/// </summary> | ||
public string WorkingPrefixText { get; set; } = "Working on "; | ||
|
||
/// <summary> | ||
/// Overwrite the image key (for custom images) | ||
/// </summary> | ||
public bool UseCustomImage { get; set; } = false; | ||
|
||
/// <summary> | ||
/// Custom image key to use | ||
/// </summary> | ||
public string CustomImageKey { get; set; } = "custom"; | ||
|
||
/// <summary> | ||
/// Enable hot reloading of the configuration file | ||
/// </summary> | ||
public bool Debug { get; set; } = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System.Diagnostics; | ||
|
||
namespace DAWPresence; | ||
|
||
public abstract class Daw | ||
{ | ||
/// <summary> | ||
/// Pretty name that will be shown in the presence | ||
/// </summary> | ||
public string DisplayName { get; protected init; } | ||
|
||
/// <summary> | ||
/// Name of the DAWs process as seen in Task Manager on Windows | ||
/// </summary> | ||
public string ProcessName { get; protected init; } | ||
|
||
/// <summary> | ||
/// The text that needs to be trimmed from the Window title in order to get the project name (if it works that way for | ||
/// the DAW) | ||
/// </summary> | ||
public string WindowTrim { get; protected init; } | ||
|
||
/// <summary> | ||
/// The amount of characters that should be trimmed to get the project name | ||
/// </summary> | ||
public int TitleOffset { get; protected init; } | ||
|
||
/// <summary> | ||
/// Discord Rich Presence Image Key | ||
/// </summary> | ||
public string ImageKey { get; protected init; } | ||
|
||
/// <summary> | ||
/// Discord Rich Presence Application Id | ||
/// </summary> | ||
public string ApplicationId { get; protected init; } | ||
|
||
/// <summary> | ||
/// Return the amount of processes with the name of the DAW | ||
/// </summary> | ||
public int ProcessCount => Process.GetProcessesByName(ProcessName).Length; | ||
|
||
/// <summary> | ||
/// Returns whether there is a running instance of the DAW or not | ||
/// </summary> | ||
public bool IsRunning => ProcessCount > 0; | ||
|
||
/// <summary> | ||
/// Retrieves the name of the currently open project or an empty string if no project is open | ||
/// </summary> | ||
/// <returns></returns> | ||
public abstract string GetProjectNameFromProcessWindow(); | ||
|
||
/// <summary> | ||
/// Get the first process with the name of the DAW | ||
/// </summary> | ||
/// <returns></returns> | ||
protected Process GetProcess() => Process.GetProcessesByName(ProcessName).First(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>net8.0-windows</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<UseWindowsForms>true</UseWindowsForms> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<RuntimeIdentifier>win-x64</RuntimeIdentifier> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<ApplicationIcon>appicon.ico</ApplicationIcon> | ||
<PublishSingleFile>true</PublishSingleFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Update="appicon.ico"> | ||
<CopyToOutputDirectory>Never</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="DiscordRichPresence" Version="1.1.3.18"/> | ||
<PackageReference Include="YamlDotNet" Version="15.1.4" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Diagnostics; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace DAWPresence.DAWs; | ||
|
||
public partial class AbletonLive10Intro : Daw | ||
{ | ||
public AbletonLive10Intro() | ||
{ | ||
ProcessName = "Ableton Live 10 Intro"; | ||
DisplayName = ProcessName; | ||
ImageKey = "ableton-white"; | ||
ApplicationId = "1053952444859686983"; | ||
WindowTrim = " - " + DisplayName; | ||
TitleOffset = 24; | ||
} | ||
|
||
public override string GetProjectNameFromProcessWindow() | ||
{ | ||
Process? process = GetProcess(); | ||
if (process is null) return ""; | ||
string title = process.MainWindowTitle; | ||
return title.Contains(WindowTrim) | ||
? TitleRegex().Match(title[..^TitleOffset]).Value | ||
: ""; | ||
} | ||
|
||
[GeneratedRegex("[^\\[]*")] | ||
private static partial Regex TitleRegex(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Diagnostics; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace DAWPresence.DAWs; | ||
|
||
public partial class AbletonLive10Standard : Daw | ||
{ | ||
public AbletonLive10Standard() | ||
{ | ||
ProcessName = "Ableton Live 10 Standard"; | ||
DisplayName = ProcessName; | ||
ImageKey = "ableton-white"; | ||
ApplicationId = "1053952444859686983"; | ||
WindowTrim = " - " + DisplayName; | ||
TitleOffset = 27; | ||
} | ||
|
||
public override string GetProjectNameFromProcessWindow() | ||
{ | ||
Process? process = GetProcess(); | ||
if (process is null) return ""; | ||
string title = process.MainWindowTitle; | ||
return title.Contains(WindowTrim) | ||
? TitleRegex().Match(title[..^TitleOffset]).Value | ||
: ""; | ||
} | ||
|
||
[GeneratedRegex("[^\\[]*")] | ||
private static partial Regex TitleRegex(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Diagnostics; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace DAWPresence.DAWs; | ||
|
||
public partial class AbletonLive10Suite : Daw | ||
{ | ||
public AbletonLive10Suite() | ||
{ | ||
ProcessName = "Ableton Live 10 Suite"; | ||
DisplayName = ProcessName; | ||
ImageKey = "ableton-white"; | ||
ApplicationId = "1053952444859686983"; | ||
WindowTrim = " - " + DisplayName; | ||
TitleOffset = 24; | ||
} | ||
|
||
public override string GetProjectNameFromProcessWindow() | ||
{ | ||
Process? process = GetProcess(); | ||
if (process is null) return ""; | ||
string title = process.MainWindowTitle; | ||
return title.Contains(WindowTrim) | ||
? TitleRegex().Match(title[..^TitleOffset]).Value | ||
: ""; | ||
} | ||
|
||
[GeneratedRegex("[^\\[]*")] | ||
private static partial Regex TitleRegex(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Diagnostics; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace DAWPresence.DAWs; | ||
|
||
public partial class AbletonLive11Intro : Daw | ||
{ | ||
public AbletonLive11Intro() | ||
{ | ||
ProcessName = "Ableton Live 11 Intro"; | ||
DisplayName = ProcessName; | ||
ImageKey = "ableton-white"; | ||
ApplicationId = "1053952444859686983"; | ||
WindowTrim = " - " + DisplayName; | ||
TitleOffset = 24; | ||
} | ||
|
||
public override string GetProjectNameFromProcessWindow() | ||
{ | ||
Process? process = GetProcess(); | ||
if (process is null) return ""; | ||
string title = process.MainWindowTitle; | ||
return title.Contains(WindowTrim) | ||
? TitleRegex().Match(title[..^TitleOffset]).Value | ||
: ""; | ||
} | ||
|
||
[GeneratedRegex("[^\\[]*")] | ||
private static partial Regex TitleRegex(); | ||
} |
Oops, something went wrong.