If you want to keep such command line utilities for future use, package them with Composer and install/store them in /usr/local/bin . I have several such binaries that I package together and push to all computers when the machines are initially deployed, then invoke them in policies as needed. This would also save bandwidth and protect against the github download being removed, which is nigh inevitable.
Good point. I do have a package that does this in a similar fashion. The github thing would definitely be an issue in the future tho, Ima rewrite this a bit.
One other thing. I see a lot of people do this in scripts, but it's not necessary to cd
into a location, and then do a curl for a file. You can direct curl to download a file direct to a location without first cd'ing into the directory. For example
curl -L "https://github.com/fcanas/mirror-displays/releases/download/1.0/MirrorTool.zip" > "/Library/Application Support/JAMF/tmp/MirrorTool.zip"
sleep 2
unzip "/Library/Application Support/JAMF/tmp/MirrorTool.zip" -d "/Library/Application Support/JAMF/tmp/"
sleep 0.5
It's a minor thing, but just wanted to point it out as it avoids an unnecessary step in the overall sequence. It also means you can download a zip to one location and extract it to some other location, using the -d
flag as shown above. Example:
curl -L "https://github.com/fcanas/mirror-displays/releases/download/1.0/MirrorTool.zip" > /private/tmp/MirrorTool.zip
unzip /private/tmp/MirrorTool.zip -d "/Library/Application Support/JAMF/bin/"
I really like the use of Self-Service. This is a great way to get attention there!
That said, part of me wonders if that's the best way to help them. Mirroring displays is a routine, near-daily task for some. It's also very simple. Not only is it the very first selection available from the 'displays menu item' (when connected to a display) it also has a simple shortcut (command+f1).
Anyways, good work!
** I am being reminded that some alternative keyboard layouts may require the use of the (option+command+f1)
@Chris_Hafner Thanks for checking out the code! Actually I totally know what you mean as it is such a basic task to just go in there and switch it. But since a lot of our professors are old...(no way to put it better) they really don't how to do it and don't really want to learn. Also doesn't help that our buildings are mainly PC houses. So when they have to walk in to to a mac based room they are just confused with looking at a Mac.
Also good point. I was gonna make a basic script where clicking an app would just call the keyboard shortcut and do the mirror swap, but apparently mac doesn't allow the Command button to be inputted into bash/terminal. Sucks.
@mm2270 Thanks for pointing that out. I need to rewrite it a bit because I want to avoid downloading from the internet and have it locally depend on our servers...in case github decides to delete that mirrortool.zip file.
Yes, totally understood. And I agree that pulling the executable down and packaging it up for deployment is the way to go. Github links sometimes break, projects get moved, etc.
As for keyboard shortcuts and all that, it IS possible to do Command + <something> calls, but it requires AppleScript to do it. And you may run into accessibility problems now that the OS tries to block those kinds of things until they are manually approved. So not really the way to go there unfortunately.
@mm2270 I totally ran into that problem, when I also tried applecripting this but it would force me to enable it in accessibility. Why apple -.-.
@Corellana I totally understand! Nice work!
If Fabian Canas is out there: Please update w/64-bit (I get a "bad CPU type in executable:" error in Catalina).
@dstranathan I sent him a message through Twitter, let's see what he says.
@dstranathan Be sure you're using 1.2 version. He pointed out I was still using the older 1.02 version. Duh moment for me. lol Good luck!