users/ryan/modules/simple-bar/simple-bar-source/lib/scripts/init-aerospace.sh

cabf188ae487120d4b9ac1fe21fff45403a787b4 · 874 B · 26 lines raw

1 # Store the first argument passed to the script in the variable aerospace_path
2 aerospace_path=$1
3
4 # Get the status of System Integrity Protection (SIP) and store it in the variable SIP
5 SIP=$(csrutil status)
6
7 # List monitors using the aerospace tool, format the output as JSON, and store it in the variable displays
8 # Redirect any error output to /dev/null
9 displays=$($aerospace_path list-monitors --json --format "%{monitor-id} %{monitor-name} %{monitor-appkit-nsscreen-screens-id}" 2> /dev/null)
10
11 # Check if the previous command failed (exit status 1)
12 if [ $? -eq 1 ]; then
13 # Print "aerospaceError" and exit the script with status 0
14 echo "aerospaceError"
15 exit 0
16 fi
17
18 # Print a JSON object containing the displays information, SIP status, and a shadow property set to true
19 echo $(cat <<-EOF
20 {
21 "displays": $displays,
22 "SIP": "$SIP",
23 "shadow": true
24 }
25 EOF
26 )