mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-26 10:14:39 +03:00
Use regex to make extraction bulletproof
This commit is contained in:
parent
dcc804783c
commit
7b4b1d6312
@ -33,9 +33,9 @@ fi
|
|||||||
# Make each Zed instance take up half of the screen.
|
# Make each Zed instance take up half of the screen.
|
||||||
output=$(system_profiler SPDisplaysDataType -json)
|
output=$(system_profiler SPDisplaysDataType -json)
|
||||||
resolution=$(echo "$output" | jq -r '.SPDisplaysDataType[0].spdisplays_ndrvs[] | select(.spdisplays_online == "spdisplays_yes") | ._spdisplays_resolution')
|
resolution=$(echo "$output" | jq -r '.SPDisplaysDataType[0].spdisplays_ndrvs[] | select(.spdisplays_online == "spdisplays_yes") | ._spdisplays_resolution')
|
||||||
width=$(echo "$resolution" | jq -Rr 'split(" x ")[0]')
|
width=$(echo "$resolution" | jq -Rr 'match("(\\d+) x (\\d+)").captures[0].string')
|
||||||
half_width=$(($width / 2))
|
half_width=$(($width / 2))
|
||||||
height=$(echo "$resolution" | jq -Rr 'split(" x ")[1]')
|
height=$(echo "$resolution" | jq -Rr 'match("(\\d+) x (\\d+)").captures[1].string')
|
||||||
y=0
|
y=0
|
||||||
|
|
||||||
echo "Width: $width"
|
echo "Width: $width"
|
||||||
|
Loading…
Reference in New Issue
Block a user