#hue #light #bar #menu #macos #status-bar #phillips

app menhue

Menu bar interface for Phillips Hue lights

1 unstable release

0.1.0 Aug 29, 2024

#86 in Hardware support

Download history 106/week @ 2024-08-25 6/week @ 2024-09-01

112 downloads per month

MIT/Apache

35KB
701 lines

Menhue - Menu bar interface for Phillips Hue lights

Mostly an open-source clone of https://huemenu.app/, but without the (IMO) excessive polling it does to always be up to date. Starting a request on click is enough to feel interactive.

Very feature-incomplete and work-in-progress, don't actually use this for anything other than inspiration for how to use objc2.

Design decisions

Uses only Cocoa APIs, to get a feel for what that's like.

In a real-world application, I'd strongly recommend serde and serde_json for interacting with JSON data, and reqwest for doing the URL requests.

Future ideas

Notes

Detecting mouseEntered:/mouseExited: for status bar buttons is not possible, even with replacing the class.

Old API docs: https://developers.meethue.com/develop/hue-api/, https://www.burgestrand.se/hue-api/ Developer: https://$HOST/debug/clip.html

State machine WIP

flowchart TD;
  Init-->DataFromCache;

  DataFromCache[Getting data from cache...]
  DataFromCache-- Failure -->LoginDialog;
  DataFromCache-- Success -->MenuReady;

  LoginDialog[[Show login dialog]]
  LoginDialog-- Log in with details -->FetchUser;

  FetchUser[Logging in...]
  FetchUser-- Failure -->LoginDialog;
  FetchUser-- Success -->MenuReady;

  MenuReady[[Menu ready]]
  MenuReady-- On open -->FetchLampStatus;

  FetchLampStatus[Fetching lamp status...]
  FetchLampStatus-- Permission error -->LoginDialog2;
  LoginDialog2[[Show login dialog]]
  FetchLampStatus-- Failure -->MenuOpenWithError;
  FetchLampStatus-- Success -->MenuOpen;

  MenuOpenWithError[[Show error in menu]]
  MenuOpenWithError-- Retry -->FetchLampStatus;
  MenuOpenWithError-- Close -->MenuReady;

  MenuOpen[[Show lamps]]
  MenuOpen-- Edit Lamp -->EditLamp;
  MenuOpen-- Close -->MenuReady;

  EditLamp[Editing lamp...]
  EditLamp-- Permission error -->LoginDialog3;
  LoginDialog3[[Show login dialog]]
  EditLamp-- Failure -->MenuOpenWithError;
  EditLamp-- Success -->MenuOpen;

Dependencies

~6.5MB
~133K SLoC