Skip to content

Commit 09be837

Browse files
authored
run: Add support for X11/Wayland and NoGPU specific args (#108)
This provides an easier way to customise a given workload so that it will work effectively regardless of running it on Wayland or X11. It will also avoid issues when no GPU is available. Relates to #2.
2 parents 0c4de48 + 8694c22 commit 09be837

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

internal/qubesome/run.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@ func runner(in WorkloadInfo, runnerOverride string, headless bool) error {
184184
slog.Debug("unknown objects mismatch", "w", w, "ew", ew)
185185
}
186186

187+
if strings.EqualFold(os.Getenv("XDG_SESSION_TYPE"), "wayland") {
188+
ew.Workload.Args = append(ew.Workload.Args, ew.Workload.WaylandArgs...)
189+
} else {
190+
ew.Workload.Args = append(ew.Workload.Args, ew.Workload.X11Args...)
191+
}
192+
193+
if len(ew.Workload.HostAccess.Gpus) == 0 {
194+
ew.Workload.Args = append(ew.Workload.Args, ew.Workload.NoGPUArgs...)
195+
}
196+
187197
ew.Workload.Args = append(ew.Workload.Args, in.Args...)
188198

189199
if runnerOverride != "" {

internal/types/workload.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@ import (
1010
)
1111

1212
type Workload struct {
13-
Name string `yaml:"name"`
14-
Image string `yaml:"image"`
15-
Command string `yaml:"command"`
16-
Args []string `yaml:"args"`
13+
Name string `yaml:"name"`
14+
Image string `yaml:"image"`
15+
Command string `yaml:"command"`
16+
// Args defines X11-specific arguments.
17+
Args []string `yaml:"args"`
18+
// X11Args defines X11-specific arguments.
19+
X11Args []string `yaml:"x11Args"`
20+
// WaylandArgs defines Wayland-specific arguments.
21+
WaylandArgs []string `yaml:"waylandArgs"`
22+
// NoGPUArgs defines arguments to be used when no GPU is available.
23+
NoGPUArgs []string `yaml:"noGpuArgs"`
1724
SingleInstance bool `yaml:"singleInstance"`
1825
HostAccess HostAccess `yaml:"hostAccess"`
1926
MimeApps []string `yaml:"mimeApps"`

0 commit comments

Comments
 (0)