Autorun pmount when new usb drive is plugged? [SOLVED]
- Argolance
- Posts: 3767
- Joined: Sun 06 Jan 2008, 22:57
- Location: PORT-BRILLET (Mayenne - France)
- Contact:
Autorun pmount when new usb drive is plugged? [SOLVED]
Hello,
I noticed that when pmount is running, the application is automatically closed and reopened when, for example, a removable USB drive is unplugged. This doesn't happen when a new removable drive is plugged. User has to to click on the refresh button for the drive to be taken in account/listed. I made a fork of pmount (I saw later that Zigbert and some others made something similar but didn't find the thread again! ) and would like it to be automatically launched/relaunched as soon as any removable usb drive is plugged in.
Has somebody any track I could explore to do this?
Cordialement.
I noticed that when pmount is running, the application is automatically closed and reopened when, for example, a removable USB drive is unplugged. This doesn't happen when a new removable drive is plugged. User has to to click on the refresh button for the drive to be taken in account/listed. I made a fork of pmount (I saw later that Zigbert and some others made something similar but didn't find the thread again! ) and would like it to be automatically launched/relaunched as soon as any removable usb drive is plugged in.
Has somebody any track I could explore to do this?
Cordialement.
- Attachments
-
- 124945_300x529_easyshot.jpg
- (19.04 KiB) Downloaded 566 times
Last edited by Argolance on Thu 24 Jan 2013, 18:05, edited 2 times in total.
- L18L
- Posts: 3479
- Joined: Sat 19 Jun 2010, 18:56
- Location: www.eussenheim.de/
Re: Autorun pmount when new usb drive is plugged?
Maybe just this?Argolance wrote:...like it to be automatically launched/relaunched as soon as any usb drive is plugged in....
- Attachments
-
- event.png
- (26.91 KiB) Downloaded 570 times
- Argolance
- Posts: 3767
- Joined: Sun 06 Jan 2008, 22:57
- Location: PORT-BRILLET (Mayenne - France)
- Contact:
Hello,
Thank you for answering.
My purpose is to replace (optionally) drives/partitions desktop icons with this fork of pmount (2pmount) because I don't find them very convenient.
2 reasons:
It probably should not be too much difficult to make but supposes knowledge which I do not currently have! At least a track to follow or an example to be imitated should be great!
Cordialement.
Thank you for answering.
My purpose is to replace (optionally) drives/partitions desktop icons with this fork of pmount (2pmount) because I don't find them very convenient.
2 reasons:
- - When many applications are running, drives icons being in the background, it is sometimes boring to move windows to reach them, unless minimizing all the applications windows, which is not convenient to.
- When working with 2 screens (twinview), icons are hidden when screens has not the same size (though I know it is possible to move icons for them to be visible but this has to be done before configuring twinview).
It probably should not be too much difficult to make but supposes knowledge which I do not currently have! At least a track to follow or an example to be imitated should be great!
Cordialement.
I guess this is the thread you've lost track of:
http://murga-linux.com/puppy/viewtopic.php?t=77494
It's /sbin/pup_event_frontend_d script which is responsible for refreshing pmount in case of device removal, but it's easy do add this also in case of device insertion.
I tested it only with USB stick plugging/unplugging and all was fine, but can't guarantee it will be so with everything - perhaps there's a reason why Barry and others didn't design it this way..?
But if you'd like to explore it anyway, find the following block of code and add if..fi condition as shown:
(btw, this code is taken from Slacko-5.4, so if you're using other Puppy it may vary, but I'm sure you can handle it).
After modifications restart X.
HTH
Greetings!
http://murga-linux.com/puppy/viewtopic.php?t=77494
It's /sbin/pup_event_frontend_d script which is responsible for refreshing pmount in case of device removal, but it's easy do add this also in case of device insertion.
I tested it only with USB stick plugging/unplugging and all was fine, but can't guarantee it will be so with everything - perhaps there's a reason why Barry and others didn't design it this way..?
But if you'd like to explore it anyway, find the following block of code and add if..fi condition as shown:
Code: Select all
ACTION=add
SUBSYSTEM=block
DEVTYPE=disk
for DRV_NAME in $BLOCKSADD
do
[ ! -e /sys/block/$DRV_NAME ] && continue #precaution
DEVPATH=/block/$DRV_NAME
odPATTERN='^/dev/'"$DRV_NAME"'|'
PROBEDISK="`probedisk2`"
DRVS_OPTICAL="`echo "$PROBEDISK" | grep '|optical|' | cut -f 1 -d '|' | cut -f 3 -d '/'`" #update
DRVS_FLOPPY="`echo "$PROBEDISK" | grep '|floppy|' | cut -f 1 -d '|' | cut -f 3 -d '/'`" #update
DRV_CATEGORY="`echo -n "$PROBEDISK" | grep "$odPATTERN" | cut -f 2 -d '|'`"
DRV_DESCRIPTION="`echo -n "$PROBEDISK" | grep "$odPATTERN" | cut -f 3 -d '|' | tr -s ' '`"
[ "$ICONDESK" = "true" ] && create_icon_func #uses DRV_NAME, DRV_CATEGORY, DRV_DESCRIPTION
[ "$HOTPLUGNOISY" = "true" ] && /root/.pup_event/drive_${DRV_NAME}/AppRun ${DRV_CATEGORY} & #handler script.
if [ "`pidof gtkdialog_pmount`" != "" ];then #if pmount running, refresh it.
killall gtkdialog_pmount 2>/dev/null
sleep 0.1
LANG=$OLDLANG pmount & #100613 fix from shinobar.
fi
done
After modifications restart X.
HTH
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]
[b][color=green]Omnia mea mecum porto.[/color][/b]
- Argolance
- Posts: 3767
- Joined: Sun 06 Jan 2008, 22:57
- Location: PORT-BRILLET (Mayenne - France)
- Contact:
It was another thread, not specially dedicated to the single Zigbert pmount...SFR wrote:I guess this is the thread you've lost track of:
http://murga-linux.com/puppy/viewtopic.php?t=77494
Is this zigbert advertisement meaning that this has not to be "touched"?SFR wrote:I tested it only with USB stick plugging/unplugging and all was fine, but can't guarantee it will be so with everything - perhaps there's a reason why Barry and others didn't design it this way..?
I copied lines inside the pmount script as described above. This works... but pmount opens and closes non-stop...zigbert wrote:the detection/mounting engine is NOT touched.
I tried this too, to make pmound automatically running (if not!) when a removable drive is plugged:
Code: Select all
if [ "`pidof gtkdialog_pmount`" = "" ];then #if pmount not running, launch it.
LANG=$OLDLANG pmount & #100613 fix from shinobar.
else #if pmount running, refresh it.
killall gtkdialog_pmount 2>/dev/null
sleep 1
LANG=$OLDLANG pmount & #100613 fix from shinobar.
fi
Cordialement.
Zigbert is referring to pmount, not to pup_event_frontend_d.Argolance wrote:Is this zigbert advertisement meaning that this has not to be "touched"?SFR wrote:I tested it only with USB stick plugging/unplugging and all was fine, but can't guarantee it will be so with everything - perhaps there's a reason why Barry and others didn't design it this way..?zigbert wrote:the detection/mounting engine is NOT touched.
What I mean is that I have tried it only with USB stick (and later with WD MyPassport which has 1 "normal" partition + virtual CD drive), no DVD, SD, etc...
What can I say - your modified piece of code works well for me.Argolance wrote:I copied lines inside the pmount script as described above. This works... but pmount opens and closes non-stop...
I tried this too, to make pmound automatically running (if not!) when a removable drive is plugged:But this doesn't work: pmount sleeps...Code: Select all
if [ "`pidof gtkdialog_pmount`" = "" ];then #if pmount not running, launch it. LANG=$OLDLANG pmount & #100613 fix from shinobar. else #if pmount running, refresh it. killall gtkdialog_pmount 2>/dev/null sleep 1 LANG=$OLDLANG pmount & #100613 fix from shinobar. fi
Could you attach the whole modified script, so I could look into it?
BTW, Slacko-5.4 has Zigbert's fork of pmount installed, perhaps that's why it acts differently to each of us?
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]
[b][color=green]Omnia mea mecum porto.[/color][/b]
- Argolance
- Posts: 3767
- Joined: Sun 06 Jan 2008, 22:57
- Location: PORT-BRILLET (Mayenne - France)
- Contact:
Hello SFR,
Today, pmount ran immediately when I plugged my USB flash drive: yesterday, I forgot to restart X before testing added code lines inside pup_event_frontend_d.
But pmount don't stop opening/closing... To stop the loop, I have to unplug the device.
Cordialement.
Today, pmount ran immediately when I plugged my USB flash drive: yesterday, I forgot to restart X before testing added code lines inside pup_event_frontend_d.
But pmount don't stop opening/closing... To stop the loop, I have to unplug the device.
Thank you! Please, see attached file, to be simply renamed without extension.Could you attach the whole modified script, so I could look into it?
Cordialement.
- Attachments
-
- pup_event_frontend_d.tar
- (35.23 KiB) Downloaded 283 times
Hey Argolance
Your version of pup_event_frontend_d is practically the same as mine (and works as mine), just a bit newer. The only difference is:
I tried the modification also in Lupu-528 & Wary-5.3 (pristine boot, in VBox) and still ok.
What about some "debugging"?
Few things to try (if you haven't done so yet):
1. pfix=ram
2. Different USB stick
3. Replace 'pmount' with something else, eg. 'abiword' in the script:
4. Add the 'echo...' as shown, restart X, plug in USB stick (let pmount restart few times), stop pup_event_frontend_d and see what's inside /root/pup_debug.
Greetings!
Your version of pup_event_frontend_d is practically the same as mine (and works as mine), just a bit newer. The only difference is:
but this is irrelevant here, I believe.#121212 try increase sleep to 3 ...still getting rox-filer crashing.
I tried the modification also in Lupu-528 & Wary-5.3 (pristine boot, in VBox) and still ok.
What about some "debugging"?
Few things to try (if you haven't done so yet):
1. pfix=ram
2. Different USB stick
3. Replace 'pmount' with something else, eg. 'abiword' in the script:
Code: Select all
if [ "`pidof abiword`" = "" ];then #if pmount not running, launch it.
LANG=$OLDLANG abiword & #100613 fix from shinobar.
else #if pmount running, refresh it.
killall abiword 2>/dev/null
sleep 1
LANG=$OLDLANG abiword & #100613 fix from shinobar.
fi
Code: Select all
#########hotplug block event##########
if [ "$BLOCKDIFF" != "" ];then
echo "$BLOCKDIFF" >> /root/pup_debug
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]
[b][color=green]Omnia mea mecum porto.[/color][/b]
- Argolance
- Posts: 3767
- Joined: Sun 06 Jan 2008, 22:57
- Location: PORT-BRILLET (Mayenne - France)
- Contact:
Hello SFR,
Cordialement.
Sorry, but where do I copy this exactly?SFR wrote:4. Add the 'echo...' as shown, restart X, plug in USB stick (let pmount restart few times), stop pup_event_frontend_d and see what's inside /root/pup_debug.
Code:Code: Select all
#########hotplug block event########## if [ "$BLOCKDIFF" != "" ];then echo "$BLOCKDIFF" >> /root/pup_debug
Cordialement.
Yeah, sorry - to pup_event_frontend_d
According to your script this block begins at line 721.
BTW, I don't mean you to do those tasks at once, they should be done as a separate trials (first try pfix=ram, if problem still occurs - try another USB stick and so on).
Greetings!
According to your script this block begins at line 721.
BTW, I don't mean you to do those tasks at once, they should be done as a separate trials (first try pfix=ram, if problem still occurs - try another USB stick and so on).
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]
[b][color=green]Omnia mea mecum porto.[/color][/b]
- Argolance
- Posts: 3767
- Joined: Sun 06 Jan 2008, 22:57
- Location: PORT-BRILLET (Mayenne - France)
- Contact:
Hello SFR,
Replacing pmount with abiword gives the same issue. I tested with the original pmount, zigbert pmount and mine.
More: Nothing happens anymore... Even when I plug/unplug an (other) removable USB device (I didn't forget to restart X after modifying pup_event_frontend_d!)
Otherwise, pmount works normally!
Is there any "hidden" config file to clear now for being able to start all over again?
I am very disappointed, because this would be very convenient. But, as you said above, there is probably some reason for this not to have already been done by some "Puppy king": It would be very surprising that nobody thought of this little improvement!
This is what pup_debug says:
Replacing pmount with abiword gives the same issue. I tested with the original pmount, zigbert pmount and mine.
More: Nothing happens anymore... Even when I plug/unplug an (other) removable USB device (I didn't forget to restart X after modifying pup_event_frontend_d!)
Otherwise, pmount works normally!
Is there any "hidden" config file to clear now for being able to start all over again?
I am very disappointed, because this would be very convenient. But, as you said above, there is probably some reason for this not to have already been done by some "Puppy king": It would be very surprising that nobody thought of this little improvement!
This is what pup_debug says:
Cordialement.> sdc
> sdc
> sdc
> sdc
> sdc
> sdc
> sdc
> sdc
> sdc
> sdc
> sdc
> sdc
3d2
< sdc
2a3
> sdc
3a4
> sdd
> sdd
> sdd
> sdd
> sdd
> sdd
> sdd
> sdd
> sdd
> sdd
> sdd
> sdd
4d3
< sdd
3d2
< sdc
Just replace /sbin/pup_event_frontend_d with the original one from CD or (if you have frugal install) from /initrd/pup_ro2/sbin/ and restart X, or better reboot.Is there any "hidden" config file to clear now for being able to start all over again?
The debug shows that when you insert a USB stick, it starts to be constantly detected as if it was just plugged in a moment ago - it shouldn't be like this, I guess, and that's why pmount restarts over and over again.
One more thing - did you try to boot with pfix=ram (or even with other Puppy version), modify pup_event_frontend_d and see what happens then?
If this one fails too - I'll be out of ideas why it acts this way in your case, sorry.
EDIT:
If pfix=ram will fail, clean all things as they were before we started, and try this (it's stand-alone script):
Code: Select all
#!/bin/bash
OLD="`ls -1 --hide=ram* --hide=loop* /sys/block`"
while true; do
NEW="`ls -1 --hide=ram* --hide=loop* /sys/block`"
if [ "${#NEW}" -gt "${#OLD}" ]; then
if [ "`pidof gtkdialog_pmount`" = "" ]; then #if pmount not running, launch it.
pmount &
else #if pmount running, refresh it.
killall gtkdialog_pmount 2>/dev/null
sleep 0.1
pmount &
fi
fi
OLD="$NEW"
sleep 2
done
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]
[b][color=green]Omnia mea mecum porto.[/color][/b]
- Argolance
- Posts: 3767
- Joined: Sun 06 Jan 2008, 22:57
- Location: PORT-BRILLET (Mayenne - France)
- Contact:
Hello SFR,
Thank you for you patience...
I tested on my laptop too and got the same issue.
Your latest idea is great and I finally think a stand alone script would be much better: it could be so activate/deactivate by user, through an additional option in pmount.
I copied your script to /root/startup/ as "pmount_in_out.sh" (for example), cleaned /sbin/pup_event_frontend_d and restarted X: This works! ... but is almost operational: from the second attempt, pmount window is not refreshed properly and this has to be done manually (perhaps is this due to the remove action code part of pmount?)
Anyway, I was wondering if it would not be more appropriate to complete the script for it to support both add/remove actions, and uncomment or simply delete relative lines inside pmount?
I admit that I can just say your script works but cannot say how!
Thank you so much for this beautiful fish! So, I take the risk of abusing your kindness: may I please ask you to give me the net to try to catch it myself?
The initial idea is indeed perhaps going to succeed thanks to you?
Cordialement.
Thank you for you patience...
I tested on my laptop too and got the same issue.
Your latest idea is great and I finally think a stand alone script would be much better: it could be so activate/deactivate by user, through an additional option in pmount.
I copied your script to /root/startup/ as "pmount_in_out.sh" (for example), cleaned /sbin/pup_event_frontend_d and restarted X: This works! ... but is almost operational: from the second attempt, pmount window is not refreshed properly and this has to be done manually (perhaps is this due to the remove action code part of pmount?)
Anyway, I was wondering if it would not be more appropriate to complete the script for it to support both add/remove actions, and uncomment or simply delete relative lines inside pmount?
I admit that I can just say your script works but cannot say how!
Code: Select all
OLD="`ls -1 --hide=ram* --hide=loop* /sys/block`"
while true; do
NEW="`ls -1 --hide=ram* --hide=loop* /sys/block`"
if [ "${#NEW}" -gt "${#OLD}" ]
The initial idea is indeed perhaps going to succeed thanks to you?
Cordialement.
Hey Argolance
I'm glad we've achieved some positive results at last.
Sure, just comment out the if..fi block (it's around line 750, just below the section we were playing with) as shown:
And the modified script with add & remove support + comments:
Greetings!
I'm glad we've achieved some positive results at last.
(Those lines are in pup_event_frontend_d, not pmount)Anyway, I was wondering if it would not be more appropriate to complete the script for it to support both add/remove actions, and uncomment or simply delete relative lines inside pmount?
I admit that I can just say your script works but cannot say how!
Sure, just comment out the if..fi block (it's around line 750, just below the section we were playing with) as shown:
Code: Select all
ACTION=remove
for DRV_NAME in $BLOCKSREM
do
#[ -e /sys/block/$DRV_NAME ] && continue #precaution. w015 must remove.
DRVS_OPTICAL="`echo "$DRVS_OPTICAL" | grep -v "$DRV_NAME"`" #update
DRVS_FLOPPY="`echo "$DRVS_FLOPPY" | grep -v "$DRV_NAME"`" #update
DEVPATH=/block/$DRV_NAME
#if [ "`pidof gtkdialog_pmount`" != "" ];then #if pmount running, refresh it.
# killall gtkdialog_pmount 2>/dev/null
# sleep 0.1
# LANG=$OLDLANG pmount & #100613 fix from shinobar.
#fi
remove_pinboard_func #needs DRV_NAME
rm -rf /root/.pup_event/drive_${DRV_NAME}* 2>/dev/null
done
Code: Select all
#!/bin/bash
# This line stores in OLD variable the current state of /dev/block/ folder
# (except ram* and loop*, only sd* etc.), where appropriate links
# are being created in case of device insertion/removal.
# BTW, this line is taken from /sbin/pup_event_frontend_d and the whole
# detection mechanism is very simplified here, so may not work with some devices.
# For details see pup_event_frontend_d around lines 680-.
OLD="`ls -1 --hide=ram* --hide=loop* /sys/block`"
# Infinite loop, executed every 2 seconds
while true; do
# Store the state of /dev/block/ in NEW variable, for comparsion
NEW="`ls -1 --hide=ram* --hide=loop* /sys/block`"
# If the lenght of NEW is greatest than OLD, most likely a new device
# was plugged in...
if [ "${#NEW}" -gt "${#OLD}" ]; then
# You know this part ;)
if [ "`pidof gtkdialog_pmount`" = "" ]; then #if pmount not running, launch it.
pmount &
else #if pmount running, refresh it.
killall gtkdialog_pmount 2>/dev/null
sleep 0.1
pmount &
fi
fi
# If the lenght of NEW is less than OLD, most likely a device was removed
if [ "${#NEW}" -lt "${#OLD}" ]; then
# Don't launch pmount in this case, just refresh it if running.
if [ "`pidof gtkdialog_pmount`" != "" ]; then #if pmount is running, refresh it.
killall gtkdialog_pmount 2>/dev/null
sleep 0.1
pmount &
fi
fi
OLD="$NEW"
sleep 2
done
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]
[b][color=green]Omnia mea mecum porto.[/color][/b]
- Argolance
- Posts: 3767
- Joined: Sun 06 Jan 2008, 22:57
- Location: PORT-BRILLET (Mayenne - France)
- Contact:
Hello SFR,
Really great! This works, as well as plugging or unplugging a removable device and explanations helped me to understand how: thank you!
Last thing : As said above, pmount window is not always refreshed properly and this has sometimes to be done manually. Is there any sleep delay to put/increase somewhere for this script to work... perfectly?
Cordialement.
Really great! This works, as well as plugging or unplugging a removable device and explanations helped me to understand how: thank you!
Last thing : As said above, pmount window is not always refreshed properly and this has sometimes to be done manually. Is there any sleep delay to put/increase somewhere for this script to work... perfectly?
Cordialement.
Perhaps the device was reinserted too quickly..? Hard to say, because I haven't encountered this problem.
You can try decrease sleep 2 to, eg. sleep 1, but don't know if this helps...
To watch up to date what devices (and how quick) are being recognized by system, launch this in terminal:
Greetings!
You can try decrease sleep 2 to, eg. sleep 1, but don't know if this helps...
To watch up to date what devices (and how quick) are being recognized by system, launch this in terminal:
Code: Select all
watch -n1 ls -1 --hide=ram* --hide=loop* /sys/block
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]
[b][color=green]Omnia mea mecum porto.[/color][/b]