Skip to content

Commit

Permalink
use incoming cookie variable
Browse files Browse the repository at this point in the history
  • Loading branch information
marwan-at-work committed Nov 16, 2023
1 parent fc20ffd commit 6f0bd81
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ func newClient(appName, cookie string) (*Client, error) {
h.Set("origin", "ws://localhost/")
h.Set("x-iterm2-library-version", "go 3.6")
h.Set("x-iterm2-disable-auth-ui", "true")
// Disable using env var cookie due to
if cookie := os.Getenv("ITERM2_COOKIE"); cookie != "" {
h.Set("x-iterm2-cookie", cookie)
} else {
if cookie == "" {
resp, err := mack.Tell("iTerm2", fmt.Sprintf("request cookie and key for app named %q", appName))
if err != nil {
return nil, fmt.Errorf("AppleScript/tell: %w", err)
Expand All @@ -59,9 +56,10 @@ func newClient(appName, cookie string) (*Client, error) {
if len(fields) != 2 {
return nil, fmt.Errorf("incorrect field format: %q", resp)
}
h.Set("x-iterm2-cookie", fields[0])
cookie = fields[0]
h.Set("x-iterm2-key", fields[1])
}
h.Set("x-iterm2-cookie", cookie)
homeDir, err := os.UserHomeDir()
if err != nil {
return nil, fmt.Errorf("os.UserHomeDir: %w", err)
Expand Down

0 comments on commit 6f0bd81

Please sign in to comment.