Skip to content

Commit

Permalink
Revert "Accept any XDG_ environment variable to determine desktop (#2037
Browse files Browse the repository at this point in the history
)" (#2042)

This reverts commit 67e2185.
  • Loading branch information
mlsmaycon authored May 23, 2024
1 parent 29a2d93 commit 69048bf
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 25 deletions.
12 changes: 1 addition & 11 deletions client/cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,5 @@ func openURL(cmd *cobra.Command, verificationURIComplete, userCode string) {

// isLinuxRunningDesktop checks if a Linux OS is running desktop environment
func isLinuxRunningDesktop() bool {
if os.Getenv("DESKTOP_SESSION") != "" {
return true
}

for _, env := range os.Environ() {
if strings.HasPrefix(env, "XDG_") {
return true
}
}

return false
return os.Getenv("DESKTOP_SESSION") != "" || os.Getenv("XDG_CURRENT_DESKTOP") != ""
}
14 changes: 0 additions & 14 deletions client/cmd/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"fmt"
"runtime"
"strings"
"testing"

Expand Down Expand Up @@ -52,16 +51,3 @@ func TestLogin(t *testing.T) {
t.Errorf("expected non empty Private key, got empty")
}
}

func TestIsLinuxRunningDesktop(t *testing.T) {
if runtime.GOOS != "linux" {
t.Skip("skipping test on non-linux platform")
}

t.Setenv("XDG_FOO", "BAR")

isDesktop := isLinuxRunningDesktop()
if !isDesktop {
t.Errorf("expected desktop environment, got false")
}
}

0 comments on commit 69048bf

Please sign in to comment.