pmaports/main/postmarketos-ui-kodi/automount-media.rules
Dylan Van Assche b24b021431
main/postmarketos-ui-kodi: switch to GBM (MR 2808)
Kodi UI is broken on Wayland with Cage, switch to GBM instead.
GBM is more suitable for running standalone and easier to maintain.
Also add udev rules to automount USB drives as you cannot access
them from Kodi otherwise.

[ci:skip-build] already built successfully in CI
2022-01-04 22:58:11 -08:00

19 lines
994 B
Text

# Automount any media you plug into the device to make it accessible to Kodi
# Thanks to https://www.axllent.org/docs/auto-mounting-usb-storage/
KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"
# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"
# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"
# Global mount options
ACTION=="add", ENV{mount_options}="relatime"
# Filesystem-specific mount options
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"
# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"
# Clean up after removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"
# Exit
LABEL="media_by_label_auto_mount_end"