Categories
Computer science programming utilities

Controlling the Logitech Litra on MacOS

Recently I bought a USB-C connected diffused light for Zoom calls, the Logitech Litra Glow. The hardware is excellent, but the control software, Logitech GHub, is horrible. Intrusive permissions, auto start, auto updater, laggy UI, just a hard no. The light has buttons on the back to control it, but since mine is next to the camera it looks odd when I’m reaching over and let’s face it, I’m a programmer and love solving small problems with code. Let’s find a way.

Some searching found a Linux app on Github, but the USB library for MacOS required sudo access which adds hassle. There’s an issue and discussion on the topic, which led me to hidapitester, which doesn’t require root access to run.

Goals

I want menu bar control, simplified – light on and off, one or two brightness levels. Basically make it easy to use as I hop on and off calls. Here’s what I came up with, hopefully it’s helpful for you too.

Installation and configuration

  1. Install hidapitester
  2. Add shell aliases to control the light
  3. Tweak color temp and brightness values to your liking
  4. Add Shortcuts to drive the shell aliases from the GUI

Install hidapitester

Grab the source or binary from the project GitHub page. Copy it into /usr/local/bin and then, due to app signing requirements, you’ll need to approve its use from the Finder.

open /usr/local/bin

Right click on hidapitester and select Open

On the warning dialog, select Open.

The binary is now flagged as OK; you only have to do this once.

Add shell aliases

The default shell is now zsh so let’s use that. I also use and like oh-my-zsh, so my aliases are in /Users/phubbard/.oh-my-zsh/custom/aliases.zsh

Using the magic payloads from the Github issue, we define a base function _hid that invokes hidapitester with the full path and identifiers. We then build on that to add a selection of color temps and brightness levels.

function _hid() {
  /usr/local/bin/hidapitester --vidpid 046D/C900 --open --length 20 --send-output $1
}
# 2/17/22 Litra Glow aliases from https://github.com/kharyam/litra-driver/issues/13
function light() {
  _hid 0x11,0xff,0x04,0x1c,0x01
}
function dark() {
  _hid 0x11,0xff,0x04,0x1c
}
# ~10%
function glow(){
  _hid 0x11,0xff,0x04,0x4c,0x00,20
}
# ~20%
function dim(){
  _hid 0x11,0xff,0x04,0x4c,0x00,50
}
# tweaking by hand - less than 50%
function normal() {
  _hid 0x11,0xff,0x04,0x4c,0x00,70
}
# ~50%
function medium() {
  _hid 0x11,0xff,0x04,0x4c,0x00,100
}
# 90%
function bright(){
  _hid 0x11,0xff,0x04,0x4c,0x00,204
}
# 2700K
function warmest() {
  _hid 0x11,0xff,0x04,0x9c,10,140
}
# 3200K
function warm() {
  _hid 0x11,0xff,0x04,0x9c,12,128
}
# 6500K
function coldest() {
  _hid 0x11,0xff,0x04,0x9c,25,100
}

You should be able to run any of these from zsh:

exec zsh
light
dark

That might be all you need/want. If so, enjoy!

Add Shortcuts

There’s a few key things to know in order to make this work:

  • You can invoke a shell script or alias by using the Terminal app from Shortcuts
  • You don’t get a login shell, so we need to manually load the aliases for this to work.
  • We also need to use full paths, since the non-login shell has a different PATH set.
  • Once the aliases are loaded, we can chain calls using the && operator.
  • Under the Shortcuts setting, there’s a checkbox for ‘Pin in Menu Bar’ that exposes the Shortcut to your GUI.

Looks like this on the menu bar:

I use these three:

source /Users/phubbard/.oh-my-zsh/custom/aliases.zsh && light && warmest && dim
source /Users/phubbard/.oh-my-zsh/custom/aliases.zsh && dark
source /Users/phubbard/.oh-my-zsh/custom/aliases.zsh && light && warmest && normal

I hope that others find this useful. I’m happy with the result as the code runs in a second or so and has yet to fail.

Litra Beam

A reader tells me that this code also works with the newer Litra Beam if you change the USB IDs in the _hid routine to 046D/C901. Thanks, John!

Categories
recommendations

Today I learned the iPhone’s excellent document scanner can be controlled from a Mac – The Verge

Cool trick – as they say, no wires required, and I just tried it out to import a receipt for reimbursement. Works really well.

https://www.theverge.com/2021/3/1/22306875/apple-continuity-camera-ios-ipados-document-scanner-macos-mojave