Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find the location of the Dock programmatically?

Is there a way in code to find out if the Dock on a Mac is located on the bottom, left, or right side of the user's monitor?

like image 612
Michael Wildermuth Avatar asked Oct 10 '11 18:10

Michael Wildermuth


3 Answers

NSScreen has visibleFrame method, wich returns a rect that doesn't include the area currently occupied by the dock and menu bar. You can compare this rect with the full screen rect(- (NSRect) [NSScreen* frame]) and determine the dock location.

like image 77
VenoMKO Avatar answered Nov 16 '22 23:11

VenoMKO


This is probably simpler…

defaults read com.apple.dock "orientation"

bottom

You can also find out.. autohide (i.e. 1), large size (i.e. "65.48148") and magnification (i.e. 1), etc.

like image 6
Alex Gray Avatar answered Nov 16 '22 23:11

Alex Gray


private discovered API used by prefs panel

typedef enum {
  kCoreDockOrientationTop = 1,
  kCoreDockOrientationBottom = 2,
  kCoreDockOrientationLeft = 3,
  kCoreDockOrientationRight = 4
} CoreDockOrientation;

extern void CoreDockGetOrientationAndPinning(CoreDockOrientation *outOrientation, CoreDockPinning *outPinning);
// If you only want to set one, use 0 for the other.
extern void CoreDockSetOrientationAndPinning(CoreDockOrientation orientation, CoreDockPinning pinning);
like image 1
diimdeep Avatar answered Nov 16 '22 22:11

diimdeep