ogra
September 1, 2021, 1:29pm
2
for the snap side of things there are the raw-usb
interface and there is
Hotplug support gives snaps the ability to integrate with Linux’s USB hotplugging and Udev device management subsystem. This enables snaps to recognise specific classes of device and create corresponding system slots when a device is connected.
Developers wishing to add hotplug functionality to their own interfaces should see Developing hotplug interfaces .
Hotplug support is currently under active development , and will become widely available with a future release of snap…
but that might indeed not change/add the permissions of the device itself, if your app does not run as a daemon (i.e. as root) you might need to cater for that as well to make sure the user is in the correct groups etc …
here is an example snap where i pop up a warning for the user if she is not in the video group … the script is a simple command-chain script using yad to show the popup:
#! /bin/sh
[ -e "$SNAP_USER_DATA/.check-complete" ] && exec "$@"
if ! id -Gn | grep -q video; then
yad --text "<b>Error, can not open video playback device \!</b>\n\nThe user $LOGNAME is not in the "video" group.\nPlease execute:\n\n <b>sudo usermod -a -G video $LOGNAME</b>\n\nIn a Terminal, afterwards log out and back in again." \
--borders=5 --center --on-top --undecorated \
--skip-taskbar && exit 0
fi
if ! snapctl is-connected hardware-observe; then
yad --text "<b>Error, can not get status of video playback device \!</b>\n\nPlease connect the hardware-observe snap interface\nwith the command:\n\n <b>sudo snap connect vlc-pi:hardware-observe</b>\n\nOr through the Permissions UI in the snap-store application" \
--borders=5 --center --on-top --undecorated \
--skip-taskbar && exit 0
fi
if [ ! -d "$SNAP_USER_COMMON/.local/lib/locale/$LANG" ]; then
yad --text "\nGenerating VLC translations for:\n\n\t$LANG" \
--borders=10 --no-buttons --center --on-top \
--undecorated --skip-taskbar --timeout=10 \
This file has been truncated. show original