av8r1
Posts: 20
Joined: Mon Jun 23, 2014 7:04 pm

I think udev doesn't work, and there's no useful documentation

Tue Feb 20, 2018 3:18 am

I've found several forum posts about this, and none have helped me. I have an mp4 on a usb thumb drive. I want it to automatically play using omxplayer when I plug in the drive. I wrote a simple little bash script that goes a little somethin' like this:

Code: Select all

#!/bin/bash
omxplayer /media/pi/drivename/video_I_want_to_play.mp4
This script is stored on the Pi in the Documents folder, not the thumb drive.

From what I read, I'm supposed to put a udev rule in /etc/udev/rules.d. Every example I've seen uses a different file name for that rule, so I guarantee I'm missing something there. I don't know what BLOCK== or whatever is. I figured out that KERNEL is supposed to be the drive device name, ex. sda1. I place that rule there, and when I plug in the drive, nothing happens.

A search of youtube turns up the usual incomprehensible Indians, videos with no sound from 16 years ago usingCentARCH on a graphing calculator, a pen test lecture, and two guys standing in the street hitting each other with shovels. A google search turns up basically a lot of people trying to get this to work, failing, and not finding solutions.

Actually, you know what? Screw udev. What I want is a script that launches on startup that checks to see if a drive has been inserted, when one has, try to play an mp4 on that usb drive, if that file isn't there, do nothing. Is this a thing that modern science can do?

On a related note, how do I get it to quit asking me if I want to open a folder to view the files, and just have it automatically do it without asking?

av8r1
Posts: 20
Joined: Mon Jun 23, 2014 7:04 pm

Re: I think udev doesn't work, and there's no useful documentation

Tue Feb 20, 2018 4:17 am

I'm not going to get this to work, am I?

ejolson
Posts: 2158
Joined: Tue Mar 18, 2014 11:47 am

Re: I think udev doesn't work, and there's no useful documentation

Thu Feb 22, 2018 8:17 am

av8r1 wrote:
Tue Feb 20, 2018 4:17 am
I'm not going to get this to work, am I?
I think it is one of those things where the people who know how to make it work think it's a bad idea and those who think it's a good idea don't know how to make it work. At the same time, as you already suggested, it is not clear udev itself is really such a good idea anyway.

epoch1970
Posts: 2126
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: I think udev doesn't work, and there's no useful documentation

Thu Feb 22, 2018 11:27 am

On google "udev documentation", I get on first page:
- Current manual page
- The excellent "Writing udev rules" guide by Daniel Drake. Read this one first. Keep in mind it is about 15 years old. The basic logic has not changed and examples shown will still work for simpler cases.

For more elaborate tricks, like launching a long-lived process (hint) or mounting a disk (hint) from udev, make sure to rely on recent sources that mention the all-important role of systemd.

Why is it so amply yet poorly documented? Because udev has been in the process of merging with systemd for a few years, its behaviour changes from version to version and over time you end up with contradictory solutions to the same problems.
Your best inspiration source could be working examples from this forum, describing the same kind of application and using the same version of Raspbian.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Raspbian”