MQTT Keyboard

Last Updated or created 2022-04-05

A fancy keyboard….. At last a clickety keyboard. A Razer Blackwidow V3 mechanical keyboard. I’m not a gamer, but i like the clickety sounds. RGB leds are always nice to play with.

One of the nice things about razer is the Linux support!

Some nice links:

https://github.com/openrazer/openrazer

https://openrazer.github.io/

Even several python scripts can be found, but no MQTT.
So made a fast ‘n simple hack to control my keyboard with mqtt/nodered.

When someone is at the frontdoor, my keyboard changes from white to red.

Below a node-red example

My python code:

import paho.mqtt.client as mqttClient
import time
import os
import subprocess
import json

def on_connect(client, userdata, flags, rc):
    if rc == 0:
        print("Connected to broker")
        global Connected
        Connected =True
    else:
        print("Connection failed")

def on_message(client, userdata, message):
    subprocess.Popen(["razer-cli", "-c", message.payload])

Connected = False

broker_address = "your.mqtt.brokerip.here"
port = 1883
#user = "user"
#password = "password"
client = mqttClient.Client("mqttrazer")
#client.username_pw_set(user, password=password)
client.on_connect = on_connect
client.on_message = on_message

client.connect(broker_address, port=port)
client.loop_start()

while Connected != True:
    time.sleep(0.1)

client.subscribe('razer/in')

try:
    while True:
        time.sleep(1)

except KeyboardInterrupt:
    print ("exiting")
    client.disconnect()
    client.loop_stop()

Android / Oculus Quest screen record

Last Updated or created 2022-04-02

Needed a way to record stuff from phone and VR set, found scrcpy.

A really usefull tool, you can control you phone, and what i was looking for .. screen record.

Used this to show via Jitsi screen share, how to do stuff on your phone.

scrcpy –record file.mkv

https://github.com/Genymobile/scrcpy#copy-paste

Switch fullscreen modeMOD+f
Rotate display leftMOD+ (left)
Rotate display rightMOD+ (right)
Resize window to 1:1 (pixel-perfect)MOD+g
Resize window to remove black bordersMOD+w | Double-left-click¹
Click on HOMEMOD+h | Middle-click
Click on BACKMOD+b | Right-click²
Click on APP_SWITCHMOD+s | 4th-click³
Click on MENU (unlock screen)⁴MOD+m
Click on VOLUME_UPMOD+ (up)
Click on VOLUME_DOWNMOD+ (down)
Click on POWERMOD+p
Power onRight-click²
Turn device screen off (keep mirroring)MOD+o
Turn device screen onMOD+Shift+o
Rotate device screenMOD+r
Expand notification panelMOD+n | 5th-click³
Expand settings panelMOD+n+n | Double-5th-click³
Collapse panelsMOD+Shift+n
Copy to clipboard⁵MOD+c
Cut to clipboard⁵MOD+x
Synchronize clipboards and paste⁵MOD+v
Inject computer clipboard textMOD+Shift+v
Enable/disable FPS counter (on stdout)MOD+i
Pinch-to-zoomCtrl+click-and-move
Drag & drop APK fileInstall APK from computer
Drag & drop non-APK filePush file to device