Skip to content

Commit

Permalink
Ableton regex to trim [ProjectName] from title
Browse files Browse the repository at this point in the history
  • Loading branch information
Myuuiii committed Dec 27, 2022
1 parent 18872b4 commit 1e9e2d0
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 19 deletions.
8 changes: 6 additions & 2 deletions DAWPresence/DAWs/AbletonLive10Intro.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.Diagnostics;
using System.Text.RegularExpressions;

namespace DAWPresence.DAWs;

public class AbletonLive10Intro : Daw
public partial class AbletonLive10Intro : Daw
{
public AbletonLive10Intro()
{
Expand All @@ -20,7 +21,10 @@ public override string GetProjectNameFromProcessWindow()
if (process is null) return "";
string title = process.MainWindowTitle;
return title.Contains(WindowTrim)
? title[..^TitleOffset]
? TitleRegex().Match(title[..^TitleOffset]).Value
: "";
}

[GeneratedRegex("[^\\[]*")]
private static partial Regex TitleRegex();
}
8 changes: 6 additions & 2 deletions DAWPresence/DAWs/AbletonLive10Standard.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.Diagnostics;
using System.Text.RegularExpressions;

namespace DAWPresence.DAWs;

public class AbletonLive10Standard : Daw
public partial class AbletonLive10Standard : Daw
{
public AbletonLive10Standard()
{
Expand All @@ -20,7 +21,10 @@ public override string GetProjectNameFromProcessWindow()
if (process is null) return "";
string title = process.MainWindowTitle;
return title.Contains(WindowTrim)
? title[..^TitleOffset]
? TitleRegex().Match(title[..^TitleOffset]).Value
: "";
}

[GeneratedRegex("[^\\[]*")]
private static partial Regex TitleRegex();
}
8 changes: 6 additions & 2 deletions DAWPresence/DAWs/AbletonLive10Suite.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.Diagnostics;
using System.Text.RegularExpressions;

namespace DAWPresence.DAWs;

public class AbletonLive10Suite : Daw
public partial class AbletonLive10Suite : Daw
{
public AbletonLive10Suite()
{
Expand All @@ -20,7 +21,10 @@ public override string GetProjectNameFromProcessWindow()
if (process is null) return "";
string title = process.MainWindowTitle;
return title.Contains(WindowTrim)
? title[..^TitleOffset]
? TitleRegex().Match(title[..^TitleOffset]).Value
: "";
}

[GeneratedRegex("[^\\[]*")]
private static partial Regex TitleRegex();
}
8 changes: 6 additions & 2 deletions DAWPresence/DAWs/AbletonLive11Intro.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.Diagnostics;
using System.Text.RegularExpressions;

namespace DAWPresence.DAWs;

public class AbletonLive11Intro : Daw
public partial class AbletonLive11Intro : Daw
{
public AbletonLive11Intro()
{
Expand All @@ -20,7 +21,10 @@ public override string GetProjectNameFromProcessWindow()
if (process is null) return "";
string title = process.MainWindowTitle;
return title.Contains(WindowTrim)
? title[..^TitleOffset]
? TitleRegex().Match(title[..^TitleOffset]).Value
: "";
}

[GeneratedRegex("[^\\[]*")]
private static partial Regex TitleRegex();
}
8 changes: 6 additions & 2 deletions DAWPresence/DAWs/AbletonLive11Standard.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.Diagnostics;
using System.Text.RegularExpressions;

namespace DAWPresence.DAWs;

public class AbletonLive11Standard : Daw
public partial class AbletonLive11Standard : Daw
{
public AbletonLive11Standard()
{
Expand All @@ -20,7 +21,10 @@ public override string GetProjectNameFromProcessWindow()
if (process is null) return "";
string title = process.MainWindowTitle;
return title.Contains(WindowTrim)
? title[..^TitleOffset]
? TitleRegex().Match(title[..^TitleOffset]).Value
: "";
}

[GeneratedRegex("[^\\[]*")]
private static partial Regex TitleRegex();
}
10 changes: 7 additions & 3 deletions DAWPresence/DAWs/AbletonLive11Suite.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using System.Diagnostics;
using System.Text.RegularExpressions;

namespace DAWPresence.DAWs;

public class AbletonLive11Suite : Daw
public partial class AbletonLive11Suite : Daw
{
public AbletonLive11Suite()
{
ProcessName = "Ableton Live 11 Suite";
DisplayName = ProcessName;
ImageKey = "ableton-white";
ImageKey = "ableton";
ApplicationId = "1053952444859686983";
WindowTrim = " - " + DisplayName;
TitleOffset = 24;
Expand All @@ -20,7 +21,10 @@ public override string GetProjectNameFromProcessWindow()
if (process is null) return "";
string title = process.MainWindowTitle;
return title.Contains(WindowTrim)
? title[..^TitleOffset]
? TitleRegex().Match(title[..^TitleOffset]).Value
: "";
}

[GeneratedRegex("[^\\[]*")]
private static partial Regex TitleRegex();
}
8 changes: 6 additions & 2 deletions DAWPresence/DAWs/AbletonLive9Intro.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.Diagnostics;
using System.Text.RegularExpressions;

namespace DAWPresence.DAWs;

public class AbletonLive9Intro : Daw
public partial class AbletonLive9Intro : Daw
{
public AbletonLive9Intro()
{
Expand All @@ -20,7 +21,10 @@ public override string GetProjectNameFromProcessWindow()
if (process is null) return "";
string title = process.MainWindowTitle;
return title.Contains(WindowTrim)
? title[..^TitleOffset]
? TitleRegex().Match(title[..^TitleOffset]).Value
: "";
}

[GeneratedRegex("[^\\[]*")]
private static partial Regex TitleRegex();
}
8 changes: 6 additions & 2 deletions DAWPresence/DAWs/AbletonLive9Standard.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.Diagnostics;
using System.Text.RegularExpressions;

namespace DAWPresence.DAWs;

public class AbletonLive9Standard : Daw
public partial class AbletonLive9Standard : Daw
{
public AbletonLive9Standard()
{
Expand All @@ -20,7 +21,10 @@ public override string GetProjectNameFromProcessWindow()
if (process is null) return "";
string title = process.MainWindowTitle;
return title.Contains(WindowTrim)
? title[..^TitleOffset]
? TitleRegex().Match(title[..^TitleOffset]).Value
: "";
}

[GeneratedRegex("[^\\[]*")]
private static partial Regex TitleRegex();
}
8 changes: 6 additions & 2 deletions DAWPresence/DAWs/AbletonLive9Suite.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.Diagnostics;
using System.Text.RegularExpressions;

namespace DAWPresence.DAWs;

public class AbletonLive9Suite : Daw
public partial class AbletonLive9Suite : Daw
{
public AbletonLive9Suite()
{
Expand All @@ -20,7 +21,10 @@ public override string GetProjectNameFromProcessWindow()
if (process is null) return "";
string title = process.MainWindowTitle;
return title.Contains(WindowTrim)
? title[..^TitleOffset]
? TitleRegex().Match(title[..^TitleOffset]).Value
: "";
}

[GeneratedRegex("[^\\[]*")]
private static partial Regex TitleRegex();
}

0 comments on commit 1e9e2d0

Please sign in to comment.