Posted on 05-07-2015 09:28 AM
I need some help writing a script to push out to student machines. We are trying to disable Expose/Mission Control/Spaces. I know there are a few other threads on this topic using config profiles, but I was looking for a script to push out as well with Casper Remote to add to our arsenal. I can go to a student machine, open terminal and run these commands:
defaults write com.apple.dock mcx-expose-disabled -bool TRUE
defaults write com.apple.dashboard mcx-disabled -boolean YES
killall Dock
Doing so disables what we need disabled. I tried to turn it into a script for Casper Remote as follows:
#!/bin/sh
defaults write com.apple.dock mcx-expose-disabled -bool TRUE
defaults write com.apple.dashboard mcx-disabled -boolean YES
killall Dock
Remotely pushing this out does not work though. I also tried adding a sudo to the first line with no luck. I'm guessing this needs to be pushed out at the user level. We use a couple of different generic accounts. I'm not sure how to write the script for each account. I may be going about this the wrong way. Any help or suggestions would be appreciated!
Solved! Go to Solution.
Posted on 05-07-2015 10:00 AM
There are a ton of posts on here on how to do this but here you go ;)
#!/bin/sh
useris=$(ls -l /dev/console | awk -F"1 " '{print $2}' | awk -F" " '{print $1}')
sudo -u "$useris" defaults write com.apple.dock mcx-expose-disabled -bool TRUE
sudo -u "$useris" defaults write com.apple.dashboard mcx-disabled -boolean YES
killall Dock
Posted on 05-07-2015 10:00 AM
There are a ton of posts on here on how to do this but here you go ;)
#!/bin/sh
useris=$(ls -l /dev/console | awk -F"1 " '{print $2}' | awk -F" " '{print $1}')
sudo -u "$useris" defaults write com.apple.dock mcx-expose-disabled -bool TRUE
sudo -u "$useris" defaults write com.apple.dashboard mcx-disabled -boolean YES
killall Dock
Posted on 05-07-2015 10:47 AM
Its almost kind of funny, and sad at the same time, how this topic of "how do I get X to run as the logged in user when doing it out of Casper?" comes up just about every other day on a post here.
This, to me, makes a good case for this Feature Request (which is sadly labeled as Not Planned) It would be nice if JAMF could oblige with something like this though, maybe done in their own style.
I think no-one really minds questions being asked since that's what the forum is about, but topics like these would be awesome to have in a "Common topics" list, or a "Top questions asked" kind of section that new (or old) forum users could go right to. Otherwise these very important topics just get buried on another page in a matter of hours and aren't easily seen unless you know exactly what to search for.
Posted on 05-07-2015 10:59 AM
@mm2270 Totally agreed. At the least they could make it a knowledge base article with a recommended way of doing it that we could just point people to easily with a clear and concise explanation. The only reason I don't usually drop a link to a thread is I feel bad for leaving someone to dig through a bunch of posts in a thread for the right answer. Well, that and I don't really feel like having to do a search for a thread myself with the best concise explanation just to point somebody else to it, since that feels like doing the work for them anyway. Its faster to help them on the thread they posted.
Posted on 05-07-2015 02:26 PM
Thank you for the help!
Posted on 11-10-2015 07:17 AM
What would be the trick to getting this to work in self service or pushed out at login? I can get it to work in a shell script on a computer but when I put it into self service it doesn't seem to work.
Thanks
Posted on 11-16-2015 12:49 PM
You can try taking the script in the post from chriscollins, add it to Casper Admin, then create a policy where it runs that script on startup. I haven't tried this personally. I've been using Casper Remote to push it out when needed.
Posted on 09-27-2016 09:48 AM
Old post but confirmed chriscollins's script runs fine from self service as well as through a trigger on our 10.11 machines.