3 # v4l2-settings-save.sh - save v4l2 device settings
5 # Copyright (C) 2018 Antonio Ospite <ao2@ao2.it>
7 # This program is free software. It comes without any warranty, to
8 # the extent permitted by applicable law. You can redistribute it
9 # and/or modify it under the terms of the Do What The Fuck You Want
10 # To Public License, Version 2, as published by Sam Hocevar. See
11 # http://sam.zoy.org/wtfpl/COPYING for more details.
13 [ "$DEBUG" = "true" ] && set -x
16 [ -e "$1" ] || { echo "usage: $(basename "$0") <videodev>" 1>&2; exit 1; }
21 [ -f /etc/default/v4l2-persistent-settings ] && . /etc/default/v4l2-persistent-settings
23 : "${ID_V4L_PRODUCT:=$(v4l2-ctl -d "$DEVNAME" --info | grep "Card type" | cut -d ':' -f 2 | sed 's/^[[:space:]]//' | tr -d '\n')}"
25 SETTINGS_FILE="${SETTINGS_DIR}/${ID_V4L_PRODUCT}.conf"
27 # Save the latest settings.
28 v4l2-ctl -d "$DEVNAME" -l | sed -n '/^[[:space:]]/s/^[[:space:]]*\([^[:space:]]*\).*value=\([^[:space:]]*\).*$/\1 \2/p' > "$SETTINGS_FILE"