WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Being notified when plugging an usb stick? [SOLVED]  (Read 2138 times)

Offline manuel

  • Newbie
  • *
  • Posts: 3
Being notified when plugging an usb stick? [SOLVED]
« on: August 10, 2009, 11:36:01 AM »
Hello.

I need to know how I could be notified of plugging an usb memory and react reading some files therein.
I've installed dbus and hal TCEs, but I'm not able to receive dbus messages.
Is there an application where I can see dbus and hal working? Something like Gnome panel with automount applet? (But without the whole Gnome thing.)

Thanks!

« Last Edit: August 11, 2009, 12:35:55 AM by manuel »

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Being notified when plugging an usb stick?
« Reply #1 on: August 10, 2009, 12:06:40 PM »
Hi,
 
first make sure DBUS and HAL is running. Use 'lshal' command. If everything is ok, you will get a long list of identified devices.

If DBUS/HAL is not running, start it with 'sudo hal-start'
 
If running, use 'lshal -m' to monitor changes. Plug USB drive, it must be reported.

However it depends on what do you want to do. In fact USB connection is identified by udev and kernel, DBUS and HAL are higher layers and not necessarily needed, see udev rules.
« Last Edit: August 10, 2009, 12:13:59 PM by bmarkus »
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline ^thehatsrule^

  • Administrator
  • Hero Member
  • *****
  • Posts: 1726
Re: Being notified when plugging an usb stick?
« Reply #2 on: August 10, 2009, 12:07:58 PM »
I think the hal extension were created initially for the xfce4 extension in mind... not sure if any other extensions take advantage of it

Alternatively, you could adjust the udev settings instead.

Offline manuel

  • Newbie
  • *
  • Posts: 3
Re: Being notified when plugging an usb stick?
« Reply #3 on: August 10, 2009, 12:34:36 PM »
Hello.

Ok, I see HAL isn't running. I run "sudo hal-start", and dbus starts, but not hal.
I've seen, in other post, that we need bluez to start dbus and hal. I've installed that and a lot of things to try to get dbus working, even edited /opt/bootlocal.sh and added hal-start, but to no avail.

While waiting your help, I'll read udev rules docs.

Thank you.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Being notified when plugging an usb stick?
« Reply #4 on: August 10, 2009, 12:39:27 PM »

Ok, I see HAL isn't running. I run "sudo hal-start", and dbus starts, but not hal.
I've seen, in other post, that we need bluez to start dbus and hal. I've installed that and a lot of things to try to get dbus working, even edited


Bluez definitely not needed. hal.tcel (or hal.tczl) installs everything needed to run hal. There is mybe a conflict between installed components.

Take a clean system, either a newly installed on the USB stick or start system with 'tinycore base nolocal norestore' option. Then install only hal with appbrowser.

It must work on TC 2.2 system. If not, there must be an error message. Share it with us.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Being notified when plugging an usb stick?
« Reply #5 on: August 10, 2009, 12:56:39 PM »

While waiting your help, I'll read udev rules docs.


sudo udevmonitor may help


or you can run periodically lsusb command. There are many different approaches...
« Last Edit: August 10, 2009, 12:58:52 PM by bmarkus »
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline manuel

  • Newbie
  • *
  • Posts: 3
Re: Being notified when plugging an usb stick?
« Reply #6 on: August 11, 2009, 12:35:30 AM »
Hello.

Ok, it's just like you said. After a clean install it works perfectly.
Anyway, after following your suggestions, last night I readed udev documentation and I have to say, to my joy: that's the perfect solution to my headache  :)

Thank you guys because I didn't even know about udev, and this will be a source of joy and happiness.  ;D