Lighweight pup_event_frontend_d Replacement

Under development: PCMCIA, wireless, etc.
Message
Author
User avatar
Iguleder
Posts: 2026
Joined: Tue 11 Aug 2009, 09:36
Location: Israel, somewhere in the beautiful desert
Contact:

#31 Post by Iguleder »

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? :D
Attachments
part-hotplug-handler.tar.bz2
(18.16 KiB) Downloaded 343 times
screeny.png
(47.37 KiB) Downloaded 461 times
[url=http://dimakrasner.com/]My homepage[/url]
[url=https://github.com/dimkr]My GitHub profile[/url]

simargl

#32 Post by simargl »

.
Last edited by simargl on Sun 01 Sep 2013, 15:13, edited 1 time in total.

User avatar
charlie6
Posts: 1230
Joined: Mon 30 Jun 2008, 04:03
Location: Saint-Gérard / Walloon part of Belgium

#33 Post by charlie6 »

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

User avatar
Iguleder
Posts: 2026
Joined: Tue 11 Aug 2009, 09:36
Location: Israel, somewhere in the beautiful desert
Contact:

#34 Post by Iguleder »

Yep, two things:
- It doesn't output anything.
- It still doesn't draw icons for existing partitions, only for newly added ones. :wink:
[url=http://dimakrasner.com/]My homepage[/url]
[url=https://github.com/dimkr]My GitHub profile[/url]

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#35 Post by jamesbond »

@charlie6
To display existing partitions you need to re-trigger udev. See my comment for Karl, in the previous page.
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

User avatar
charlie6
Posts: 1230
Joined: Mon 30 Jun 2008, 04:03
Location: Saint-Gérard / Walloon part of Belgium

#36 Post by charlie6 »

@Iguleder & Jamesbond
:)
thanks for your help!
it works as expected ...how fast .. 8) ... and believe i will keep it for a while, even if some icons have falled outside the desktops bottom edge ... :shock:
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: Select all

 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 ! :roll:
cheers, charlie
Attachments
part-mount.jpg
(26.25 KiB) Downloaded 455 times
part-mount_2.jpg
(29.77 KiB) Downloaded 458 times

User avatar
charlie6
Posts: 1230
Joined: Mon 30 Jun 2008, 04:03
Location: Saint-Gérard / Walloon part of Belgium

#37 Post by charlie6 »

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
Attachments
plug-unplug.jpg
(22.63 KiB) Downloaded 313 times
Last edited by charlie6 on Mon 03 Jun 2013, 03:34, edited 1 time in total.

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#38 Post by seaside »

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: Select all

#!/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 

User avatar
charlie6
Posts: 1230
Joined: Mon 30 Jun 2008, 04:03
Location: Saint-Gérard / Walloon part of Belgium

#39 Post by charlie6 »

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 ... :shock:

i even did « #udevadm trigger --action=add » or « #udevadm trigger --action=change » before plug-in without change.

questions:
and then starting part-hotplug-monitor
which way do you start part-hotplug-monitor?
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»
Attachments
start.jpg
(22.76 KiB) Downloaded 427 times

User avatar
charlie6
Posts: 1230
Joined: Mon 30 Jun 2008, 04:03
Location: Saint-Gérard / Walloon part of Belgium

#40 Post by charlie6 »

re-re-Hi :D

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

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#41 Post by Karl Godt »

The whole udevadm --trigger is complete garbage !
:

Code: Select all

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: Select all

# 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: Select all

        # 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 .

Post Reply