I'm currently developing a Kiosk style application that will run on a Raspberry Pi 3B+ where my frontend is a Chromium instance running in Kiosk mode and my backend is a locally hosted ASP.NET Core 3.0 project. My problem now is that the user needs to enter some text to search for something but I only have the touchscreen interface, no keyboard. So now I need to focus the XVKBD instance running in the background, I can do this by using wmctrl to focus it. This works perfectly fine when running the command from a terminal, but doesn't work when my ASP.NET application is invoking it with a Process
, here is my code:
Bash to focus XVKBD/ Chromium:
# Show XVKBD
wmctrl -a xvkbd
# Show Chromium
wmctrl -a Chromium
C# Code
public void FocusKeyboard()
{
var proc = new Process
{
StartInfo = new ProcessStartInfo("bash", "\"wmctrl -a xvkbd\"")
};
proc.Start();
}
///<param name="title">Passed in from JS to tell wmctrl what to focus</param>
public void FocusChromium(string title)
{
var proc = new Process
{
StartInfo = new ProcessStartInfo("bash", $"\"wmctrl -a {title}\"")
};
proc.Start();
}
Note that the C# code is being called by JavaScript running in the frontend via SignalR
Expected behaviour: When I call the FocusKeyboard
method it should focus the xvkbd instance and when I call the FocusChromium
method it should focus the Chromium instance.
Actual behaviour: It does nothing.
So my question is this: How can I switch focus for my user in a ASP.NET application?