Skip to content

Commit

Permalink
Updated CefSharp arguments and skip update checking on rpc call if debug
Browse files Browse the repository at this point in the history
  • Loading branch information
rocksdanister committed May 3, 2024
1 parent ab86fff commit 5e199b6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 15 deletions.
53 changes: 38 additions & 15 deletions src/Lively/Lively/Core/Wallpapers/WebCefSharpProcess.cs
Expand Up @@ -50,28 +50,28 @@ public class WebCefSharpProcess : IWallpaper
bool diskCache,
int volume)
{
//Streams can also use browser..
//TODO: Add support for livelyproperty video adjustments.
//Streams can also use browser.
var isWeb = model.LivelyInfo.Type == WallpaperType.url || model.LivelyInfo.Type == WallpaperType.web || model.LivelyInfo.Type == WallpaperType.webaudio;
LivelyPropertyCopyPath = isWeb ? livelyPropertyPath : null;

StringBuilder cmdArgs = new StringBuilder();
cmdArgs.Append(" --url " + "\"" + path + "\"");
cmdArgs.Append(" --display " + "\"" + display.DeviceId + "\"");
cmdArgs.Append(" --property " + "\"" + LivelyPropertyCopyPath + "\"");
var cmdArgs = new StringBuilder();
cmdArgs.Append(" --wallpaper-url " + "\"" + path + "\"");
cmdArgs.Append(" --wallpaper-display " + "\"" + display.DeviceId + "\"");
cmdArgs.Append(" --wallpaper-property " + "\"" + LivelyPropertyCopyPath + "\"");
//volume == 0, Cef is permanently muted and cannot be adjusted runtime
cmdArgs.Append(" --volume " + 100);
cmdArgs.Append(" --geometry " + display.Bounds.Width + "x" + display.Bounds.Height);
cmdArgs.Append(" --wallpaper-volume " + 100);
cmdArgs.Append(" --wallpaper-geometry " + display.Bounds.Width + "x" + display.Bounds.Height);
//--audio false Issue: https://github.com/commandlineparser/commandline/issues/702
cmdArgs.Append(model.LivelyInfo.Type == WallpaperType.webaudio ? " --audio true" : " ");
cmdArgs.Append(!string.IsNullOrWhiteSpace(model.LivelyInfo.Arguments) ? " " + model.LivelyInfo.Arguments : " ");
cmdArgs.Append(!string.IsNullOrWhiteSpace(debugPort) ? " --debug " + debugPort : " ");
cmdArgs.Append(model.LivelyInfo.Type == WallpaperType.url || model.LivelyInfo.Type == WallpaperType.videostream ? " --type online" : " --type local");
cmdArgs.Append(diskCache && model.LivelyInfo.Type == WallpaperType.url ? " --cache " + "\"" + Path.Combine(Constants.CommonPaths.TempCefDir, "cache", display.Index.ToString()) + "\"" : " ");
cmdArgs.Append(model.LivelyInfo.Type == WallpaperType.webaudio ? " --wallpaper-audio true" : " ");
cmdArgs.Append(!string.IsNullOrWhiteSpace(debugPort) ? " --wallpaper-debug " + debugPort : " ");
cmdArgs.Append(model.LivelyInfo.Type == WallpaperType.url || model.LivelyInfo.Type == WallpaperType.videostream ? " --wallpaper-type online" : " --wallpaper-type local");
cmdArgs.Append(diskCache && model.LivelyInfo.Type == WallpaperType.url ? " --wallpaper-cache " + "\"" + Path.Combine(Constants.CommonPaths.TempCefDir, "cache", display.Index.ToString()) + "\"" : " ");
if (TryParseUserCommandArgs(model.LivelyInfo.Arguments, out string parsedArgs))
cmdArgs.Append(parsedArgs);
#if DEBUG
//cmdArgs.Append(" --verbose-log true");
#endif

ProcessStartInfo start = new ProcessStartInfo
{
Arguments = cmdArgs.ToString(),
Expand All @@ -98,7 +98,7 @@ public class WebCefSharpProcess : IWallpaper
//for logging purpose
uniqueId = globalCount++;
}

public void Pause()
{
//minimize browser.
Expand Down Expand Up @@ -334,5 +334,28 @@ void OutputDataReceived(object sender, DataReceivedEventArgs e)
Proc.OutputDataReceived -= OutputDataReceived;
}
}

/// <summary>
/// Backward compatibility, appends --wallpaper to arguments if required.
/// </summary>
private static bool TryParseUserCommandArgs(string args, out string result)
{
if (string.IsNullOrWhiteSpace(args))
{
result = null;
return false;
}

var words = args.Split(' ');
for (int i = 0; i < words.Length; i++)
{
if (words[i].StartsWith("--"))
{
words[i] = string.Concat("--wallpaper-", words[i].AsSpan(2));
}
}
result = string.Join(" ", words);
return true;
}
}
}
3 changes: 3 additions & 0 deletions src/Lively/Lively/RPC/AppUpdateServer.cs
Expand Up @@ -34,7 +34,10 @@ public AppUpdateServer(IAppUpdaterService updater, IDialogService dialogService)

public override async Task<Empty> CheckUpdate(Empty _, ServerCallContext context)
{
#if !DEBUG
await updater.CheckUpdate(0);
#endif
Debug.WriteLine("App Update checking disabled in DEBUG mode.");
return await Task.FromResult(new Empty());
}

Expand Down

0 comments on commit 5e199b6

Please sign in to comment.