Skip to content

Instantly share code, notes, and snippets.

@replaid
Created July 8, 2020 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save replaid/fd90ef14ecc13b0c470c491bd5823438 to your computer and use it in GitHub Desktop.
Save replaid/fd90ef14ecc13b0c470c491bd5823438 to your computer and use it in GitHub Desktop.
Give Zenity foreground on macOS
#!/usr/bin/env bash
zenity --password &
zenity_pid=$!
osascript<<EOF
tell application "System Events"
set processList to every process whose unix id is $zenity_pid
repeat with proc in processList
set the frontmost of proc to true
end repeat
end tell
EOF
# Can't use fg by default, that's for interactive shells.
# But this waits for all background processes to finish.
wait
@replaid
Copy link
Author

replaid commented Jul 8, 2020

Probably can achieve everything through just the osascript command without all the GTK stuff anyway. This project is one example but all this could be rolled in shell/etc. plus osascript.

https://github.com/ncruces/zenity

@replaid
Copy link
Author

replaid commented Jul 8, 2020

All this was inspired by withfig.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment