Skip to content

Commit

Permalink
#1: Support forced grouping.
Browse files Browse the repository at this point in the history
Add support for multiple match rules.
Backwards compat maintained (if no Rule then Name is used like before).
  • Loading branch information
halsafar committed May 7, 2021
1 parent cba9aab commit 45cce0b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions TaskBarAppIdAdjuster/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class TaskSetting
[DataMember]
public String Name;

[DataMember]
public List<String> Rules;

[DataMember]
public TaskAction Action = default(TaskAction);
}
Expand Down Expand Up @@ -68,6 +71,7 @@ public static Settings Load()
// Assume first run, create a default config file to serve as an example
TaskSetting notePadDefault = new TaskSetting();
notePadDefault.Name = "notepad";
notePadDefault.Rules = new List<string>() { "notepad" };
notePadDefault.Action = TaskAction.Ungroup;

retVal = new Settings();
Expand Down
21 changes: 20 additions & 1 deletion TaskBarAppIdAdjuster/TaskBarService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,26 @@ private void HandleProcesses()
{
Console.WriteLine("Searching for any process matching the name: {0}", taskSetting.Name);

Process[] processes = Process.GetProcessesByName(taskSetting.Name);
List<Process> processes = new List<Process>();

// support older configs where Name == Rules[0]
if (taskSetting.Rules == null && !String.IsNullOrEmpty(taskSetting.Name))
{
processes.AddRange(Process.GetProcessesByName(taskSetting.Name));
}
else if (taskSetting.Rules.Count > 0)
{
foreach (string rule in taskSetting.Rules)
{
processes.AddRange(Process.GetProcessesByName(rule));
}
}
else
{
// invalid rule, don't log spam
return;
}

foreach (Process process in processes)
{
// Assume if main process has no window then the rest do not?
Expand Down

0 comments on commit 45cce0b

Please sign in to comment.