Compare commits

...

3 Commits

Author SHA1 Message Date
23ae43c155 Update manifest 2025-01-25 16:54:34 -07:00
d8b4bf340b github-15 - add ability to ignore processes 2025-01-25 16:51:28 -07:00
cd306b0aab github-16 - previous app was not functioning 2025-01-25 16:21:51 -07:00
6 changed files with 84 additions and 2 deletions

View File

@ -17,6 +17,7 @@ public class AudioHelper
int _retryFallbackCount = 0; int _retryFallbackCount = 0;
public List<Override> Overrides { get; set; } public List<Override> Overrides { get; set; }
public List<string> Ignored { get; set; }
public IAudioSession Current { get; private set; } public IAudioSession Current { get; private set; }
@ -146,7 +147,13 @@ public class AudioHelper
if (_currentProcesses == null || !_currentProcesses.SequenceEqual(processIds) || _retryFallbackCount == 5) if (_currentProcesses == null || !_currentProcesses.SequenceEqual(processIds) || _retryFallbackCount == 5)
{ {
_retryFallbackCount = 0; _retryFallbackCount = 0;
Current = FindSession(processes);
var newSession = FindSession(processes);
if(newSession != null || fallbackBehavior != FallbackBehavior.PreviousApp)
{
Current = newSession;
}
} }
else if(Current is SystemSoundsAudioSession || Current is SystemVolumeAudioSession) else if(Current is SystemSoundsAudioSession || Current is SystemVolumeAudioSession)
{ {
@ -217,6 +224,11 @@ public class AudioHelper
{ {
return new List<Process>(); return new List<Process>();
} }
if(processes.Any(x => Ignored.Contains(x.ProcessName)))
{
return new List<Process>();
}
try try
{ {

View File

@ -33,12 +33,16 @@ public class DialAction : EncoderBase
[JsonProperty("overrides")] [JsonProperty("overrides")]
public string Overrides { get; set; } public string Overrides { get; set; }
[JsonProperty("ignored")]
public string Ignored { get; set; }
public static PluginSettings CreateDefaultSettings() public static PluginSettings CreateDefaultSettings()
{ {
PluginSettings instance = new PluginSettings(); PluginSettings instance = new PluginSettings();
instance.FallbackBehavior = FallbackBehavior.SystemSounds; instance.FallbackBehavior = FallbackBehavior.SystemSounds;
instance.StepSize = 1; instance.StepSize = 1;
instance.Overrides = DefaultOverrides; instance.Overrides = DefaultOverrides;
instance.Ignored = "";
return instance; return instance;
} }
} }
@ -57,9 +61,20 @@ public class DialAction : EncoderBase
else else
{ {
settings = payload.Settings.ToObject<PluginSettings>(); settings = payload.Settings.ToObject<PluginSettings>();
bool save = false;
if(string.IsNullOrEmpty(settings.Overrides)) if(string.IsNullOrEmpty(settings.Overrides))
{ {
settings.Overrides = DefaultOverrides; settings.Overrides = DefaultOverrides;
save = true;
}
if(string.IsNullOrEmpty(settings.Ignored))
{
settings.Ignored = "";
save = true;
}
if(save)
{
_ = SaveSettings(); _ = SaveSettings();
} }
} }
@ -69,6 +84,7 @@ public class DialAction : EncoderBase
try try
{ {
_audioHelper.Overrides = OverrideParser.Parse(settings.Overrides); _audioHelper.Overrides = OverrideParser.Parse(settings.Overrides);
_audioHelper.Ignored = IgnoreParser.Parse(settings.Ignored);
//just in case we fail to get the active session, don't prevent the plugin from launching //just in case we fail to get the active session, don't prevent the plugin from launching
var session = _audioHelper.GetActiveSession(settings.FallbackBehavior); var session = _audioHelper.GetActiveSession(settings.FallbackBehavior);
_ = UpdateStateIfNeeded(session); _ = UpdateStateIfNeeded(session);
@ -238,6 +254,7 @@ public class DialAction : EncoderBase
{ {
Tools.AutoPopulateSettings(settings, payload.Settings); Tools.AutoPopulateSettings(settings, payload.Settings);
_audioHelper.Overrides = OverrideParser.Parse(settings.Overrides); _audioHelper.Overrides = OverrideParser.Parse(settings.Overrides);
_audioHelper.Ignored = IgnoreParser.Parse(settings.Ignored);
//_ = SaveSettings(); //_ = SaveSettings();
} }
catch (Exception ex) catch (Exception ex)

View File

@ -67,6 +67,7 @@
<Compile Include="FallbackBehavior.cs" /> <Compile Include="FallbackBehavior.cs" />
<Compile Include="AudioHelpers\NameAndIconHelper.cs" /> <Compile Include="AudioHelpers\NameAndIconHelper.cs" />
<Compile Include="InternalsVisibleTo.cs" /> <Compile Include="InternalsVisibleTo.cs" />
<Compile Include="Overrides\IgnoreParser.cs" />
<Compile Include="Overrides\Override.cs" /> <Compile Include="Overrides\Override.cs" />
<Compile Include="Overrides\MatchType.cs" /> <Compile Include="Overrides\MatchType.cs" />
<Compile Include="Overrides\OverrideParser.cs" /> <Compile Include="Overrides\OverrideParser.cs" />

View File

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FocusVolumeControl.Overrides
{
internal class IgnoreParser
{
public static List<string> Parse(string raw)
{
var ignores = new List<string>();
if (raw == null)
{
return ignores;
}
var lines = raw.Split(new[] { "\r\n", "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries);
foreach (var line in lines)
{
if (string.IsNullOrEmpty(line) || line.StartsWith("//"))
{
continue;
}
var str = line.Trim();
ignores.Add(line.Trim());
}
return ignores;
}
}
}

View File

@ -61,6 +61,22 @@
</details> </details>
<div type="textarea" class="sdpi-item">
<div class="sdpi-item-label">Ignored</div>
<span class="sdpi-item-value" textarea>
<textarea type="textarea" class="sdProperty" id="ignored" oninput="setSettings()"></textarea>
</span>
</div>
<details>
<summary>Ignored Details</summary>
<p>Sometimes you may not want certain processes to be controlable.</p>
<p>In this case, you can add a list of process names which will be ignored.</p>
<p>ex:<br /> chrome</p>
<p>Blank lines can be used for spacing<br/>Lines starting with // are ignored</p>
<p>To get a process name, you can use task manager, right click on a process and select properties</p>
<p>Process names are case sensitive and must match exactly</p>
</details>
</div> </div>
</body> </body>

View File

@ -33,7 +33,7 @@
"Name": "Focused Application Volume", "Name": "Focused Application Volume",
"Description": "Control the volume of the focused application", "Description": "Control the volume of the focused application",
"URL": "https://github.com/dlprows/FocusVolumeControl", "URL": "https://github.com/dlprows/FocusVolumeControl",
"Version": "1.3.1", "Version": "1.4.0",
"CodePath": "FocusVolumeControl", "CodePath": "FocusVolumeControl",
"Category": "Volume Control [dlprows]", "Category": "Volume Control [dlprows]",
"Icon": "Images/pluginIcon", "Icon": "Images/pluginIcon",