Turn off Natural Scrolling using a script

HpOfficejetPro
New Contributor

Hello, I am new to jamf and our client is requesting that we automate turning off of Natural Scrolling. I have found a script that when run in terminal works perfect and does not prompt the user for anything. Currently this is what I am using:

#!bin\bash

defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false

When I go to run this through jamf it just fails and does nothing. I'm sure I am missing something but have racked my brain and cannot figure it out. Thanks in advance for the help.

1 ACCEPTED SOLUTION

mdp
Contributor

Testing this out myself, it seems you may have to run it as the user rather than running it as root (as Jamf scripts natively do). So you can try something like this:

#!/bin/bash

loggedInUser=$(stat -f%Su /dev/console)
loggedInUID=$(id -u $loggedInUser)

/bin/launchctl asuser $loggedInUID sudo -iu $loggedInUser defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false

 

---
Matthew Prins -- Jamf Scripts @ Github

View solution in original post

2 REPLIES 2

mdp
Contributor

Testing this out myself, it seems you may have to run it as the user rather than running it as root (as Jamf scripts natively do). So you can try something like this:

#!/bin/bash

loggedInUser=$(stat -f%Su /dev/console)
loggedInUID=$(id -u $loggedInUser)

/bin/launchctl asuser $loggedInUID sudo -iu $loggedInUser defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false

 

---
Matthew Prins -- Jamf Scripts @ Github

moriahitadmin
New Contributor III

Can not really say anything without knowing why script fails. but you can run as a command.

policy > Files and Processes then put 

defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false