I would like to know if it is possible to get the battery level of a connected Bluetooth device (for example, a headset) on Mac OSX.
I'm looking for a command line or a library that would offer this possibility.
Thanks.
There is no easy way to get this information without special application.
There is an app especially designed for this only purpose - called AKKU.
It worked with Bose and Sony's headphones (checked)
https://github.com/jariz/Akku/
Remember to download version 0.1.0-beta.10.
The app works after restart.
Just follow this guide: http://osxdaily.com/2014/05/18/how-to-check-bluetooth-keyboard-battery-levels-from-the-command-line-on-mac-os-x/
Basically:
You just need to know the name of the device and then use ioreg, like this:
ioreg -c <devicename> |grep '"BatteryPercent" ='
Additionally, you could retrieve broader battery information with:
ioreg -c BeatsBluetoothHeadset |grep Battery
Next time, just google ... Since a similar question was already answered https://apple.stackexchange.com/questions/215256/check-the-battery-level-of-connected-bluetooth-headphones-from-the-command-line
Related
I'm using Ruby 1.8 and linux (Ubuntu and SLAX), and i need to write a script in ruby which finds out if some specific usb device is connected to the system and on which USB port (0,1,2, etc). It was done before with the help of HAL (hal-find-by-capability --capability serial), but now i can't use this approach. I was trying to read /var/log/messages file trying to find the number of the usb port, but it appears that this number may not be written in some systems. Other thing i tried is to check /dev folder and search for ttyUSB# file, but it doesn't appear on some system when new device connects to USB.
I would appreciate any ideas how to do this.
lsusb is a linux command for displaying your usb hubs and listing the devices that are connected to them. In ruby I believe you'd be able to do something like this:
ls_results = `lsusb`
You should be able to parse that for whatever device you're looking for.
I'm sorry that I couldn't provide you an ruby sample. I had the same problem in C / C++ (QT). You can find my snippet here:
http://www.known-issues.net/cpp/how-to-detect-if-dev-is-a-usb-device.html
You have libusb ruby bindings which allow to control usb devices.
In my Mac OS X application, I would like to log the user's graphics card driver and model. What is the appropriate API to use?
I've not been able to find an API to find this information, but you can get some information about the display hardware by running the following command:
/usr/sbin/system_profiler SPDisplaysDataType
Using dtruss that command appears to be doing something with executable code in /System/Library/SystemProfiler/SPDisplaysReporter.spreporter/Contents/MacOS/SPDisplaysReporter, but it's a bit hard to tell what exactly.
Do you want to get the the Graphics Card Driver and Model provided by IORegistryExploer, an application showing the hierarchies about the Devices and Drivers?
If so, you may use command ioreg -l in the terminal, and then filter the information you need.
Of course, how execute shell command in your application is another question, you may use the API provided by Cocoa, NSTask, or use the system() function.
In Windows, it is possible to view a Power tab for a USB hub in Device Manager that lists information such as whether the hub is self-powered and the total power available.
Is this information available programatically, either in Windows (perhaps WMI?) or Linux? I've looked in MSDN with little success so far.
Linux:
lsusb -v | grep MaxPower
I think WMI is going to be your best bet here. I'm not familar with exactly what you want, but I'd start with the Win32_VoltageProbe class.
How can I retrieve the information shown in the Mac's System Profiler app programatically? I'm actually interested in the USB section if that matters.
The OSX command line tool "ioreg" might give you want you want.
man ioreg
ioreg displays the I/O Kit registry. It shows the heirarchical registry as an inverted tree.
Also if you can/want to use Cocoa look at IOKit. IOKit is the OSX framework that talks to USB hardware.
Take a look at the system_profiler(8) command.
How does one go about creating a virtual CD driver on Mac OS X programatically?
I can't find any relevant Cocoa APIs or any pure C BSD solutions.
Any help or information is appreciated.
You would need to use the I/O Kit framework to develop your own device driver that would emulate a virtual CD drive. Here are some links to the relevant APIs to get you started.
I/O Kit Fundamentals
I/O Kit Device Driver Guidelines
Kernel Extension Programming Topics
There are several different answers people have proposed here. The issue at hand is what are you trying to accomplish. If you really want to emulate a CD ROM (down to the commandset) you will need to write a device driver. If your goal is merely to emulate a block device with contents similiar to a CD you can create a disk image using disk utility and let the builtin disk image driver handle it for you.
MacFUSE is useful if you want to present some sort of custom filesystem functionality, but if what you are looking for is something that has the same semantics as an optical disc (whether that is and block or command set level) it is the wrong tool.
If you're simply looking to mount an ISO or something then it's done through the Disk Utility, simply drag it into the side-bar and then select it and choose mount.
If you want to do it from code you can issue the hdiutil command, as shown here. I'm not sure if there's an API call to do it, but getting that command to do the work is quite painless.
The simplest way to mount a custom volume is MacFUSE. It handles the IOKit details for you and lets you write the implementation in user space. However, I don’t think you can make a MacFUSE “look like” a CD; you’d have to modify FUSE to achieve that.
I had a nosey around DAEMON Tools for Mac's driver:
/Library/Extensions/DAEMONToolsVirtualSCSIBus.kext/Contents/MacOS/DAEMONToolsVirtualSCSIBus
I disassembled the binary using Hopper and discovered they are using
IOSCSIProtocolServices.