This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How to run a script when an USB device is connected?

Tags: None
(comma "," separated)
User avatar
bushveld
Registered Member
Posts
174
Karma
0
OS
Hello,

I like to sync my google calendar to my ipod this can be done fairly simple by downloading the certain ics file via wget and move it to the ipod calender folder. The script is ok and works fine.
Now I like to run this script automatically when I connect my iPod via USB. Is ther a way to do this? I thought about the plasma device notifier this plamoid at least get the event - can I hook on here? Or is there an alternative?

Thank a lot
Michael


openSUSE 11.2 and KDE 4.4.0 -- Vita brevis! --
Kryten2X4B
Registered Member
Posts
911
Karma
4
OS
If you're using 4.4, you could use the "Device actions" settings to configure a script to run upon connecting the iPod. Run semi-automatically that is, since you would have to click on the iPod in the device-notifier pop-up to actually run it.

Personally I'd prefer it if it could be set to 100 % automatically (I'm using that method to run my backup-program upon connecting a specific disk) but better than nothing.


OpenSUSE 11.4, 64-bit with KDE 4.6.4
Proud to be a member of KDE forums since 2008-Oct.
User avatar
bushveld
Registered Member
Posts
174
Karma
0
OS
Hello,

well I use 4.3.1 and soon 4.3.5 the method you describe is halve way what I like. Anyone how can help? I am sure that it is possible to run the script right after the plugin..
I'd like to use the plasmoid, the other option is to check for some udev rules.

Michael


openSUSE 11.2 and KDE 4.4.0 -- Vita brevis! --
User avatar
LBL
Registered Member
Posts
131
Karma
0
OS
I think udev is able to run a script on connecting a device, at least usb devices. but I don't know any gui for udev.


42: There is no other answer. There are only different ways to express it.
0x2A
0o52
0b101010
User avatar
bushveld
Registered Member
Posts
174
Karma
0
OS
Hello,

I finally upgraded to 4.4.0 ! I was able to add my script to sync my iPod for all "Storage devices"
via the "Device actions" like Kryten2x4b described. How can I shrink this down to pop up only when my iPod is pluged in? Is there a method to set up a rule for e.g. Product=xx ? Or is there somewhere a documentation of the options?

Here is how my iPod "looks" like.

T: Bus=01 Lev=03 Prnt=03 Port=00 Cnt=01 Dev#= 4 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 2
P: Vendor=05ac ProdID=1265 Rev= 0.01
S: Manufacturer=Apple Inc.
S: Product=iPod
S: SerialNumber=000Axxxxxxxxxxxx
C: #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=500mA
I: If#= 0 Alt= 0 #EPs= 2 Cls=08(mstor) Sub=06 Prot=50 Driver=usb-storage

Thanks a lot
Michael


openSUSE 11.2 and KDE 4.4.0 -- Vita brevis! --
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
If you give your iPod a certain Volume Label, then you can match on that.
The Device Actions interface is aware of all possible matching combinations, you may wish to check the Storage Access and Storage Drive device types also.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
bushveld
Registered Member
Posts
174
Karma
0
OS
Hello

thanks for the hint, I actually understand the concept but unfortunately I am not able to setup a rule to check for the given device name. Nor I am able to set up more than 2 Rules. I only change existing rules, I do not see any ADD button for rules..
Is there somewhere a document wich describes the options and the variables?

Thanks a lot
Michael


openSUSE 11.2 and KDE 4.4.0 -- Vita brevis! --
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Have you read the Help document for the Device Actions KCM? It explains most of the weird details.

You need to change the Parameter Type to "Content Conjunction" or "Content Disjunction" for it to have children.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
bushveld
Registered Member
Posts
174
Karma
0
OS
Hm

at least with the openSuSE 11.2 and KDE 4.4 Factory rpms I did not get a help. But these rpms are from day one - will reinstall and check

thx
michael


openSUSE 11.2 and KDE 4.4.0 -- Vita brevis! --
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
You may wish to use the on line documentation if you cannot get local docs to work...

http://docs.kde.org/stable/en/kdebase-w ... index.html


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
bushveld
Registered Member
Posts
174
Karma
0
OS
Thank for the link this actually confirmed my findings.

I have more, hopefully not to stupid questions:

- how can I delete a rule? I did not find an option, so I would need to start all over when I am mistaken?

- I have attached the data of my iPod, this is detected as Storage Volume, which value do I need to check for when I want to use the objectname??

05: SCSI 800.0: 10600 Disk
[Created at block.243]
UDI: /org/freedesktop/Hal/devices/storage_serial_Apple_iPod_000A27001Exxxxxx7_0_0
Unique ID: mW+_.52ebT2CxxxA
SysFS ID: /class/block/sdc
SysFS BusID: 8:0:0:0
SysFS Device Link: /devices/pci0000:00/0000:00:1a.7/usb1/1-4/1-4.4/1-4.4.1/1-4.4.1:1.0/host8/target8:0:0/8:0:0:0
Hardware Class: disk
Model: "Apple iPod"
Vendor: usb 0x05ac "Apple"
Device: usb 0x1265 "iPod"
Revision: "1.70"
Serial ID: "YxxxxxxxL71Y"
Driver: "usb-storage", "sd"
Driver Modules: "usb_storage"
Device File: /dev/sdc (/dev/sg4)
Device Files: /dev/sdc, /dev/block/8:32, /dev/disk/by-id/usb-Apple_iPod_000A27001ED05DD7-0:0, /dev/disk/by-path/pci-0000:00:1a.7-usb-0:4.4.1:1.0-scsi-0:0:0:0, /dev/disk/by-uuid/A88B-3652, /dev/disk/by-label/iPod
Device Number: block 8:32-8:47 (char 21:4)
Features: Hotpluggable
Geometry (Logical): CHS 127/245/62
Size: 1937856 sectors a 4096 bytes
Speed: 480 Mbps
Module Alias: "usb:v05ACp1265d0001dc00dsc00dp00ic08isc06ip50"
Config Status: cfg=new, avail=yes, need=no, active=unknown


openSUSE 11.2 and KDE 4.4.0 -- Vita brevis! --
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
The object name property is not used by Solid, and comes from QObject. It has been removed from display in 4.5.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
bushveld
Registered Member
Posts
174
Karma
0
OS
Ok,

which value would you suggest to unicely identify the iPod ?
I was not yet able to get something unique.

Michael


openSUSE 11.2 and KDE 4.4.0 -- Vita brevis! --
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
If you can ensure it is always mounted at the same unique location, then type StorageAccess, property File Path should work.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
bushveld
Registered Member
Posts
174
Karma
0
OS
'Thanks

works like a charm :-)

Michael


openSUSE 11.2 and KDE 4.4.0 -- Vita brevis! --


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], q.ignora, watchstar