Author |
Message |
Iguleder

Joined: 11 Aug 2009 Posts: 2031 Location: Israel, somewhere in the beautiful desert
|
Posted: Sat 01 Jun 2013, 11:10 Post subject:
|
|
Good news!
I wrote a handler which creates desktop icons and lets ROX-Filer automatically position them, so they appear right after the existing ones. See the screeny for an example. This handler uses Puppy-style icons which match the partition type and change once the partition is mounted. The sources are attached
It's possible to use Puppy's icon positioning algorithm but it's quite dirty and I like it more when icons are automatically arranged.
First impressions?
Description |
|

Download |
Filename |
part-hotplug-handler.tar.bz2 |
Filesize |
18.16 KB |
Downloaded |
277 Time(s) |
Description |
|

Download |
Filename |
screeny.png |
Filesize |
47.37 KB |
Downloaded |
339 Time(s) |
_________________ My homepage
My GitHub profile
|
Back to top
|
|
 |
simargl
Joined: 11 Feb 2013 Posts: 572
|
Posted: Sat 01 Jun 2013, 17:49 Post subject:
|
|
.
Last edited by simargl on Sun 01 Sep 2013, 11:13; edited 1 time in total
|
Back to top
|
|
 |
charlie6

Joined: 30 Jun 2008 Posts: 1199 Location: Saint-Gérard / Walloon part of Belgium
|
Posted: Sat 01 Jun 2013, 23:58 Post subject:
|
|
Hi Iguleder,
here impressions on wheezy-3.5.2.5
- have extracted the part-hotplug-handler.tar.bz2
- have compiled part-hotplug-monitor.c > got part-hotplug-monitor (just ran make)
- have copied + rendered them executable
part-hotplug-monitor
part-hotplug-handler
part-icon
to /usr/bin
- have made a symlink for part-hotplug-monitor pointing to /sbin where /sbin/pup_event_frontend_d is present
- have disabled the existing pup_event_frontend_d and renamed whatever anme;
- have renamed pup_event_frontend_d the symling part-hotplug-monitor
restarted X ... wait a rather long long time till X actually restarted ... and got X desktop displayed without any drive icon.
running ./sbin/part-hotplug-monitor in a console: part-hotplug-monitor seems hanging up as there is no comment and nothing happens...
have i missed something ...?
Charlie
|
Back to top
|
|
 |
Iguleder

Joined: 11 Aug 2009 Posts: 2031 Location: Israel, somewhere in the beautiful desert
|
Posted: Sun 02 Jun 2013, 12:45 Post subject:
|
|
Yep, two things:
- It doesn't output anything.
- It still doesn't draw icons for existing partitions, only for newly added ones.
_________________ My homepage
My GitHub profile
|
Back to top
|
|
 |
jamesbond
Joined: 26 Feb 2007 Posts: 3146 Location: The Blue Marble
|
Posted: Sun 02 Jun 2013, 13:25 Post subject:
|
|
@charlie6
To display existing partitions you need to re-trigger udev. See my comment for Karl, in the previous page.
_________________ Fatdog64, Slacko and Puppeee user. Puppy user since 2.13.
Contributed Fatdog64 packages thread.
|
Back to top
|
|
 |
charlie6

Joined: 30 Jun 2008 Posts: 1199 Location: Saint-Gérard / Walloon part of Belgium
|
Posted: Sun 02 Jun 2013, 17:57 Post subject:
|
|
@Iguleder & Jamesbond
thanks for your help!
it works as expected ...how fast .. ... and believe i will keep it for a while, even if some icons have falled outside the desktops bottom edge ...
see attached screenshot (wheezy-3.5.2.5 1280x1024 resolution)
installation:
all files placed in /usr/bin (after compilation !!)
+
symlinked /usr/bin/part-hotplug-monitor to /sbin/part-hotplug-monitor
+
disactivated /sbin/pup_event_frontend_d
+
renamed it /sbin/pup_event_frontend_d.txt
+
renamed the symlink /sbin/part-hotplug-monitor to /sbin/pup_event_frontend_d
Pmount helps for opening disk that are not displayed (red circled); sdb1 to sdc10 have been plugged after above installation ended.
doing afterwards in console (thanks 2 Jamesbond):
Code: | udevadm trigger --action=add |
results in sda1 to sda6 icons to be displayed;
have manualy reorderd the icons as shown;
Menu/restart X process is much slower ---> be patient !
cheers, charlie
Description |
|
Filesize |
26.25 KB |
Viewed |
431 Time(s) |

|
Description |
|
Filesize |
29.77 KB |
Viewed |
434 Time(s) |

|
|
Back to top
|
|
 |
charlie6

Joined: 30 Jun 2008 Posts: 1199 Location: Saint-Gérard / Walloon part of Belgium
|
Posted: Sun 02 Jun 2013, 18:21 Post subject:
|
|
re-Hi...
1. unplugging and plugging again results in ... a kind of icons "overpopulating" of the desktop...
2. clicking on the X in the icon does not unmount it. Pmount is the only way to unmount?
3. how to erase them when unplugged ...?
restart X does not help....
last edited:
...3.(follow and solved) unplugging the usb flash plugs ---> the corresponding icons switch off ...only the first displayed set remains. OK i understand: this first set displayed, in the above post procedure, upon plugging a flash plug + an usb hdd, before doing « #udevadm trigger --action=add » in console.
So do « #udevadm trigger --action=add » BEFORE plugging.
(for info: i just had to right click on the extra icons and then click «remove item» to erase .
and
4. cd-or-dvd-inserted's icons are not (yet ...?) displayed. I had a dvd inserted along the whole above procedure and not any «sr0» nor «sr1» icon. Yes...the present part-icon-handler manages only USB plugged stuffs, no optical devices.
At this state of art, use of Pmount to manage them.
cheers
 |
Description |
|
Filesize |
22.63 KB |
Viewed |
287 Time(s) |

|
Last edited by charlie6 on Sun 02 Jun 2013, 23:34; edited 1 time in total
|
Back to top
|
|
 |
seaside
Joined: 11 Apr 2007 Posts: 917
|
Posted: Sun 02 Jun 2013, 23:31 Post subject:
|
|
Iguleder,
Very nice work.
I decided to test this by a normal startup, killing pup_event_frontend_d, and then starting part-hotplug-monitor and plugging in a thumb drive.
Since the icon came up on the left just below "connect", I made some changes in the part-icon script to locate the icon in line with the other drives.
As there was no direct way to unmount the drive, I also made some changes to toggle unmounting by left clicking.
First click, mounts and starts the file manager, second click unmounts the drive....etc..
Other possibilities exist to specify the icon x,y position somewhere else as well.
All the programs are in /usr/bin with no symlinks
Thanks again for this simple direct approach.
Regards,
s
Code: | #!/bin/sh
# part-icon: a utility script for adding and removing ROX-Filer pinboard icons
# for partitions
# modded to toggle mount and icon placement
# the ROX-Filer command line used for RPC
ROX_RPC_COMMAND_LINE="rox -R"
# _get_partition_icon()
# purpose: determines which icon should be used to represent a partition
# input : the mount point and device node path of a partition
# output : an icon path
_get_partition_icon() {
# choose the partition icon, according to the device node name
case "$2" in
*floppy*)
type="floppy"
;;
*mmc*)
type="card"
;;
*cdrom*|*sr*)
type="optical"
;;
*sd*)
type="usbdrv"
;;
*)
type="drive"
;;
esac
# if the partition is mounted, add a suffix to the icon name
mountpoint -q "$1"
if [ 0 -eq $? ]
then
suffix="_mntd"
else
suffix=""
fi
echo -n "/usr/local/lib/X11/pixmaps/${type}${suffix}48.png"
}
# _update_partition_icon()
# purpose: changes the icon of a partition to the most suitable one
# input : a partition name
# output: -
_update_partition_icon() {
echo -n "<?xml version=\"1.0\"?>
<env:Envelope xmlns:env=\"http://www.w3.org/2001/12/soap-envelope\">
<env:Body xmlns=\"http://rox.sourceforge.net/SOAP/ROX-Filer\">
<SetIcon>
<Path>$HOME/.part-hotplug-handler/$1</Path>
<Icon>$(_get_partition_icon /mnt/$1 $1)</Icon>
</SetIcon>
</env:Body>
</env:Envelope>" | $ROX_RPC_COMMAND_LINE
}
case "$1" in
add)
# check the command-line usage
if [ 3 -ne $# ]
then
echo "Usage: part-icon remove PARTITION DEVICE_NODE"
exit 1
fi
# create a directory for the partition mounting scripts
[ ! -d $HOME/.part-hotplug-handler ] && \
mkdir $HOME/.part-hotplug-handler
# create the partition mounting script
echo -n "#!/bin/sh
if ! [ -d /mnt/$2 ] # check whether mount dir exists
then
# create a mount point
mkdir /mnt/$2
[ 0 -ne \$? ] && exit 1
# mount the partition
mount \"$3\" /mnt/$2
[ 0 -ne \$? ] && exit 1
xdg-open /mnt/$2
# mark icon mounted
part-icon update $2
else # check if mounted
if mountpoint -q /mnt/$2
then
umount /mnt/$2
[ 0 -ne \$? ] && exit 1
# change icon to unmounted
part-icon update $2
else
mount \"$3\" /mnt/$2
[ 0 -ne \$? ] && exit 1
xdg-open /mnt/$2
# mark icon mounted
part-icon update $2
fi
fi
" > $HOME/.part-hotplug-handler/$2
chmod 755 $HOME/.part-hotplug-handler/$2
# set the icon used
_update_partition_icon $2
# align to bottom icons
line=`grep 'label=\"[[:alpha:]]\{3\}[0-9]' /root/Choices/ROX-Filer/PuppyPin | head -n 1`
x=${line#*\"} x=${x%%\"*}
x=$((x+64)) y=704
# add a pinboard icon
echo -n "<?xml version=\"1.0\"?>
<env:Envelope xmlns:env=\"http://www.w3.org/2001/12/soap-envelope\">
<env:Body xmlns=\"http://rox.sourceforge.net/SOAP/ROX-Filer\">
<PinboardAdd>
<Path>$HOME/.part-hotplug-handler/$2</Path>
<Label>$2</Label>
<X>$x</X> <Y>$y</Y>
<Args></Args>
</PinboardAdd>
</env:Body>
</env:Envelope>" | $ROX_RPC_COMMAND_LINE
;;
remove)
# check the command-line usage
if [ 2 -ne $# ]
then
echo "Usage: part-icon remove PARTITION"
exit 1
fi
# unmount the partition and delete the mount point
if [ -d /mnt/$2 ]
then
mountpoint -q /mnt/$2
if [ 0 -eq $? ]
then
umount /mnt/$2
[ 0 -eq $? ] && rmdir /mnt/$2
fi
fi
# remove the pinboard icon
echo -n "<?xml version=\"1.0\"?>
<env:Envelope xmlns:env=\"http://www.w3.org/2001/12/soap-envelope\">
<env:Body xmlns=\"http://rox.sourceforge.net/SOAP/ROX-Filer\">
<PinboardRemove>
<Path>$HOME/.part-hotplug-handler/$2</Path>
<Args></Args>
</PinboardRemove>
</env:Body>
</env:Envelope>" | $ROX_RPC_COMMAND_LINE
# remove the partition mounting script
rm -f $HOME/.part-hotplug-handler/$2
;;
update)
# check the command-line usage
if [ 2 -ne $# ]
then
echo "Usage: part-icon update PARTITION"
exit 1
fi
# update the partition icon
_update_partition_icon "$2"
;;
esac |
|
Back to top
|
|
 |
charlie6

Joined: 30 Jun 2008 Posts: 1199 Location: Saint-Gérard / Walloon part of Belgium
|
Posted: Mon 03 Jun 2013, 01:15 Post subject:
|
|
Hi seaside,
thanks a lot !
i replaced the existing part-icon by yours
and
deleted the symlink /sbin/pup_event_frontend_d to /usr/bin/part-hotplug-monitor;
afterwards creted a script to exec /usr/bin/part-hotplug-monitor and placed it in /root/Startup and rebooted.
I then plugged some thumb drives and got them each twice displayed ...
i even did « #udevadm trigger --action=add » or « #udevadm trigger --action=change » before plug-in without change.
questions:
Quote: | and then starting part-hotplug-monitor |
which way do you start part-hotplug-monitor?
Quote: | First click, mounts and starts the file manager, second click unmounts the drive....etc.. |
whatever right or left click, here it mounts and opens a rox-window at first click, but no unmount at second click; got a second rox-window opened instead.
Maybe had better to start all over from the beginning ..?
cheers
last edited:
icon display versus Pmount status at start: see screenshot below:
«sdc1=mounted» icon whereas Pmount reprots «not mounted»
Description |
|
Filesize |
22.76 KB |
Viewed |
402 Time(s) |

|
|
Back to top
|
|
 |
charlie6

Joined: 30 Jun 2008 Posts: 1199 Location: Saint-Gérard / Walloon part of Belgium
|
Posted: Mon 03 Jun 2013, 03:06 Post subject:
|
|
re-re-Hi
using forum member seaside's part-icon
+
no symlink to part-hot-plug-monitor (pup_event-frontend_d = «killed»)
+
part-hot-plug-monitor started from /root/Startup:
follow...
i manualy erased (right-click on icon + remove object) the extra icons set;
then rebooted;
the icons are now displayed one each.
(time to shutdown is here long..long..long..be patient)
Cheers
|
Back to top
|
|
 |
Karl Godt

Joined: 20 Jun 2010 Posts: 4208 Location: Kiel,Germany
|
Posted: Mon 09 Jun 2014, 02:59 Post subject:
|
|
The whole udevadm --trigger is complete garbage !
:
Code: | for anU in `ls -1v /sys/block/*/*/uevent`; do
echo add >$anU; sleep 0.3; done; |
and same for "echo remove" ie /sbin/clean_desk_icons
This uses the '-v' switch of `ls' to sort the partition numbers.
What is missing is maybe a second
#define PARTITION_DEVTYPE "partition"
for "disk" :
E: DEVTYPE=disk
E: DEVNAME=/dev/sr0
E: ID_CDROM=1
E: ID_TYPE=cd
E: ID_INSTANCE=0:0
E: ID_BUS=usb
And part-icon could have such code adjusts:
Code: | # check the VARIABES
if [ "$DEVNAME" ]; then
:
elif [ "$DEVPATH" ]; then
DEVNAME="/dev/${DEVPATH##*/}"
else echo "$0:Error:Need UDEV's DEVNAME or DEVPATH"; exit 1;
fi
#DEVPATH=/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda19
#echo "DEVPATH=$DEVPATH"
#echo "DEVNAME=$DEVNAME"
# create unique path for ROX
test -d $HOME/.pup_event/drive_${DEVNAME##*/} || mkdir -p $HOME/.pup_event/drive_${DEVNAME##*/}
test -f $HOME/.pup_event/drive_${DEVNAME##*/}/mount-and-open -a -x $HOME/.pup_event/drive_${DEVNAME##*/}/mount-and-open || cp -a /sbin/mount-and-open $HOME/.pup_event/drive_${DEVNAME##*/}/
case "$ACTION" in
add)
# guess the fs type and don't process further if undesired -
# set guessfstype as you wish and adjust grep pattern
guessfstype=guess_fstype
$guessfstype $DEVNAME | grep -iE "unknown|none|swap|Extended|Ext'd" && exit 0
|
Code: | # check for usb
if test -e /sys/block/${DEVNAME##*/}; then
realPATH=`realpath /sys/block/${DEVNAME##*/}`
elif test -e "/sys/block/`echo ${DEVNAME##*/} | sed 's/[0-9]*$//'`/${DEVNAME##*/}"; then
realPATH=`realpath /sys/block/$(echo ${DEVNAME##*/} | sed 's/[0-9]*$//')/${DEVNAME##*/}`
fi
case "$realPATH" in
*usb*) kDRIVE=usb;;
*) :;;
esac
# check for removable
if test -f /sys/block/${DEVNAME##*/}/removable; then
read removABLE< /sys/block/${DEVNAME##*/}/removable
fi
case "$removeABLE" in
1) kDRIVE="${kDRIVE}cd";;
*) :;;
esac
case $ID_BUS in
usb) :;;
scsi) :;; #SATA HDD
esac
case $ID_TYPE in
cd) :;; # CD
disk) :;; # HDD USB flash pendrive
esac
case $ID_CDROM in
1):;;
esac
case $ID_VENDOR in
ATA) :;; # internal (S)ATA
USB) :;; #
esac |
My experiences with Xorg s with udev dependencies brought me back here .
Have never encountered USB-FDD and such bizarre devices .
For IDE I could find out .
At the moment at reworking parts of /init - so am occupied with other things for the next times .
|
Back to top
|
|
 |
|