Fix example in scriptdata/uv/README.md

This commit is contained in:
Celestial.y
2025-10-08 22:43:15 +08:00
committed by GitHub
parent c412090dbc
commit 26bab59886
+15 -6
View File
@@ -49,12 +49,11 @@ Example: In `~/.config/quickshell/ii/screenshot.qml`:
Process { Process {
id: imageDetectionProcess id: imageDetectionProcess
command: ["bash", "-c", `${Directories.scriptPath}/images/find_regions.py ` command: ["bash", "-c", `${Directories.scriptPath}/images/find_regions.py `
command: ["bash", "-c", `${Directories.scriptPath}/images/find-regions-venv.sh `
+ `--hyprctl ` + `--hyprctl `
+ `--image '${StringUtils.shellSingleQuoteEscape(panelWindow.screenshotPath)}' ` + `--image '${StringUtils.shellSingleQuoteEscape(panelWindow.screenshotPath)}' `
+ `--max-width ${Math.round(panelWindow.screen.width * root.falsePositivePreventionRatio)} ` + `--max-width ${Math.round(panelWindow.screen.width * root.falsePositivePreventionRatio)} `
``` ```
In this example, python script `${Directories.scriptPath}/images/find_regions.py` is called and receives some arguments. In this example, python script `find_regions.py` is called and receives some arguments.
#### Solution A: shebang #### Solution A: shebang
@@ -73,21 +72,31 @@ However:
#### Solution B: bash script as wrapper #### Solution B: bash script as wrapper
For this solution, first make sure the python script is using the shebang `#!/usr/bin/env python3`. First make sure the python script is using the shebang `#!/usr/bin/env python3`, instead of `#!/usr/bin/python3` or something else.
Write a wrapper script in bash. Then write a wrapper script in bash.
(Take `find_regions.py` as example, write `find-regions-venv.sh` in the same directory.) Let's continue the `screenshot.qml` example, in the same directory as `find_regions.py`, write a `find-regions-venv.sh`:
```bash ```bash
#!/usr/bin/env bash #!/usr/bin/env bash
# Specify the path of the python script. # Specify the path of the python script.
# The example below only applies when `find_regions.py` and the wrapper script are under the same folder. # The example below only applies when `find_regions.py` and this wrapper script are under the same folder.
PY_SCRIPT="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)/find_regions.py" PY_SCRIPT="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)/find_regions.py"
source $(eval echo $ILLOGICAL_IMPULSE_VIRTUAL_ENV)/bin/activate source $(eval echo $ILLOGICAL_IMPULSE_VIRTUAL_ENV)/bin/activate
"$PY_SCRIPT" "$@" "$PY_SCRIPT" "$@"
deactivate deactivate
``` ```
**Not done yet!** Do not forget to update the code calling the original python script.
In this example, in `~/.config/quickshell/ii/screenshot.qml` we should modify `find_regions.py` to the wrapper script `find-regions-venv.sh`:
```qml
Process {
id: imageDetectionProcess
command: ["bash", "-c", `${Directories.scriptPath}/images/find-regions-venv.sh `
+ `--hyprctl `
+ `--image '${StringUtils.shellSingleQuoteEscape(panelWindow.screenshotPath)}' `
+ `--max-width ${Math.round(panelWindow.screen.width * root.falsePositivePreventionRatio)} `
```
### Situation 2: Inside a bash script ### Situation 2: Inside a bash script
Note: the solutions for `Situation 1: As a single command` also apply here; but **not** vice versa. Note: the solutions for `Situation 1: As a single command` also apply here; but **not** vice versa.