56 lines
1.8 KiB
Plaintext
56 lines
1.8 KiB
Plaintext
_install_sleep_hook() {
|
|
cp /usr/share/intel-ipu7-camera/camera-sleep-hook /usr/lib/systemd/system-sleep/camera-sleep-hook
|
|
chmod 755 /usr/lib/systemd/system-sleep/camera-sleep-hook
|
|
}
|
|
|
|
post_install() {
|
|
_install_sleep_hook
|
|
systemctl daemon-reload
|
|
systemctl enable camera-init.service
|
|
systemctl --global enable camera-feed-watch.service
|
|
udevadm control --reload-rules 2>/dev/null || true
|
|
|
|
if [ -n "$SUDO_USER" ]; then
|
|
usermod -aG video "$SUDO_USER" 2>/dev/null || true
|
|
|
|
# Start the service in the current user session if one is active
|
|
local uid
|
|
uid=$(id -u "$SUDO_USER" 2>/dev/null)
|
|
if [ -n "$uid" ] && [ -d "/run/user/$uid" ]; then
|
|
XDG_RUNTIME_DIR="/run/user/$uid" \
|
|
DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$uid/bus" \
|
|
runuser -u "$SUDO_USER" -- \
|
|
systemctl --user start camera-feed-watch.service 2>/dev/null || true
|
|
fi
|
|
fi
|
|
}
|
|
|
|
post_upgrade() {
|
|
_install_sleep_hook
|
|
systemctl daemon-reload
|
|
udevadm control --reload-rules 2>/dev/null || true
|
|
}
|
|
|
|
pre_remove() {
|
|
systemctl --global disable camera-feed-watch.service 2>/dev/null || true
|
|
systemctl disable camera-init.service 2>/dev/null || true
|
|
systemctl stop camera-init.service 2>/dev/null || true
|
|
|
|
if [ -n "$SUDO_USER" ]; then
|
|
local uid
|
|
uid=$(id -u "$SUDO_USER" 2>/dev/null)
|
|
if [ -n "$uid" ] && [ -d "/run/user/$uid" ]; then
|
|
XDG_RUNTIME_DIR="/run/user/$uid" \
|
|
DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$uid/bus" \
|
|
runuser -u "$SUDO_USER" -- \
|
|
systemctl --user stop camera-feed-watch.service 2>/dev/null || true
|
|
fi
|
|
fi
|
|
}
|
|
|
|
post_remove() {
|
|
rm -f /usr/lib/systemd/system-sleep/camera-sleep-hook
|
|
systemctl daemon-reload
|
|
udevadm control --reload-rules 2>/dev/null || true
|
|
}
|