I need to query the DeviceID of each connected monitor on Mac OS X Leopard & Snow Leopard. is this possible to do using bash? if not what would be the best approach?
would this be stored in a preference file anywhere?
i tried accessing the system_profiler info but it does not look like the device id is included for the monitors.
any help would be greatly appreciated...
Thanks!
You can find here How to Get the Display Name with the Display ID in Mac OS X? one small C program. You can compile it, and when you run it will show Device ID.
For example, for my notebook will return:
Color LCD : 69677760
it is decimal number, when you convert it to hexadecimal
echo 69677760 16 o p | dc
will return the 42732C0 hex-number what is the last part of Device ID from the colorsync.
Related
I'm using a 14 inch M1 Pro Macbook Pro, running Mac OS Monterey 12.6.
I'm making an OpenCV and Mediapipe based Computer Vision Project that allows me to use hand detection to control my Mac's volume. The code detects the distance between the tips of my index finger and thumb using the webcam, and changes the volume based on that. I've been trying to use osascript to set the volume:
osascript.osascript("set volume output volume 0")
It works, but only for hard coded values like 0, 5 and 10. How do I pass a variable value N to osascript:
osascript.osascript("set volume output volume N")
If I could pass that variable value, then I could actually vary the volume instead of having it set at either 0, 5 or 10. The documentation hasn't been very helpful, anybody have any ideas or alternatives instead of osascript?
I've tried applescript but couldn't figure it out.
I'm guessing you are actually using Python, though you don't mention it in the question or in your tags.
If so, you can use an "f-string" like this - note the f at the start:
N = 7
osascript.osascript(f"set volume output volume {N}")
Use command
osascript -e "set Volume 10"
or use python library driver_controler https://github.com/Alexandro1112/driver-controller
I have two Big Sur laptops, one is Intel and other is M1(MacBook Pro M1), when I run command "ioreg | grep -i iodisplayconnect", the Intel one still has it, but M1 system found nothing, anyone know its replacement in M1 Big Sur? I need it to detect display names
I had the same question, but I was looking for IODisplayConnect for the purposes of reading the display brightness.
On a M1 Mac with Big Sur, I found the easiest way to get the brightness info is by running corebrightnessdiag:
$ /usr/libexec/corebrightnessdiag status-info | grep 'DisplayServicesBrightness '
DisplayServicesBrightness = "0.9302966";
To get and set brightness from code, you can use private APIs from the DisplayServices framework (/System/Library/PrivateFrameworks/DisplayServices.framework):
extern int DisplayServicesGetBrightness(int display, float *brightness);
extern int DisplayServicesSetBrightness(int display, float brightness);
// Change brightness
float brightness = 0.8;
int err = DisplayServicesSetBrightness(1, brightness);
// Get current brightness
err = DisplayServicesGetBrightness(1, &brightness);
Looks like NSScreen is the answer, not perfect since couldn't get other informaiton
I found this question about what's the maximum PID for Linux and my question is exactly the same for OSX :
OSX doesn't seem to have the /proc/sys/kernel/pid_max file containing this value on Linux.
Is there an equivalent file or an other way to find out what is the range of PIDs on an OSX system?
The maximum PID on macOS is 99998.
Unlike on Linux, this value is not tunable. I'm not aware of any way to retrieve it in a program; the only assumption you should make is that the value of a process ID will fit into the pid_t type.
in our college project, the following call is made:
sem_t *handle = sem_open("/6770::BitCompressedVector::allocate", 512, 420, 1);
As the title says, errno is set to ENAMETOOLONG, indicating that the first parameter (name) either exceeds PATH_MAX (1024 characters), or a pathname component exceeds NAME_MAX (255 characters).
The binary is executed in a 62 characters long path. Reducing the path length to 14 characters didn't help. When using "/6770::B::a", everything is fine. But this is no solution to us.
I'm using Mac OS X 10.6.6 with an HFS+ volume and the Xcode developer toolset 3.2.6. On my team mates MacBooks (Mac OS X 10.6.x, HFS+) and our Ubuntu 10.10 ext4 systems, the code works without errors.
What's the reason for the different behaviour on my system? Is there a workaround that does not need a change to the code?
The Os X man page for sem_open states:
[ENAMETOOLONG] name exceeded SEM_NAME_LEN characters.
I don't have that OS, but google seems to indicate that SEM_NAME_LEN would be 31.
My program reads device paths like /dev/rdisk0 from input and then it looks in IOKit for a disk with the BSD name disk0. For this I have to remove /dev/r from the path.
Hard coding this path can break in future versions of Mac OS X. Therefore I though of another way: I could match the IOService using the BSD Major and Minor version of the device.
Here's my question: Is it possible to extract the BSD minor and major numbers from a path?
Yes. Use the stat syscall. The member of struct stat you are looking for is st_dev, which I believe is an OR of major and minor after a bit shift.