()
| 2125 | } |
| 2126 | |
| 2127 | func cursorFrontWindowTitle() (string, error) { |
| 2128 | script := `tell application "System Events" |
| 2129 | if not (exists application process "Cursor") then |
| 2130 | return "" |
| 2131 | end if |
| 2132 | |
| 2133 | tell application process "Cursor" |
| 2134 | repeat with w in windows |
| 2135 | try |
| 2136 | if value of attribute "AXMain" of w is true then |
| 2137 | return name of w |
| 2138 | end if |
| 2139 | end try |
| 2140 | end repeat |
| 2141 | |
| 2142 | if (count of windows) > 0 then |
| 2143 | try |
| 2144 | return name of window 1 |
| 2145 | end try |
| 2146 | end if |
| 2147 | end tell |
| 2148 | end tell |
| 2149 | |
| 2150 | return ""` |
| 2151 | |
| 2152 | cmd := exec.Command("osascript", "-e", script) |
| 2153 | output, err := cmd.CombinedOutput() |
| 2154 | if err != nil { |
| 2155 | trimmed := strings.TrimSpace(string(output)) |
| 2156 | if trimmed != "" { |
| 2157 | return "", fmt.Errorf("osascript front window: %s", trimmed) |
| 2158 | } |
| 2159 | return "", fmt.Errorf("osascript front window: %w", err) |
| 2160 | } |
| 2161 | |
| 2162 | return strings.TrimSpace(string(output)), nil |
| 2163 | } |
| 2164 | |
| 2165 | func runShExec(ctx *snap.Context) error { |
| 2166 | if ctx.NArgs() != 0 { |
no outgoing calls
no test coverage detected