Skip to content

Commit 9ed71c5

Browse files
committed
Add settings for visual effects
#149
1 parent 0c80a87 commit 9ed71c5

File tree

2 files changed

+79
-2
lines changed

2 files changed

+79
-2
lines changed

Main.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ public record class Configuration(
344344
IStartPinsSettings StartPinsSettings,
345345
IStartTilesSettings StartTilesSettings,
346346
CompactOsModes CompactOsMode,
347-
ITaskbarIcons TaskbarIcons
347+
ITaskbarIcons TaskbarIcons,
348+
IEffects Effects
348349
)
349350
{
350351
public static Configuration Default => new(
@@ -406,7 +407,8 @@ ITaskbarIcons TaskbarIcons
406407
StartPinsSettings: new DefaultStartPinsSettings(),
407408
StartTilesSettings: new DefaultStartTilesSettings(),
408409
CompactOsMode: CompactOsModes.Default,
409-
TaskbarIcons: new DefaultTaskbarIcons()
410+
TaskbarIcons: new DefaultTaskbarIcons(),
411+
Effects: new DefaultEffects()
410412
);
411413
}
412414

modifier/Optimizations.cs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using Newtonsoft.Json;
22
using System;
3+
using System.Collections.Immutable;
34
using System.IO;
5+
using System.Text;
46
using System.Xml;
57

68
namespace Schneegans.Unattend;
@@ -73,6 +75,39 @@ public record class CustomTaskbarIcons(
7375
string Xml
7476
) : ITaskbarIcons;
7577

78+
public interface IEffects;
79+
80+
public record class DefaultEffects : IEffects;
81+
82+
public record class BestPerformanceEffects : IEffects;
83+
84+
public record class BestAppearanceEffects : IEffects;
85+
86+
public record class CustomEffects(
87+
ImmutableDictionary<Effect, bool> Settings
88+
) : IEffects;
89+
90+
public enum Effect
91+
{
92+
ControlAnimations,
93+
AnimateMinMax,
94+
TaskbarAnimations,
95+
DWMAeroPeekEnabled,
96+
MenuAnimation,
97+
TooltipAnimation,
98+
SelectionFade,
99+
DWMSaveThumbnailEnabled,
100+
CursorShadow,
101+
ListviewShadow,
102+
ThumbnailsOrIcon,
103+
ListviewAlphaSelect,
104+
DragFullWindows,
105+
ComboBoxAnimation,
106+
FontSmoothing,
107+
ListBoxSmoothScrolling,
108+
DropShadow
109+
}
110+
76111
class OptimizationsModifier(ModifierContext context) : Modifier(context)
77112
{
78113
public override void Process()
@@ -555,5 +590,45 @@ void SetStartTiles(string xml)
555590
DefaultUserScript.Append(@"reg.exe add ""HKU\DefaultUser\Software\Policies\Microsoft\Windows\Explorer"" /v DisableSearchBoxSuggestions /t REG_DWORD /d 1 /f;");
556591
}
557592
}
593+
{
594+
static ImmutableDictionary<Effect, bool> MakeEffectsDictionary(bool value)
595+
{
596+
var builder = ImmutableDictionary.CreateBuilder<Effect, bool>();
597+
foreach (var key in Enum.GetValues<Effect>())
598+
{
599+
builder.Add(key, value);
600+
}
601+
return builder.ToImmutable();
602+
}
603+
604+
void SetEffects(CustomEffects effects, int setting)
605+
{
606+
StringBuilder sb = new();
607+
foreach (var pair in effects.Settings)
608+
{
609+
sb.AppendLine(@$"Set-ItemProperty -LiteralPath ""Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\{pair.Key}"" -Name 'DefaultValue' -Value {(pair.Value ? 1 : 0)} -Type 'DWord' -Force;");
610+
}
611+
SpecializeScript.Append(sb.ToString());
612+
UserOnceScript.Append($@"Set-ItemProperty -LiteralPath 'Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects' -Name 'VisualFXSetting' -Type 'DWord' -Value {setting} -Force;");
613+
}
614+
615+
switch (Configuration.Effects)
616+
{
617+
case DefaultEffects:
618+
break;
619+
620+
case BestAppearanceEffects:
621+
SetEffects(new CustomEffects(MakeEffectsDictionary(true)), 1);
622+
break;
623+
624+
case BestPerformanceEffects:
625+
SetEffects(new CustomEffects(MakeEffectsDictionary(false)), 2);
626+
break;
627+
628+
case CustomEffects effects:
629+
SetEffects(effects, 3);
630+
break;
631+
}
632+
}
558633
}
559634
}

0 commit comments

Comments
 (0)