3 # v4l2-settings-restore.sh - restore 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 # NOTE: this script is meant to be called by an udev rule.
15 [ "$DEBUG" = "true" ] && set -x
18 source /etc/default/v4l2-persistent-settings || :
20 : "${SETTINGS_DIR:=/tmp}"
22 SETTINGS_FILE="${SETTINGS_DIR}/${ID_V4L_PRODUCT}.conf"
24 if [ "$ACTION" = "add" ] && [ -f "$SETTINGS_FILE" ];
26 while read -r setting;
28 CTRL=$(echo -n "$setting" | cut -d ' ' -f 1)
29 VAL=$(echo -n "$setting" | cut -d ' ' -f 2)
30 v4l2-ctl -d "$DEVNAME" --set-ctrl "${CTRL}=${VAL}"
31 done < "$SETTINGS_FILE"