forked from amkovkov/GranuSightSoftware2
55 lines
1.2 KiB
C#
55 lines
1.2 KiB
C#
using System.Diagnostics;
|
|
using System.Reflection;
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
|
using Avalonia.Threading;
|
|
|
|
using GSS2.UI.Core.ViewModels;
|
|
|
|
namespace GSS2.ViewModels.Common;
|
|
|
|
public partial class SystemViewModel : ViewModelBase
|
|
{
|
|
public SystemViewModel()
|
|
{
|
|
|
|
}
|
|
|
|
[RelayCommand]
|
|
void Close()
|
|
{
|
|
|
|
Dispatcher.UIThread.InvokeShutdown();
|
|
}
|
|
|
|
[RelayCommand]
|
|
void Shutdown()
|
|
{
|
|
var process = new Process();
|
|
process.StartInfo.FileName = "/usr/bin/sudo";
|
|
process.StartInfo.Arguments = "/sbin/shutdown -h now";
|
|
process.Start();
|
|
}
|
|
|
|
[RelayCommand]
|
|
void Reboot()
|
|
{
|
|
var process = new Process();
|
|
process.StartInfo.FileName = "/usr/bin/sudo";
|
|
process.StartInfo.Arguments = "/sbin/shutdown -r now";
|
|
process.Start();
|
|
}
|
|
[RelayCommand]
|
|
void Restart()
|
|
{
|
|
var process = new Process();
|
|
process.StartInfo.FileName = "/home/granusight/.dotnet/dotnet";
|
|
process.StartInfo.Arguments = Assembly.GetExecutingAssembly().Location;
|
|
Dispatcher.UIThread.InvokeShutdown();
|
|
process.Start();
|
|
Environment.Exit(0);
|
|
}
|
|
}
|