Compare commits
3 Commits
v1.3.1-pre
...
main
Author | SHA1 | Date | |
---|---|---|---|
23ae43c155 | |||
d8b4bf340b | |||
cd306b0aab |
@ -17,6 +17,7 @@ public class AudioHelper
|
||||
int _retryFallbackCount = 0;
|
||||
|
||||
public List<Override> Overrides { get; set; }
|
||||
public List<string> Ignored { get; set; }
|
||||
|
||||
public IAudioSession Current { get; private set; }
|
||||
|
||||
@ -146,7 +147,13 @@ public class AudioHelper
|
||||
if (_currentProcesses == null || !_currentProcesses.SequenceEqual(processIds) || _retryFallbackCount == 5)
|
||||
{
|
||||
_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)
|
||||
{
|
||||
@ -217,6 +224,11 @@ public class AudioHelper
|
||||
{
|
||||
return new List<Process>();
|
||||
}
|
||||
|
||||
if(processes.Any(x => Ignored.Contains(x.ProcessName)))
|
||||
{
|
||||
return new List<Process>();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -33,12 +33,16 @@ public class DialAction : EncoderBase
|
||||
[JsonProperty("overrides")]
|
||||
public string Overrides { get; set; }
|
||||
|
||||
[JsonProperty("ignored")]
|
||||
public string Ignored { get; set; }
|
||||
|
||||
public static PluginSettings CreateDefaultSettings()
|
||||
{
|
||||
PluginSettings instance = new PluginSettings();
|
||||
instance.FallbackBehavior = FallbackBehavior.SystemSounds;
|
||||
instance.StepSize = 1;
|
||||
instance.Overrides = DefaultOverrides;
|
||||
instance.Ignored = "";
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@ -57,9 +61,20 @@ public class DialAction : EncoderBase
|
||||
else
|
||||
{
|
||||
settings = payload.Settings.ToObject<PluginSettings>();
|
||||
bool save = false;
|
||||
if(string.IsNullOrEmpty(settings.Overrides))
|
||||
{
|
||||
settings.Overrides = DefaultOverrides;
|
||||
save = true;
|
||||
}
|
||||
if(string.IsNullOrEmpty(settings.Ignored))
|
||||
{
|
||||
settings.Ignored = "";
|
||||
save = true;
|
||||
}
|
||||
|
||||
if(save)
|
||||
{
|
||||
_ = SaveSettings();
|
||||
}
|
||||
}
|
||||
@ -69,6 +84,7 @@ public class DialAction : EncoderBase
|
||||
try
|
||||
{
|
||||
_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
|
||||
var session = _audioHelper.GetActiveSession(settings.FallbackBehavior);
|
||||
_ = UpdateStateIfNeeded(session);
|
||||
@ -238,6 +254,7 @@ public class DialAction : EncoderBase
|
||||
{
|
||||
Tools.AutoPopulateSettings(settings, payload.Settings);
|
||||
_audioHelper.Overrides = OverrideParser.Parse(settings.Overrides);
|
||||
_audioHelper.Ignored = IgnoreParser.Parse(settings.Ignored);
|
||||
//_ = SaveSettings();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -67,6 +67,7 @@
|
||||
<Compile Include="FallbackBehavior.cs" />
|
||||
<Compile Include="AudioHelpers\NameAndIconHelper.cs" />
|
||||
<Compile Include="InternalsVisibleTo.cs" />
|
||||
<Compile Include="Overrides\IgnoreParser.cs" />
|
||||
<Compile Include="Overrides\Override.cs" />
|
||||
<Compile Include="Overrides\MatchType.cs" />
|
||||
<Compile Include="Overrides\OverrideParser.cs" />
|
||||
|
36
src/FocusVolumeControl/Overrides/IgnoreParser.cs
Normal file
36
src/FocusVolumeControl/Overrides/IgnoreParser.cs
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -61,6 +61,22 @@
|
||||
</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>
|
||||
</body>
|
||||
|
@ -33,7 +33,7 @@
|
||||
"Name": "Focused Application Volume",
|
||||
"Description": "Control the volume of the focused application",
|
||||
"URL": "https://github.com/dlprows/FocusVolumeControl",
|
||||
"Version": "1.3.1",
|
||||
"Version": "1.4.0",
|
||||
"CodePath": "FocusVolumeControl",
|
||||
"Category": "Volume Control [dlprows]",
|
||||
"Icon": "Images/pluginIcon",
|
||||
|
Loading…
x
Reference in New Issue
Block a user