Giving X11 support for Windows WSL

This commit is contained in:
FlUxIuS 2024-05-18 22:51:26 +02:00
parent 644df8b509
commit 9e013f66c3
3 changed files with 39 additions and 12 deletions

View File

@ -93,11 +93,14 @@ RUN ./entrypoint.sh grfhss_utils_grmod_install # depends on 'grpdu_utils_grmod_i
# Installing gr-fosphor with OpenCL
#RUN ./entrypoint.sh grfosphor_grmod_install
# Installing cyberther with OpenCL
RUN ./entrypoint.sh cyberther_soft_install
# Installing softwares
RUN ./entrypoint.sh sdrpp_soft_install
RUN ./entrypoint.sh sigdigger_soft_install
RUN ./entrypoint.sh inspection_decoding_tools
RUN ./entrypoint.sh cyberther_soft_install
#RUN ./entrypoint.sh cyberther_soft_install
RUN ./entrypoint.sh qsstv_soft_install
RUN ./entrypoint.sh ice9_bluetooth_soft_install
@ -122,4 +125,4 @@ WORKDIR /root/
RUN rm -rf /root/rules/
RUN rm -rf /root/thirdparty
RUN apt-fast clean
RUN DEBIAN_FRONTEND=noninteractive rm -rf /var/lib/apt/lists/*
RUN DEBIAN_FRONTEND=noninteractive rm -rf /var/lib/apt/lists/*

View File

@ -7,6 +7,7 @@ package cli
import (
"fmt"
"os"
"runtime"
"github.com/spf13/cobra"
rfdock "penthertz/rfswift/dock"
@ -37,11 +38,16 @@ var runCmd = &cobra.Command{
Short: "create and run a program",
Long: `Create a container and run a program inside the docker container`,
Run: func(cmd *cobra.Command, args []string) {
rfutils.XHostEnable() // force xhost to add local connections ALCs, TODO: to optimize later
rfdock.DockerSetShell(ExecCmd)
rfdock.DockerAddBiding(ExtraBind)
rfdock.DockerSetImage(DImage)
rfdock.DockerRun()
os := runtime.GOOS
if os == "windows" {
rfdock.DockerSetx11("/run/desktop/mnt/host/wslg/.X11-unix:/tmp/.X11-unix,/run/desktop/mnt/host/wslg:/mnt/wslg")
} else {
rfutils.XHostEnable() // force xhost to add local connections ALCs, TODO: to optimize later
}
rfdock.DockerSetShell(ExecCmd)
rfdock.DockerAddBiding(ExtraBind)
rfdock.DockerSetImage(DImage)
rfdock.DockerRun()
},
}
@ -50,9 +56,14 @@ var execCmd = &cobra.Command{
Short: "exec a command",
Long: `Exec a program on a created docker container, even not started`,
Run: func(cmd *cobra.Command, args []string) {
rfutils.XHostEnable() // force xhost to add local connections ALCs, TODO: to optimize later
rfdock.DockerSetShell(ExecCmd)
rfdock.DockerExec(ContID, "/root")
os := runtime.GOOS
if os == "windows" {
rfdock.DockerSetx11("/run/desktop/mnt/host/wslg/.X11-unix:/tmp/.X11-unix,/run/desktop/mnt/host/wslg:/mnt/wslg")
} else {
rfutils.XHostEnable() // force xhost to add local connections ALCs, TODO: to optimize later
}
rfdock.DockerSetShell(ExecCmd)
rfdock.DockerExec(ContID, "/root")
},
}

View File

@ -44,6 +44,15 @@ var dockerObj = DockerInst{ net: "host",
shell: "/bin/bash"} // Instance with default values
func DockerSetx11(x11forward string) {
/* Sets the shell to use in the Docker container
in(1): string command shell to use
*/
if (x11forward != "") {
dockerObj.x11forward = x11forward
}
}
func DockerSetShell(shellcmd string) {
/* Sets the shell to use in the Docker container
in(1): string command shell to use
@ -118,9 +127,13 @@ func DockerRun() {
}
defer cli.Close()
var bindings = []string{dockerObj.x11forward, dockerObj.usbforward}
x11split := strings.Split(dockerObj.x11forward, ",")
var bindings = x11split
//bindings = append(bindings, dockerObj.x11split...)
bindings = append(bindings, strings.Split(dockerObj.usbforward, ",")...)
if (dockerObj.extrabinding != "") {
bindings = append([]string{dockerObj.x11forward, dockerObj.usbforward}, strings.Split(dockerObj.extrabinding, ",")...)
bindings = append(bindings, strings.Split(dockerObj.extrabinding, ",")...)
}
resp, err := cli.ContainerCreate(ctx, &container.Config{