![从 systemd 服务守护进程显示终端窗口](https://linux22.com/image/145343/%E4%BB%8E%20systemd%20%E6%9C%8D%E5%8A%A1%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8B%E6%98%BE%E7%A4%BA%E7%BB%88%E7%AB%AF%E7%AA%97%E5%8F%A3.png)
设置:
Raspberry Pi 运行 raspbian,并连接显示器 (HDMI)
持续运行的 systemd 服务(守护进程)
目标:
启动显示屏上可见的新终端窗口
作为概念证明,我想运行一个 shell 脚本
在服务中运行 shell 脚本没有问题,但在显示屏上打开可见窗口似乎很困难。
代码(守护进程)
var process = new Process()
{
StartInfo = new ProcessStartInfo
{
FileName = "/bin/bash",
Arguments = $"-c \"{Paths.Dotnet} /path/to/app.dll\"",
WorkingDirectory = workingDirectory,
RedirectStandardOutput = false,
UseShellExecute = false,
CreateNoWindow = false,
WindowStyle = ProcessWindowStyle.Maximized
}
};
process.Start();
string result = process.StandardOutput.ReadToEnd();
process.WaitForExit();
**编辑** 将参数修改为:
Arguments = $"-c \"DISPLAY=:0.0 lxterminal -e {Paths.Dotnet} /path/to/app.dll\""
没有解决问题。 app.dll 被执行但仍在后台。