I will put here some diff lines to clean up my pup_event_frontend_d experiments and sync it to my dozen installations, which all look differently .
Today some lines to reduce writing to /tmp/ .
Variables should be kept inside the program .
This is relevant mostly for Puppy running non-RAM .
Varibles are
BLOCKDIFF ,
which reduces the usage of some external binaries like diff , which outputs differently in busybox and regular diff , which would needs adjustments if busybox ash would be configured full-featured and use applets first .
and
CURPOS[1|2] .
Code: Select all
@@ -492,6 +492,11 @@ if [ "$BACKENDON" = "false" ];then #see
fi
[ "$HOTPLUGON" = "false" ] && exit #turn off all frontend hotplug support. see /etc/eventmanager.
+#ls -1 --hide=ram* --hide=loop* /sys/block > /tmp/pup_event_frontend_block2
+#cp /tmp/pup_event_frontend_block2 /tmp/pup_event_frontend_block1
+
+BLOCK1=`ls -1 --hide=ram* --hide=loop* /sys/block`
+CURPOS1=`getcurpos`
###################################################################
#now go into a two-second loop...
@@ -503,31 +508,35 @@ do
[ -f /tmp/wmexitmode.txt ] && break
#test for any change in /sys/block...
- ls -1 --hide=ram* --hide=loop* /sys/block > /tmp/pup_event_frontend_block2
+ #ls -1 --hide=ram* --hide=loop* /sys/block > /tmp/pup_event_frontend_block2
+ BLOCK2=`ls -1 --hide=ram* --hide=loop* /sys/block`
if [ -f /tmp/pup_event_frontend_block_request ];then #w015
sleep 0.1
REMOVEBLOCK='^'"`cat /tmp/pup_event_frontend_block_request`"'$'
- BLOCKS2="`grep -v "$REMOVEBLOCK" /tmp/pup_event_frontend_block2`"
- echo "$BLOCKS2" > /tmp/pup_event_frontend_block2
+ BLOCK2=`echo "$BLOCK2" | grep -v "$REMOVEBLOCK"`
+ #BLOCKS2="`grep -v "$REMOVEBLOCK" /tmp/pup_event_frontend_block2`"
+ #echo "$BLOCKS2" > /tmp/pup_event_frontend_block2
rm -f /tmp/pup_event_frontend_block_request
fi
- [ ! -f /tmp/pup_event_frontend_block1 ] && cp /tmp/pup_event_frontend_block2 /tmp/pup_event_frontend_block1
- BLOCKDIFF="`diff /tmp/pup_event_frontend_block1 /tmp/pup_event_frontend_block2`"
-
+ #[ ! -f /tmp/pup_event_frontend_block1 ] && cp /tmp/pup_event_frontend_block2 /tmp/pup_event_frontend_block1
+ #BLOCKDIFF="`diff /tmp/pup_event_frontend_block1 /tmp/pup_event_frontend_block2`"
+
#########hotplug block event##########
- if [ "$BLOCKDIFF" != "" ];then
-
- cp -f /tmp/pup_event_frontend_block2 /tmp/pup_event_frontend_block1
-
- BLOCKSADD="`echo "$BLOCKDIFF" | grep '^> ' | cut -f 2-9 -d ' ' | tr '\n' ' '`"
- BLOCKSREM="`echo "$BLOCKDIFF" | grep '^< ' | cut -f 2-9 -d ' ' | tr '\n' ' '`"
-
+ #if [ "$BLOCKDIFF" != "" ];then
+ if [ "$BLOCK1" != "$BLOCK2" ] ; then
+ #cp -f /tmp/pup_event_frontend_block2 /tmp/pup_event_frontend_block1
+ #BLOCKSADD="`echo "$BLOCKDIFF" | grep '^> ' | cut -f 2-9 -d ' ' | tr '\n' ' '`"
+ BLOCKSADD=`echo "$BLOCK2" | grep -v "$BLOCK1"`
+ #BLOCKSREM="`echo "$BLOCKDIFF" | grep '^< ' | cut -f 2-9 -d ' ' | tr '\n' ' '`"
+ BLOCKSREM=`echo "$BLOCK1" | grep -v "$BLOCK2"`
+ BLOCK1="$BLOCK2"
+
ACTION=add
SUBSYSTEM=block
DEVTYPE=disk
for DRV_NAME in $BLOCKSADD
do
- [ ! -e /sys/block/$DRV_NAME ] && continue #precaution
+ [ -e /sys/block/$DRV_NAME ] || continue #precaution
DEVPATH=/block/$DRV_NAME
odPATTERN='^/dev/'"$DRV_NAME"'|'
PROBEDISK="`probedisk2`"
@@ -538,7 +547,7 @@ do
[ "$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.
done
-
+
ACTION=remove
for DRV_NAME in $BLOCKSREM
do
@@ -554,7 +563,7 @@ do
remove_pinboard_func #needs DRV_NAME
rm -rf /root/.pup_event/drive_${DRV_NAME}* 2>/dev/null
done
-
+
fi
if [ $TOGGLE -eq 0 ];then #slow down to every 4 seconds.
@@ -576,8 +585,8 @@ do
if [ $MINUTECNT -gt 59 ];then #come in here every minute...
MINUTECNT=0
CURPOS2="`getcurpos`"
- echo "MOUSECNT=$MOUSECNT CURPOS2=$CURPOS2" >> /tmp/pup_event_frontend_d_curpos.log
- [ "$CURPOS1" = "" ] && CURPOS1="$CURPOS2"
+ #echo "MOUSECNT=$MOUSECNT CURPOS2=$CURPOS2" >> /tmp/pup_event_frontend_d_curpos.log
+ #[ "$CURPOS1" = "" ] && CURPOS1="$CURPOS2"
[ "$CURPOS1" != "$CURPOS2" ] && MOUSECNT=0
CURPOS1="$CURPOS2"
[ $MOUSECNT -gt $POWERTIMEOUT ] && wmpoweroff &
@@ -589,7 +598,7 @@ do