Author |
Message |
Flash
Official Dog Handler

Joined: 04 May 2005 Posts: 13389 Location: Arizona USA
|
Posted: Sun 03 Jul 2005, 14:58 Post subject:
|
|
Will this work with any version of Icewm, on any version of Puppy?
I need to know for the index. Thanks.
|
Back to top
|
|
 |
GuestToo
Puppy Master
Joined: 04 May 2005 Posts: 4078
|
Posted: Sun 03 Jul 2005, 15:33 Post subject:
|
|
this line in AppRun will create /root/.Trash if it doesn't exist:
[ -d /root/.Trash ] || mkdir /root/.Trash
changing the trash icon (full, empty) is easy ... getting rox to show the changed icon, rather than a cached version of the old icon, is harder
|
Back to top
|
|
 |
dvw86

Joined: 04 May 2005 Posts: 636 Location: Washington State
|
Posted: Sun 03 Jul 2005, 15:39 Post subject:
|
|
Flash wrote: | Will this work with any version of Icewm, on any version of Puppy?
I need to know for the index. Thanks. |
It will now run in any window manager (I've tested it in Jwm and Fvwm95). It should also run in any version of Puppy, but I've only tested it in 1.0.3.
|
Back to top
|
|
 |
dvw86

Joined: 04 May 2005 Posts: 636 Location: Washington State
|
Posted: Sun 03 Jul 2005, 15:46 Post subject:
|
|
GuestToo wrote: | this line in AppRun will create /root/.Trash if it doesn't exist:
[ -d /root/.Trash ] || mkdir /root/.Trash
changing the trash icon (full, empty) is easy ... getting rox to show the changed icon, rather than a cached version of the old icon, is harder |
Thanks, I'll add that to it. How would I go about changing the icons based on the contents of root/.Trash? My first thought is that I would I check for the size of the directory and anything over 0 bytes be considered full. I don't know how I would then set the icon though.
|
Back to top
|
|
 |
dvw86

Joined: 04 May 2005 Posts: 636 Location: Washington State
|
Posted: Sun 03 Jul 2005, 18:26 Post subject:
|
|
I now have the icon changing every time something is added to the trash and when the trash is emptied. There are a couple of issues though.
First is that the icon isn't updated until you mouse over the trash icon (just like the Filer windows).
Second is that the application HAS to be placed in /root/my-applications/bin
Here is the code. Any recommendations? Any body know how to get rox to refresh icons from a shell command?
Code: |
#!/bin/sh
# July 2, 2005 - Dan Van Wormer - Puppy Linux
[ -d /root/.Trash ] || mkdir /root/.Trash
test -sd "$@"
if [ "$?" = "0" ]
then
exec rox /root/.Trash
else mv "$@" /root/.Trash/
cp /root/my-applications/bin/Trash/trashcan_full.png /root/my-applications/bin/Trash/.DirIcon
fi
if [ "$1" = "-empty" ]
then
rm -r /root/.Trash/*
cp /root/my-applications/bin/Trash/trashcan_empty.png /root/my-applications/bin/Trash/.DirIcon
fi
|
|
Back to top
|
|
 |
GuestToo
Puppy Master
Joined: 04 May 2005 Posts: 4078
|
Posted: Sun 03 Jul 2005, 20:20 Post subject:
|
|
putting these lines in AppRun:
APPDIR=`dirname "$0"`
cd "$APPDIR"
APPDIR="`pwd`"
should set $APPDIR to the dir AppRun is in
although you can have problems if the dir has spaces in the name
so a copy command like this should work:
cp -f "$APPDIR/trashcan_empty.png" "$APPDIR/.DirIcon"
or since you have already cd'ed to $APPDIR, maybe:
cp -f trashcan_empty.png .DirIcon
(the reason to cd to $APPDIR then `pwd`, is to make the path in $APPDIR absolute, rather than relative ... if you don't care if the path is absolute or relative, then
APPDIR=`dirname "$0"`
would probably work)
(export APPDIR if you need $APPDIR in sub-processes)
i don't know if there's a practical way to get the icon to refresh ... restarting the pinboard should work, kinda drastic though
maybe the -x option works (type rox -h for help)
something like:
rox -x .DirIcon
or:
rox -x "$APPDIR/.DirIcon"
|
Back to top
|
|
 |
dvw86

Joined: 04 May 2005 Posts: 636 Location: Washington State
|
Posted: Sun 03 Jul 2005, 23:51 Post subject:
|
|
I have updated the application to automatically create /root/.Trash if it does not already exist. The trash icon will now change based on if it is full or empty. It also does not matter where the application resides. In order to automatically update the icon I automatically restart the Pinboard. On my system this just causes a slight flicker of the desktop icons. I have not seen any ill side effects. Please let me know if there are any issues with doing this. It may take longer on slower systems. I could not get rox -x "$APPDIR/.DirIcon" to work.
Here is the code.
Code: |
#!/bin/sh
# July 2, 2005 - Dan Van Wormer - Puppy Linux
# Create the >Trash directory if it does not already exist.
[ -d /root/.Trash ] || mkdir /root/.Trash
# Determine the path to this application.
APPDIR=`dirname "$0"`
cd "$APPDIR"
APPDIR="`pwd`"
# Check to see if they clicked on the application or sent a file or directory to be deleted.
test -sd "$@"
if [ "$?" = "0" ]
then
exec rox /root/.Trash
else mv "$@" /root/.Trash/
cp -f "$APPDIR/trashcan_full.png" "$APPDIR/.DirIcon"
rox -o -p /root/Choices/ROX-Filer/PuppyPin
fi
# If they chose the "Empty the Trash" option.
if [ "$1" = "-empty" ]
then
rm -r /root/.Trash/*
cp -f "$APPDIR/trashcan_empty.png" "$APPDIR/.DirIcon"
rox -o -p /root/Choices/ROX-Filer/PuppyPin
fi
|
EDIT File removed. Download final copy here
Last edited by dvw86 on Mon 18 Jul 2005, 20:10; edited 1 time in total
|
Back to top
|
|
 |
GuestToo
Puppy Master
Joined: 04 May 2005 Posts: 4078
|
Posted: Mon 04 Jul 2005, 01:17 Post subject:
|
|
i haven't tried your latest version, but if you restart the pinboard from a dir other than $HOME, it might change what rox thinks is $HOME
you might want to check that when you click the rox icon, it opens a window showning $HOME (/root) and that clicking the home button goes to /root
in other words, if might be better to
cd ${HOME}
before restarting the pinboard
also, if someone is using a non-standard pinboard
(i once had 3 or 4 desktops, with icons to flip from one to another ... rox -op 1 ... rox -op 2 ... rox -op 3), your program would switch from the non-standard pinboard to the standard Puppy pinboard
which is probably not important, but it is another thing to think about when you write a program
|
Back to top
|
|
 |
dvw86

Joined: 04 May 2005 Posts: 636 Location: Washington State
|
Posted: Mon 04 Jul 2005, 02:24 Post subject:
|
|
GuestToo wrote: | i haven't tried your latest version, but if you restart the pinboard from a dir other than $HOME, it might change what rox thinks is $HOME
you might want to check that when you click the rox icon, it opens a window showning $HOME (/root) and that clicking the home button goes to /root
in other words, if might be better to
cd ${HOME}
before restarting the pinboard
|
I have tested it on two systems so far and rox still goes to /root as $HOME so it shouldn't be an issue but I will add cd ${HOME} just to be on the safe side.
Puppy running on my iBook in Virtual PC is equivalent to a 200MHz PII or slower. Restarting the Pinboard on that system is definitely more than just a flicker. I may have two versions of Trash. One for faster hardware (my 800MHz VIA for example) that restarts the Pinboard, and another for slower hardware (200MHz and less) that requires you to mouse over the icon for it to be updated. The last thing to work on is the numerical increments of duplicate names in the trash. Once that is done (if I can get it to work ) I will put it into a DotPup and post it on the Wiki.
|
Back to top
|
|
 |
dvw86

Joined: 04 May 2005 Posts: 636 Location: Washington State
|
Posted: Mon 04 Jul 2005, 19:43 Post subject:
|
|
Well I think this is it. I had to change the logic a little because it was changing the icon twice when emptying the trash. While this didn't hurt anything it made things just that much slower on older hardware. It will now add a unique number to the end of anything being sent to the Trash. This is to prevent files from being over written. When right clicking the trash icon you now have two choices. The first choice (Empty the Trash) will display every thing in the Trash and ask for confirmation before deleting them. The second option (Quickly Empty the Trash) does not display a list of items and does not ask for confirmation. Lastly it also plays a little sound when things are sent to the Trash and when the Trash is emptied. If this meets with approval I will make it a Dotpup and also a Simple-Trash Dotpup that does not restart the pinboard and does not have the sound file. Here is the code.
Code: |
#!/bin/sh
# July 4, 2005 - Dan Van Wormer - Puppy Linux
# Create the >Trash directory if it does not already exist.
[ -d /root/.Trash ] || mkdir /root/.Trash
# Determine the path to this application.
APPDIR=`dirname "$0"`
cd "$APPDIR"
APPDIR="`pwd`"
# If they chose the "Empty the Trash" option.
if [ "$1" = "-empty" ]
then
# See what is in the trash.
stuff=`ls /root/.Trash`
# Wright the confirmation message.
MSG=`which gxmessage` || MSG=xmessage
$MSG -buttons "Delete:21,Cancel" -center -geometry 300x300 -title "Confirm Delete" "$stuff"
# If they chose to cancel.
[ $? -eq 21 ] || exit
# If they chose to delete.
rm -r /root/.Trash/*
cp -f "$APPDIR/trashcan_empty.png" "$APPDIR/.DirIcon"
cd ${HOME}
rox -o -p /root/Choices/ROX-Filer/PuppyPin
play.tcl $APPDIR/systemmsg.wav
# If they chose to "Quickly Empty the Trash".
elif [ "$1" = "-empty-quick" ]
then
rm -r /root/.Trash/*
cp -f "$APPDIR/trashcan_empty.png" "$APPDIR/.DirIcon"
cd ${HOME}
rox -o -p /root/Choices/ROX-Filer/PuppyPin
play.tcl $APPDIR/systemmsg.wav
else
# Check to see if they clicked on the application or sent a file or directory to be deleted.
test -sd "$@"
if [ "$?" = "0" ]
then
# If they just clicked on the icon.
exec rox /root/.Trash
else
# If they sent something to the trash can.
mv "$@" "$@-$$"
mv "$@-$$" "/root/.Trash/"
cp -f "$APPDIR/trashcan_full.png" "$APPDIR/.DirIcon"
cd ${HOME}
rox -o -p /root/Choices/ROX-Filer/PuppyPin
play.tcl $APPDIR/systemmsg.wav
fi
fi
fi
|
EDIT File removed. Download final copy here
Last edited by dvw86 on Mon 18 Jul 2005, 20:11; edited 1 time in total
|
Back to top
|
|
 |
Flash
Official Dog Handler

Joined: 04 May 2005 Posts: 13389 Location: Arizona USA
|
Posted: Mon 04 Jul 2005, 20:58 Post subject:
|
|
Just let me know when it's ready for the index.
|
Back to top
|
|
 |
papaschtroumpf

Joined: 17 Jun 2005 Posts: 250
|
Posted: Mon 04 Jul 2005, 21:04 Post subject:
|
|
does it work for non-root users?
_________________ Mandriva LE 2005 user and puppy newbie
|
Back to top
|
|
 |
dvw86

Joined: 04 May 2005 Posts: 636 Location: Washington State
|
Posted: Mon 04 Jul 2005, 21:39 Post subject:
|
|
papaschtroumpf wrote: | does it work for non-root users? |
To tell the truth I don't know since you always run as root in Puppy. As long as the application can read and write to /root it should work.
|
Back to top
|
|
 |
dvw86

Joined: 04 May 2005 Posts: 636 Location: Washington State
|
Posted: Tue 05 Jul 2005, 11:25 Post subject:
|
|
The "Complete Trash" application has been posted in the Dotpup thread.
http://www.murga.org/~puppy/viewtopic.php?p=5309#5309
|
Back to top
|
|
 |
papaschtroumpf

Joined: 17 Jun 2005 Posts: 250
|
Posted: Tue 05 Jul 2005, 11:38 Post subject:
|
|
dvw86 wrote: | papaschtroumpf wrote: | does it work for non-root users? |
To tell the truth I don't know since you always run as root in Puppy. As long as the application can read and write to /root it should work. |
Then the answer is no.
Or if the app has access to /root then it's a security risk (probably mean a user could see and erase root's trash files, no good).
_________________ Mandriva LE 2005 user and puppy newbie
|
Back to top
|
|
 |
|