1

What terminal command can I use to terminate the cursor/mouse process on a MacOSX?

I'm changing the size of the mouse using another command in the terminal and now I need to restart the process that displays the cursor. I have searched for hours for a similar topic, but couldn't find one.

Does anybody know how to achieve this?

eeschimosu
  • 633
  • 2
  • 10
  • 24

1 Answers1

0

If by "changing the size of the mouse using another command in the terminal", you mean that you set the System Preferences value (i.e. using 'defaults' command), then you could either log out and log back in, or it may be a bit tedious -- see this answer: How to programatically change the cursor size on a Mac

If all you need to do is to change a mouse cursor size system-wide, you can use UI scripting (as suggested in the answer I linked). The command to execute would be:

osascript -e '
tell application "System Preferences"
    reveal anchor "Seeing_Display" of pane id "com.apple.preference.universalaccess"
end tell
tell application "System Events"
    set theSlider to slider "Cursor size:" of group 1 of window 1 of application process "System Preferences"
    set stash to value of theSlider
    set value of theSlider to SIZE_OF_THE_CURSOR
    stash
end tell'

Note that you need to "enable assistive access" to osascript:

http://jacobsalmela.com/bash-script-enable-access-assistive-devices-programmatically-os-x-mavericks-10-9-x-simulate-keystrokes/

"is not allowed for assistive access" error when running AppleScript from Java

Community
  • 1
  • 1
tomtau
  • 126
  • 6
  • I change the 'defaults' command programmatically in cocoa code. Now I would like to kill the mouse process programmatically in cocoa code. I can run a terminal command from code so I was wandering what command should I run. I require the assistive access before doing all this. I cannot use a script to achieve this. – eeschimosu Apr 02 '16 at 07:43
  • You can run AppleScript from Cocoa: https://gist.github.com/kaydell/6189741 Anyway, the final thing you want, if I understand correctly, is that the mouse cursor size visibly changes -- in which case, there is no need to kill any process. I recommend reading the answer I linked which goes into detail about this: http://stackoverflow.com/questions/14510870/how-to-programatically-change-the-cursor-size-on-a-mac – tomtau Apr 02 '16 at 12:58
  • I've followed that answer, but it didn't work. That is why I am searching for different methods to achieve my goals. Thanks a lot for your interest in this topic! I appreciate it! :D – eeschimosu Apr 02 '16 at 19:22
  • Where did it fail? When I tried the AppleScript from the linked answer, I had to change the name of the slider to "Cursor size:" (lowercase 's') + the per-app enabling assistive access on OS X 10.11.4. – tomtau Apr 03 '16 at 01:11
  • It works, but it opens the preferences pane every time it runs. I would like to be able to use the script without the user to see the preferences opening. Can it be done in the background, without opening the preferences pane? – eeschimosu Apr 03 '16 at 18:49
  • Also I would like to give assistive permissions just to the app itself and not to a script also. – eeschimosu Apr 03 '16 at 20:20
  • If you don't want the preferences pane in the foreground, you can use `set visible to false` to hide it. In recent OS X, the permissions are at a per-app granularity, so you'd need to give them to `/usr/bin/osascript` separately. This tool may help you: https://github.com/jacobsalmela/tccutil – tomtau Apr 04 '16 at 11:20