Skip to content

Commit

Permalink
cmd/etrace: fail on non-X11 XDG_SESSION_TYPE
Browse files Browse the repository at this point in the history
We only support X11 right now

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
  • Loading branch information
anonymouse64 committed Jul 20, 2020
1 parent 579f686 commit 4a0e014
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/etrace/cmd_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ func (x *cmdExec) Execute(args []string) error {
w = file
}

if !x.NoWindowWait {
// check if we are running on X11, if not then bail because we don't
// support graphical window waiting on wayland yet
sessionType := os.Getenv("XDG_SESSION_TYPE")
if strings.TrimSpace(strings.ToLower(sessionType)) != "x11" {
return fmt.Errorf("error: graphical session type %s is unsupported, only x11 is supported", sessionType)
}
}

outRes := ExecOutputResult{}
max := uint(1)
if currentCmd.Repeat > 0 {
Expand Down
9 changes: 9 additions & 0 deletions cmd/etrace/cmd_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ type FileOutputResult struct {
}

func (x *cmdFile) Execute(args []string) error {
if !x.NoWindowWait {
// check if we are running on X11, if not then bail because we don't
// support graphical window waiting on wayland yet
sessionType := os.Getenv("XDG_SESSION_TYPE")
if strings.TrimSpace(strings.ToLower(sessionType)) != "x11" {
return fmt.Errorf("error: graphical session type %s is unsupported, only x11 is supported", sessionType)
}
}

// check the output file
w := os.Stdout
if x.OutputFile != "" {
Expand Down

0 comments on commit 4a0e014

Please sign in to comment.