The time now is Sun 19 May 2013, 03:23
All times are UTC - 4 |
|
Page 1 of 2 [18 Posts] |
Goto page: 1, 2 Next |
| Author |
Message |
Argolance

Joined: 06 Jan 2008 Posts: 1360 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Mon 21 Jan 2013, 12:00 Post subject:
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.
| Description |
|
| Filesize |
19.04 KB |
| Viewed |
298 Time(s) |

|
_________________

Last edited by Argolance on Thu 24 Jan 2013, 14:05; edited 2 times in total
|
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 4001 Location: Arizona, U.S.A.
|
Posted: Mon 21 Jan 2013, 23:35 Post subject:
|
|
Hi Argolance; Puppy`s mount GUI, pmount has to be refreshed for CD-DVD also.
Are you just trying to change the behavior of pmount, or auto. mount USB devices?
A simple script can auto. mount USB devices without pmount.
|
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 1696 Location: Burghaslach, Germany
|
Posted: Tue 22 Jan 2013, 06:32 Post subject:
Re: Autorun pmount when new usb drive is plugged? |
|
| Argolance wrote: | | ...like it to be automatically launched/relaunched as soon as any usb drive is plugged in.... |
Maybe just this?
| Description |
|
| Filesize |
26.91 KB |
| Viewed |
309 Time(s) |

|
|
|
Back to top
|
|
 |
Argolance

Joined: 06 Jan 2008 Posts: 1360 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Tue 22 Jan 2013, 07:54 Post subject:
|
|
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:
- 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 is why I would like 2pmount to react as soon as any removable drive is plugged (exactly as it is the case when any removable drive is unplugged!) and finally this one to be listed and mountable (by clicking on the corresponding button), all this without having to click on the refresh button.
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.
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 570
|
Posted: Tue 22 Jan 2013, 08:20 Post subject:
|
|
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:
| Code: | 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 |
(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!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
|
Back to top
|
|
 |
Argolance

Joined: 06 Jan 2008 Posts: 1360 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Tue 22 Jan 2013, 13:57 Post subject:
|
|
| SFR wrote: | I guess this is the thread you've lost track of:
http://murga-linux.com/puppy/viewtopic.php?t=77494 | It was another thread, not specially dedicated to the single Zigbert pmount...
| 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..? | Is this zigbert advertisement meaning that this has not to be "touched"? | zigbert wrote: | | the detection/mounting engine is NOT touched. |
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: | Code: | 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
| But this doesn't work: pmount sleeps...
Cordialement.
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 570
|
Posted: Tue 22 Jan 2013, 14:39 Post subject:
|
|
| Argolance wrote: | | 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..? | Is this zigbert advertisement meaning that this has not to be "touched"? | zigbert wrote: | | the detection/mounting engine is NOT touched. |
|
Zigbert is referring to pmount, not to pup_event_frontend_d.
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...
| 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: | Code: | 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
| But this doesn't work: pmount sleeps... |
What can I say - your modified piece of code works well for me.
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!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
|
Back to top
|
|
 |
Argolance

Joined: 06 Jan 2008 Posts: 1360 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Wed 23 Jan 2013, 05:37 Post subject:
|
|
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. | Quote: | Could you attach the whole modified script, so I could look into it?
| Thank you! Please, see attached file, to be simply renamed without extension.
Cordialement.
| Description |
|

Download |
| Filename |
pup_event_frontend_d.tar |
| Filesize |
35.23 KB |
| Downloaded |
45 Time(s) |
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 570
|
Posted: Wed 23 Jan 2013, 08:08 Post subject:
|
|
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:
| Quote: | | #121212 try increase sleep to 3 ...still getting rox-filer crashing. |
but this is irrelevant here, I believe.
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: | 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 |
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: | #########hotplug block event##########
if [ "$BLOCKDIFF" != "" ];then
echo "$BLOCKDIFF" >> /root/pup_debug |
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
|
Back to top
|
|
 |
Argolance

Joined: 06 Jan 2008 Posts: 1360 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Wed 23 Jan 2013, 08:49 Post subject:
|
|
Hello SFR,
| 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: | #########hotplug block event##########
if [ "$BLOCKDIFF" != "" ];then
echo "$BLOCKDIFF" >> /root/pup_debug |
| Sorry, but where do I copy this exactly?
Cordialement.
_________________

|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 570
|
Posted: Wed 23 Jan 2013, 09:06 Post subject:
|
|
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!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
|
Back to top
|
|
 |
Argolance

Joined: 06 Jan 2008 Posts: 1360 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Wed 23 Jan 2013, 13:22 Post subject:
|
|
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:
| Quote: | > 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 |
Cordialement.
_________________

|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 570
|
Posted: Wed 23 Jan 2013, 15:18 Post subject:
|
|
| Quote: | | Is there any "hidden" config file to clear now for being able to start all over again? |
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.
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: | #!/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 |
It's not an elegant solution since it duplicates some functionality from pup_event_frontend_d, but perhaps at least this will work fine for you...
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
|
Back to top
|
|
 |
Argolance

Joined: 06 Jan 2008 Posts: 1360 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Thu 24 Jan 2013, 06:51 Post subject:
|
|
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!
| Code: | 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}" ] |
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.
_________________

|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 570
|
Posted: Thu 24 Jan 2013, 08:15 Post subject:
|
|
Hey Argolance
I'm glad we've achieved some positive results at last.
| Quote: | 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! |
(Those lines are in pup_event_frontend_d, not pmount)
Sure, just comment out the if..fi block (it's around line 750, just below the section we were playing with) as shown:
| Code: | 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 |
And the modified script with add & remove support + comments:
| Code: | #!/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 |
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
|
Back to top
|
|
 |
|
|
Page 1 of 2 [18 Posts] |
Goto page: 1, 2 Next |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|