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
19 [ -f /etc/default/v4l2-persistent-settings ] && . /etc/default/v4l2-persistent-settings
21 SETTINGS_FILE="${SETTINGS_DIR}/${ID_V4L_PRODUCT}.conf"
23 if [ "$ACTION" = "add" ] && [ -f "$SETTINGS_FILE" ];
25 while read -r setting;
27 CTRL=$(echo "$setting" | tr -d '\n' | cut -d ' ' -f 1)
28 VAL=$(echo "$setting" | tr -d '\n' | cut -d ' ' -f 2)
29 v4l2-ctl -d "$DEVNAME" --set-ctrl "${CTRL}=${VAL}"
30 done < "$SETTINGS_FILE"