Godot Version
4.4.1
Question
Arch Linux, KDE, X11
I want to detect whether my cursor is currently grabbed (system-wide, so the Input singleton will not work for this). I have a shell script called test.sh in the project’s root directory.
#!/bin/bash
cat /var/log/Xorg.0.log
This is the function where I try to run the script.
func _on_timer_check_pointer_timeout() -> void:
var output_grabs: Array[String] = []
var output_dict: Dictionary[String, float] = {}
var exit_code_grabs = OS.execute("./test.sh", [], output_grabs, true)
var output_grabs0 := output_grabs[0].split("\n")
print(output_grabs0)
When I right-click on test.sh in my file browser and select “Run In Konsole” it prints the contents of the file as expected. The output of the godot function, however, is:
["cat: /var/log/Xorg.0.log: No such file or directory", ""]
“ls -s” gives me this for test.sh:
-rwxr-xr-x 1 pgcomai pgcomai 36 Feb 5 14:38 test.sh
I am using a shell script because I figured it might work better than putting it all in the arguments of OS.execute(), which did not work. The following code, which I use to poll hardware temps, works just fine.
var exit_code_name = OS.execute("bash", ["-c", "cat /sys/class/hwmon/hwmon*/name"], output_name)
var exit_code_temp = OS.execute("bash", ["-c", "cat /sys/class/hwmon/hwmon*/temp1_input"], output_temp)
Any insight would be helpful. I don’t know if the problem is Linux, Godot, the fact that I’m trying to read in /var instead of /sys, or all of those together.
P.S. As a sanity check, I can confirm that the following also does not work and gives the same “no such file or directory” output.
OS.execute("bash", ["-c", "cat /var/log/Xorg.0.log"], output_grabs, true)