#!/bin/sh #pupmtp written by mistfire. Interface and behavior based from pmount for Puppy 4.0 #manage mtp devices #using ${$} which is pid of script... MYPID=${$} . /etc/rc.d/PUPSTATE #v3.96 [ ! -e /media ] && mkdir /media ALLPS="`ps`" OLDPIDS="`echo "$ALLPS" | grep 'gtkdialog' | grep 'PMTPGUI' | tr -s ' ' | sed -e 's%^ %%' | cut -f 1 -d ' ' | tr '\n' ' '`" kill $OLDPIDS 2>/dev/null /usr/lib/gtkdialog/box_splash -close never -text "Probing MTP devices..." & xPID=$! sleep 3s kill $xPID if [ "`which simple-mtpfs`" ];then simple-mtpfs -l | sed -e "s#\ #_#g" -e "s#^_##g" -e "s#:_#:#g"> /tmp/mtp-devices else /usr/lib/gtkdialog/box_ok "PupMTP" error "$(gettext "The 'simple-mtpfs' application is not installed.")" "$(gettext "That means PupMTP cannot access the files on a mtp device. Please run the Puppy Package Manager (see 'install' icon on desktop) to install 'simple-mtpfs' and it's dependencies.")" exit fi content=`cat /tmp/mtp-devices` MTPCNT=1 for d1 in `cat /tmp/mtp-devices | sort`; do portmtp=`echo "$d1" | cut -f 1 -d ":"` echo $portmtp DEVNAME=`echo "$d1" | cut -f 2 -d ":"` ONEMNTPT=`mount | grep /media/mtpdev${MTPCNT}` if [ "$ONEMNTPT" = "" ];then #not mounted. PARTSGUI="${PARTSGUI}" else #${DRIVEXPM} PARTSGUI="${PARTSGUI}" fi MTPCNT=`echo $(expr $MTPCNT + 1)` done if [ "$PARTSGUI" == "" ]; then PARTSGUI="" fi export PMTPGUI=" `/usr/lib/gtkdialog/xml_info fixed phone_mobile.svg 40 \"DO NOT REMOVE MOUNTED MEDIA\" \"$(gettext 'You may have to close your file manager to close the MTP device correctly')\"` ${PARTSGUI} " . /usr/lib/gtkdialog/xml_info gtk #build bg_pixmap for gtk-theme RETPARAMS="`gtkdialog --program=PMTPGUI --center --styles=/tmp/gtkrc_xml_info.css`" rm -f /tmp/mtp-devices #echo "$RETPARAMS" result=`echo $RETPARAMS | grep "refresh"` if [ "$result" != "" ]; then $0 fi ###END###