mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 21:38:38 +00:00
Merge pull request #770 from Artemis-RGB/feature/linux-icons
Linux update script
This commit is contained in:
commit
69c623bc8f
@ -29,6 +29,7 @@ public class ApplicationStateManager
|
||||
|
||||
Core.Utilities.ShutdownRequested += UtilitiesOnShutdownRequested;
|
||||
Core.Utilities.RestartRequested += UtilitiesOnRestartRequested;
|
||||
Core.Utilities.UpdateRequested += UtilitiesOnUpdateRequested;
|
||||
|
||||
// On OS shutdown dispose the IOC container just so device providers get a chance to clean up
|
||||
if (Application.Current?.ApplicationLifetime is IControlledApplicationLifetime controlledApplicationLifetime)
|
||||
@ -138,4 +139,35 @@ public class ApplicationStateManager
|
||||
|
||||
//todo
|
||||
}
|
||||
|
||||
private void UtilitiesOnUpdateRequested(object? sender, UpdateEventArgs e)
|
||||
{
|
||||
List<string> argsList = new(StartupArguments);
|
||||
if (e.Silent && !argsList.Contains("--minimized"))
|
||||
argsList.Add("--minimized");
|
||||
|
||||
// Retain startup arguments after update by providing them to the script
|
||||
string script = Path.Combine(Constants.UpdatingFolder, "installing", "Scripts", "update.sh");
|
||||
string source = $"\"{Path.Combine(Constants.UpdatingFolder, "installing")}\"";
|
||||
string destination = $"\"{Constants.ApplicationFolder}\"";
|
||||
string args = argsList.Any() ? string.Join(' ', argsList) : "";
|
||||
|
||||
RunScriptWithOutputFile(script, $"{source} {destination} {args}", Path.Combine(Constants.DataFolder, "update-log.txt"));
|
||||
|
||||
// Lets try a graceful shutdown, the script will kill if needed
|
||||
if (Application.Current?.ApplicationLifetime is IControlledApplicationLifetime controlledApplicationLifetime)
|
||||
Dispatcher.UIThread.Post(() => controlledApplicationLifetime.Shutdown());
|
||||
}
|
||||
|
||||
private static void RunScriptWithOutputFile(string script, string arguments, string outputFile)
|
||||
{
|
||||
ProcessStartInfo info = new()
|
||||
{
|
||||
Arguments = $"\"{script}\" {arguments} > \"{outputFile}\"",
|
||||
FileName = "/bin/bash",
|
||||
WindowStyle = ProcessWindowStyle.Hidden,
|
||||
CreateNoWindow = true,
|
||||
};
|
||||
Process.Start(info);
|
||||
}
|
||||
}
|
||||
@ -27,4 +27,8 @@
|
||||
<ProjectReference Include="..\Artemis.Core\Artemis.Core.csproj" />
|
||||
<ProjectReference Include="..\Artemis.UI\Artemis.UI.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Icons/**" CopyToOutputDirectory="PreserveNewest" />
|
||||
<Content Include="Scripts/**" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
BIN
src/Artemis.UI.Linux/Icons/128x128/apps/artemis.png
Normal file
BIN
src/Artemis.UI.Linux/Icons/128x128/apps/artemis.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.8 KiB |
BIN
src/Artemis.UI.Linux/Icons/16x16/apps/artemis.png
Normal file
BIN
src/Artemis.UI.Linux/Icons/16x16/apps/artemis.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 518 B |
BIN
src/Artemis.UI.Linux/Icons/256x256/apps/artemis.png
Normal file
BIN
src/Artemis.UI.Linux/Icons/256x256/apps/artemis.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
BIN
src/Artemis.UI.Linux/Icons/32x32/apps/artemis.png
Normal file
BIN
src/Artemis.UI.Linux/Icons/32x32/apps/artemis.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
BIN
src/Artemis.UI.Linux/Icons/48x48/apps/artemis.png
Normal file
BIN
src/Artemis.UI.Linux/Icons/48x48/apps/artemis.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
src/Artemis.UI.Linux/Icons/64x64/apps/artemis.png
Normal file
BIN
src/Artemis.UI.Linux/Icons/64x64/apps/artemis.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
56
src/Artemis.UI.Linux/Scripts/update.sh
Normal file
56
src/Artemis.UI.Linux/Scripts/update.sh
Normal file
@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
|
||||
sourceDirectory=$1
|
||||
destinationDirectory=$2
|
||||
artemisArgs=$3
|
||||
|
||||
# Wait for up to 10 seconds for the Artemis process to exit
|
||||
i=0
|
||||
while [ $i -le 10 ]
|
||||
do
|
||||
if ! pgrep -x "Artemis.UI.Linux" > /dev/null
|
||||
then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
i=$((i+1))
|
||||
done
|
||||
|
||||
# If the Artemis process is still running, kill it
|
||||
if pgrep -x "Artemis.UI.Linux" > /dev/null
|
||||
then
|
||||
pkill -x "Artemis.UI.Linux"
|
||||
fi
|
||||
|
||||
# Check if the destination directory exists
|
||||
if [ ! -d "$destinationDirectory" ]
|
||||
then
|
||||
echo "Destination directory does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Clear the destination directory but don't remove it
|
||||
echo "Cleaning up old version where needed"
|
||||
rm -rf "${destinationDirectory:?}/"*
|
||||
|
||||
# Move the contents of the source directory to the destination directory
|
||||
echo "Installing new files"
|
||||
mv "$sourceDirectory"/* "$destinationDirectory"
|
||||
|
||||
# Remove the now empty source directory
|
||||
rmdir "$sourceDirectory"
|
||||
|
||||
# Ensure the executable is executable
|
||||
chmod +x "$destinationDirectory/Artemis.UI.Linux"
|
||||
|
||||
echo "Finished! Restarting Artemis"
|
||||
sleep 1
|
||||
|
||||
# When finished, start Artemis again
|
||||
|
||||
# quoting here breaks stuff, all arguments count as 1
|
||||
# shellcheck disable=SC2086
|
||||
"$destinationDirectory/Artemis.UI.Linux" $artemisArgs &
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user