Skip to content

Commit

Permalink
fucking Snap Again
Browse files Browse the repository at this point in the history
  • Loading branch information
EvilLord666 committed Mar 5, 2024
1 parent a41b4da commit becd543
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ namespace Wissance.Zerial.Desktop.Managers
{
public class DeviceConfigurationManager
{
public DeviceConfigurationManager(string configFile)
public DeviceConfigurationManager(string env, string configFile)
{
try
if (env != Program.SnapEnvironmentKey)
{
bool result = PrepareDevConfigDirectory(configFile);
if (!result)
Expand All @@ -29,10 +29,6 @@ public DeviceConfigurationManager(string configFile)
}
}
}
catch (Exception e)
{
// SNAP ASSHOLE!!!
}
}

public ObservableCollection<SerialPortShortInfoModel> Load()
Expand Down
24 changes: 22 additions & 2 deletions app/Wissance.Zerial/Wissance.Zerial.Desktop/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Avalonia;
using Avalonia.ReactiveUI;
using System;
using System.Linq;

namespace Wissance.Zerial.Desktop;

Expand All @@ -10,8 +11,21 @@ class Program
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
public static void Main(string[] args)
{
string env = args.FirstOrDefault(a => a.Contains(EnvironmentKey));
Environment = OtherEnvironmentKey;
if (env != null)
{
string[] parts = env.Split("=");
if (parts.Length == 2)
{
Environment = parts[1].ToLower() == SnapEnvironmentKey ? SnapEnvironmentKey : OtherEnvironmentKey;
}
}

BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
}

// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
Expand All @@ -20,4 +34,10 @@ public static AppBuilder BuildAvaloniaApp()
.WithInterFont()
.LogToTrace()
.UseReactiveUI();

public static string Environment { get; set; }

public const string SnapEnvironmentKey = "snap";
public const string OtherEnvironmentKey = "other";
private const string EnvironmentKey = "environment";
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public MainWindowViewModel()
SelectedPortNumber = Ports.Any() ? Ports.First() : null;
_deviceManager = new MultiDeviceRs232Manager(OnSerialDeviceDataReceived, new LoggerFactory());
_serialDevices = new List<SerialDeviceModel>();
_configurationManager = new DeviceConfigurationManager("devices.json");
_configurationManager = new DeviceConfigurationManager(Program.Environment, "devices.json");
DevicesConfigs = _configurationManager.Load();
// these init depends on loaded configuration
foreach (SerialPortShortInfoModel config in DevicesConfigs)
Expand Down
2 changes: 1 addition & 1 deletion snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ apps:
plugs:
- desktop
- desktop-legacy
command: ./Wissance.Zerial.Desktop
command: ./Wissance.Zerial.Desktop --environment=snap

0 comments on commit becd543

Please sign in to comment.