Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Step Alpha: Set up mic check and game tracking variables
- set windowTitles to {"Ready or Not on GeForce NOW", "Fortnite® on GeForce NOW", "S.T.A.L.K.E.R. 2: Heart of Chornobyl on GeForce NOW"}
- set profileNames to {"Ready Or Not", "Fortnite", "Stalker 2"}
- set gameCheck to false
- set targetWindow to ""
- -- Check if yabai is running
- set yabaiStatus to do shell script "pgrep -x yabai > /dev/null && echo running || echo stopped"
- log "Yabai Status: " & yabaiStatus
- if yabaiStatus is "stopped" then
- log "Starting yabai service..."
- do shell script "/opt/homebrew/bin/yabai --start-service"
- delay 1 -- Ensure yabai has time to start
- end if
- -- Step 4: Monitor GeForceNOW process
- repeat
- delay 1
- try
- set isRunning to (do shell script "pgrep -x 'GeForceNOW' > /dev/null && echo true || echo false")
- log "GeForceNOW Running: " & isRunning
- if isRunning = "false" then
- set gameCheck to false
- log "Game Check Reset: GeForceNOW closed."
- exit repeat
- end if
- -- If no game is detected, check open windows
- if gameCheck is false then
- log "Checking for game windows..."
- set windowList to do shell script "/opt/homebrew/bin/yabai -m query --windows | /usr/bin/jq -r '.[].title'"
- log "Window List: " & windowList
- set foundTitles to paragraphs of windowList
- repeat with i from 1 to count of windowTitles
- set currentWindow to item i of windowTitles
- log "Checking window: " & currentWindow
- if currentWindow is in foundTitles then
- set targetWindow to currentWindow
- set profile to item i of profileNames
- log "Game detected: " & profile
- do shell script "osascript -e 'say \"" & profile & " detected, switching profile\"' &>/dev/null &"
- do shell script "echo 'echo -n \"" & profile & "\" | /usr/bin/nc -U /tmp/swiftpoint.x1.profileswitch' | /bin/bash"
- set gameCheck to true
- exit repeat
- end if
- end repeat
- end if
- -- Monitor the game window
- if gameCheck is true then
- set retryCount to 2 -- Number of times to check before assuming the window is closed
- set isWindowOpen to "false"
- repeat with attempt from 1 to retryCount
- set isWindowOpen to (do shell script "/opt/homebrew/bin/yabai -m query --windows | grep -q '\"title\":\"" & targetWindow & "\"' && echo true || echo false")
- -- Exit the loop early if the window is still open
- if isWindowOpen is "true" then exit repeat
- -- Wait 1 second before retrying
- delay 1
- end repeat
- -- If the window is still missing after retries, reset the profile
- if isWindowOpen is "false" then
- do shell script "osascript -e 'say \"Game session ended, resetting zee two profile to Desktop.\"' &>/dev/null &"
- do shell script "echo 'echo -n \"Desktop\" | /usr/bin/nc -U /tmp/swiftpoint.x1.profileswitch' | /bin/bash"
- set gameCheck to false
- end if
- end if
- on error errMsg
- display dialog "Error checking GeForceNOW status: " & errMsg
- exit repeat
- end try
- end repeat
- -- Step 7: Reset Z2 Profile
- log "Resetting Z2 Profile..."
- do shell script "osascript -e 'say \"Default Desktop Zee two profile has been set. G G\"' &>/dev/null &"
- do shell script "echo 'echo -n \"Desktop\" | /usr/bin/nc -U /tmp/swiftpoint.x1.profileswitch' | /bin/bash"
- -- Step 8: Stop yabai service
- log "Stopping yabai service..."
- do shell script "/opt/homebrew/bin/yabai --stop-service"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement