raycast/script-commands

Script causes the dock to come into focus as if Finder was right-clicked

GroovinChip opened this issue · 5 comments

I have my dock set to "Automatically hide and show". When I run a custom script that uses scrcpy to mirror my device's screen, the dock appears and puts itself into a state where it thinks Finder has been right-clicked on.

Screenshot:

image

Here is my script:

#!/bin/bash

# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Mirror TC75x
# @raycast.mode compact

# Optional parameters:
# @raycast.icon 🤖

scrcpy -s 18026522502869 --always-on-top --window-height=720 --legacy-paste

Why is this happening and how can I make it stop?

dehesa commented

Hey there @GroovinChip,

This doesn't seem to be an issue of Raycast, but of scrcpy. Sadly I cannot help you there because I have zero experience with that command-line tool. It doesn't seem like the proper tool for the job.

Do you know you can set up a system shortcut for that directly in System Settings > Keyboard > Keyboard Shortcuts?

Dock

@dehesa Thanks for replying. I don't think the issue is with scrcpy because running the same command in my terminal doesn't result in this behavior.

I didn't know about that shortcut, but toggling the dock to be visible doesn't help - Finder gets "right-clicked" on even if the dock is visible.

Something I just noticed when running the script in fullOutput mode rather than compact, versus running the script in the terminal, is that the output is different.

Regular terminal output:

INFO: ADB device found:
INFO:     -->   (usb)  18026522502869                  device  TC75x
/opt/homebrew/Cellar/scrcpy/2.1.1/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 187.8 MB/s (56995 bytes in 0.000s)
[server] INFO: Device: [Zebra Technologies] Zebra TC75x (Android 7.1.2)
[server] WARN: Audio disabled: it is not supported before Android 11
INFO: Renderer: metal
WARN: Demuxer 'audio': stream explicitly disabled by the device
INFO: Texture: 720x1280

Raycast output:

/opt/homebrew/Cellar/scrcpy/2.1.1/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 186.5 MB/s (56995 bytes in 0.000s)
[server] INFO: Device: [Zebra Technologies] Zebra TC75x (Android 7.1.2)
[server] WARN: Audio disabled: it is not supported before Android 11
WARN: Demuxer 'audio': stream explicitly disabled by the device

Perhaps this could be of some use in diagnosing the issue

dehesa commented

Ok, I re-read your messages and I think I now understand what you meant (sorry for the misunderstanding). Basically:

  • You run a script in Raycast (whether compact or fullOutput).
  • The script internally calls scrcpy (which mirrors your Android device).
  • The result in the dock appearing and the finder being preselected/rightClicked.
    Does it successfully mirror your device, though?

Scripts in Raycast are run as a subprocess in a non-login shell (as explained in the Troubleshooting section of the README and in the CONTRIBUTING file). Since, the script is working in the Terminal, I would guess one (or both) of the following two things are happening:

  • Raycast doesn't have the same privileges as the Terminal.
  • The non-login shell is creating problems to srccpy since it might expect some information that is not being passed for privacy reasons.
dehesa commented

I am closing this for now, but feel free to reopen it if you want to add more details.