- First install
sudo apt install libheif-examples
- Then run in correct directory
for p in *.heic; heif-convert $p (basename $p .heic)".jpg"; end
I have simple bash script that starts lots of processes. If one fails I want to stop everything. There maybe a better way to do this but I came up with this.
First create two scripts to test our main script. good_sleep
that sleeps for 10 seconds and exits with no error.
#!/bin/bash
echo " good sleeping"
sleep 10
echo "done"
Apply a cube LUT to mpv playback
mpv -vf=lut3d=XT4_FLog_FGamut_to_ETERNA_BT.709_33grid_V.1.01.cube FILE.MOV
or
celluloid --mpv--vf=lut3d=XT4_FLog_FGamut_to_ETERNA_BT.709_33grid_V.1.01.cube FILE.MOV
Linux mint has a few annoyances when using dual monitors. First fixing the log in screen. By default, it uses the same resolution as the primary monitor in the secondary screen. My secondary monitor is much larger so it doesn't display correctly. It's only cosmentic but it annoys me.
Create or append the file /etc/lightdm/lightdm.conf.d/70-linuxmint.conf
so that it has the lines
[SeatDefaults]
user-session=cinnamon
display-setup-script=/usr/bin/lightdmxrandr.sh
- Start the v4l2loopback module:
sudo modprobe v4l2loopback \
devices=1 exclusive_caps=1 video_nr=5 card_label="Dummy Camera"
- This creates one device with a label "Dummy Camera" as device `/dev/video5
- See https://github.com/umlaeute/v4l2loopback/ for more detailts
- I have a short test video call
Speed1.avi
, this can be played streamed to/dev/video5
withffmpeg -re -stream_loop -1 -i Speed1.avi -vcodec rawvideo -pix_fmt yuv420p -f v4l2 /dev/video5
It's actually fairly easy to control Home Assistant remotely using curl
but I couldn't find a complete solution on how to do this, so here goes...
- Activate the api in
configuration.yaml
by adding the lineapi:
- Get an Authorization token from HA (It's a Long-Lived Access Tokens which can be created on your HA user profile page)
- This list of exposed states can be found using
curl -X GET -H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" http://YOUR_IP:8123/api/states | prettyjson
- Note
prettyjson
is an alias forpython -m json.tool
, you don't need this it's just easier to read.
- To get the state of a device append the entity.id to the URL, eg
curl -X GET -H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" http://YOUR_IP:8123/api/states/switch.mylight | prettyjson
- The API documentation shows you how to change the states but this does not actually turn on the lights, etc. Instead, us
# my conversion of Goodman's code | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# Program for simulating Speckle Formation by Free Space Propagation | |
# Translate from Mathematica | |
# Ref: Goodman, Joseph W. 2020. Speckle Phenomena in Optics: Theory and Applications, Second Edition. SPIE. | |
n = 1024 # nxn array size |
- Stop the old service if it is running with
sudo service squeezelite stop
- Remove the old version if installed with
sudo apt-get remove squeezelite
- Install its dependancies
sudo apt-get install lsb-base libasound2 libavcodec57 libavcodec-extra57 libavformat57 libavutil55 libc6 libfaad2 libflac8 liblirc-client0 libmad0 libmpg123-0 libsoxr0 libvorbisfile3
- Create a directory to download the source files in your home drive
mkdir sources; cd sources
- Clone the source code
git clone https://github.com/ralph-irving/squeezelite.git
cd squeezelite
sudo apt-get install libavcodec-dev libavformat-dev
sudo apt-get install libsoxr-lsr0 libsox-dev sox libsoxr-dev
- Build it with
make all OPTS="-DDSD -DRESAMPLE -DFFMPEG"
sudo cp squeezelite /usr/bin/.
to copy the file to you path
Loguru is my favorite way to perform logging in python. It's generally so simple to use but a few things are missing from the documentation.
This is based on the loguru example, but also includes the hostname of the sender. To add extra fields the pefered method is to add to record["extra"]
dictionary (which is normally empty). The client code sends the log messages over the network and to stderr
.
class LoggingSocketHandler:
def __init__(self, host, port, timeout=600):