Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env osascript
- # -*- tab-width: 4 -*- ;; Emacs
- # vi: set ts=4 sw=4 noet ft=applescript :: Vi/ViM
- #-
- ############################################################ IDENT(1)
- #
- # $Title: AppleScript to launch imunes remotely via X11Forward $
- # $Copyright: 2019-2022 Devin Teske. All rights reserved. $
- # $FrauBSD$
- #
- ############################################################ CONFIGURATION
- #
- # qmon host
- #
- property imunesHost : "hostname"
- ############################################################ FUNCTIONS
- on replaceString(theText, oldString, newString)
- local ASTID, theText, oldString, newString, lst
- set ASTID to AppleScript's text item delimiters
- try
- considering case
- set AppleScript's text item delimiters to oldString
- set lst to every text item of theText
- set AppleScript's text item delimiters to newString
- set theText to lst as string
- end considering
- set AppleScript's text item delimiters to ASTID
- return theText
- on error eMsg number eNum
- set AppleScript's text item delimiters to ASTID
- error "Can't replaceString: " & eMsg number eNum
- end try
- end replaceString
- on shellCmd(shellText)
- # Replace tabs in shellText with spaces
- replaceString(shellText, " ", " ")
- # Join lines
- replaceString(result, linefeed, "")
- tell application "Terminal" to do script result
- end shellCmd
- ############################################################ MAIN
- on run
- tell application "XQuartz" to run
- #
- # Perform X11 forwarding with ssh(8) to the qmon server and then run qmon
- #
- shellCmd("
- xhost + || : errors ignored
- ssh -Yf " & imunesHost & " '
- imunes;
- exit;
- ';
- exit;
- ")
- end run
- ################################################################################
- # END
- ################################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement