Using Luxafor with Linux

Luxafor makes a nice busy status indicator light for the office. Unfortunately it only provides software for Windows and Mac. But it’s not hard at all to get it working on Ubuntu with PyUSB.

1- You need PyUSB installed

pip install pyusb

2- PyUSB basically lets you do anything you want with the USB device including some pretty dangerous stuff so it’s naturally open to super users. It’d be really annoying to have to sudo every light control though, so we’ll open this one particular device to your user. Create a luxafor.rules file in /etc/udev/rules.d/ and put in:

SUBSYSTEM=="usb", ATTR{idVendor}=="04d8", ATTR{idProduct}=="f372" MODE="0664", OWNER="[your user name]"

3- Reload udev with

sudo udevadm control --reload
sudo udevadm trigger

4- Create a Python script, say, to make this easier to control

import argparse
import usb.core
def main():
parser = argparse.ArgumentParser(description='Change Luxafor colour')
parser.add_argument('colour', choices=['green', 'yellow', 'red', 'blue', 'white', 'off'], help='colour to change to')
args = parser.parse_args()
colour_codes = {'green': 71, 'yellow': 89, 'red': 82, 'blue':66, 'white': 87, 'off': 79}
dev = usb.core.find(idVendor=0x04d8, idProduct=0xf372)
if dev is None:
print('Not connected')
except usb.core.USBError:
except usb.core.USBError:
print("Did you give Luxafor USB permission to your user?")
dev.write(1, [0, 0])
dev.write(1, [0, colour_codes[args.colour]])
if __name__ == '__main__':

5- Control the colour with

python green