| Author |
Message |
tytower

Joined: 24 Feb 2007 Posts: 433 Location: Green Island Cairns for the winter
|
Posted: Wed 16 Jan 2013, 16:17 Post subject:
Deleting files and trash etc |
|
When I right click I get a "delete" option to delete a file .
I would like all deleted files to go into the trash bin for say, a day , so that I could recover a file that I had deleted in error.
In fact noting the errors I have seen in Puppy where groups of files just disappear without explanation( probably because of something I have done anyway) it would be prudent to make all deleted files pass through trash anyway with an option to choose when the trash is emptied.
Can this be done at the moment?
_________________ Neither my Family nor my Property are Government issues. Governments should do what they were designed to do Manage the larger issues best done by Governments
To stop corruption give them 3 times the penalty. Get their agreement on first employment.
|
|
Back to top
|
|
 |
Hotdog

Joined: 29 Sep 2011 Posts: 60 Location: Georgia USA
|
Posted: Wed 16 Jan 2013, 21:05 Post subject:
|
|
tytower,
Most Puppies have Trash as an option in the right-click menu. What version of Puppy do you have? And, what type of installation? Maybe we can figure out how to get it back.
_________________ Puppy 528, Full Install
|
|
Back to top
|
|
 |
tytower

Joined: 24 Feb 2007 Posts: 433 Location: Green Island Cairns for the winter
|
Posted: Thu 17 Jan 2013, 03:38 Post subject:
|
|
I have 5.4.2 but I think you mean in Rox filer a trash can comes up next to the "delete" command . When you use this it does not go into trash it is deleted forever..I would like a trash can option on that right click menu at least but it would seem better to me to be able to trash it on all deletes and don't actually lose the file until a time has been reached or the user intentionally removes them to clear up space.
_________________ Neither my Family nor my Property are Government issues. Governments should do what they were designed to do Manage the larger issues best done by Governments
To stop corruption give them 3 times the penalty. Get their agreement on first employment.
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 569
|
Posted: Thu 17 Jan 2013, 09:00 Post subject:
|
|
You could try to play with this, but frankly I haven't used it since then and don't know if Darkcity has explored the subject deeper.
Regarding ROX-Filer's Trash - it depends on Puppy version.
Lucid, for instance, has it, but Slacko/Precise haven't.
If you'd like to add Trash to your right-click menu:
1. Safe, but inconvenient method:
Right-click a file/folder -> Customize Menu... -> drag'n'drop Trash icon from desktop into opened dir (create relative symlink).
It has to be repeated for each filetype.
2. Easy, but possibly unsafe method (I haven't had any problems with it, but it's better to make a backup before proceeding):
| Code: | #! /bin/bash
# Adds/removes Trash to the context menu
OpenWith_PATH="$HOME/.config/rox.sourceforge.net/OpenWith/"
case "$1" in
"add")
# Creates missing folders using 'globs' file contents
for i in `cat /usr/share/mime/globs | grep ":" | cut -f1 -d ':' | tr '/' '_' | uniq`; do
[ ! -d "$OpenWith_PATH"".""$i" ] && mkdir "$OpenWith_PATH"".""$i"
done
mkdir "$OpenWith_PATH"".inode_unknown"
# Creates symlink to the Trash in every folder
for i in `find "$OpenWith_PATH" -maxdepth 1 -type d -iname ".*"`; do
[ ! -L "$i/Trash" ] && ln -s /usr/local/apps/Trash "$i"
done
;;
"remove")
# Removes every symlink to the Trash and removes folder if empty
for i in `find "$OpenWith_PATH" -maxdepth 1 -type d -iname ".*"`; do
rm "$i/Trash"
[ ! "$(ls -A "$i")" ] && rmdir "$i"
done
;;
esac
exit |
Save it in /root/my-applications/bin/ as, eg. add_remove_trash.sh and:
a). To add Trash:
| Code: | | add_remove_trash.sh add |
b). To remove Trash:
| Code: | | add_remove_trash.sh remove |
It will automatically create Trash entries for each known and unknown filetype + folders.
EDIT: Small correction in code.
HTH
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
|
Back to top
|
|
 |
tytower

Joined: 24 Feb 2007 Posts: 433 Location: Green Island Cairns for the winter
|
Posted: Thu 17 Jan 2013, 17:54 Post subject:
|
|
Works brilliantly . Thanks very much !
How would I get trash to emty automatically say in 2 days time ?
_________________ Neither my Family nor my Property are Government issues. Governments should do what they were designed to do Manage the larger issues best done by Governments
To stop corruption give them 3 times the penalty. Get their agreement on first employment.
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 569
|
Posted: Thu 17 Jan 2013, 20:01 Post subject:
|
|
| tytower wrote: | | How would I get trash to emty automatically say in 2 days time ? |
Hmm, perhaps something like this:
| Code: | #!/bin/bash
HOW_OLD=2 # in days
while true; do
find /root/.Trash -maxdepth 1 -and -not -name .Trash -ctime +"$HOW_OLD" -print0 | xargs -0 rm -rf
sleep 1h
done |
(save it as, eg. purge_trash.sh (no spaces in filename!) in /root/Startup/ and click to perform initial launch)
This script should search (every hour) for files/folders older than 2 days in /root/.Trash/ and delete them (if any).
But this one is really barely tested, so please be careful...
(btw, you can replace -ctime with -mmin to use minutes instead of days, but then adjust also the 'sleep' command)
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
|
Back to top
|
|
 |
tytower

Joined: 24 Feb 2007 Posts: 433 Location: Green Island Cairns for the winter
|
Posted: Fri 18 Jan 2013, 02:24 Post subject:
|
|
Can't be careful if I don't test the script so that warning covers your arse so thats good for you but it is pointless for me . . No Probs I'll give it a run for a few days and if my machine explodes I promise not to whine..
Thanks
_________________ Neither my Family nor my Property are Government issues. Governments should do what they were designed to do Manage the larger issues best done by Governments
To stop corruption give them 3 times the penalty. Get their agreement on first employment.
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 569
|
Posted: Fri 18 Jan 2013, 04:33 Post subject:
|
|
Good point - to cover also your's, you can try this instead:
1. Stop the existing script (ps | grep purge_trash and kill its process)
2. Create a directory /root/Moved_From_Trash
3. Replace the appropriate line with:
| Code: | | find /root/.Trash -maxdepth 1 -and -not -name .Trash -ctime +"$HOW_OLD" -print0 | xargs -0 mv -t /root/Moved_From_Trash 2>/dev/null |
4. Re-launch the script
This way you can see if files that are supposed to be deleted are the good ones for sure.
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Last edited by SFR on Fri 18 Jan 2013, 07:06; edited 1 time in total
|
|
Back to top
|
|
 |
tytower

Joined: 24 Feb 2007 Posts: 433 Location: Green Island Cairns for the winter
|
Posted: Fri 18 Jan 2013, 05:21 Post subject:
|
|
All done I'll let you know
Should that be "All of importance I carry with me "?
_________________ Neither my Family nor my Property are Government issues. Governments should do what they were designed to do Manage the larger issues best done by Governments
To stop corruption give them 3 times the penalty. Get their agreement on first employment.
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 569
|
Posted: Fri 18 Jan 2013, 06:34 Post subject:
|
|
Great! But you didn't tell me and I forgot to ask, and assumed that you've chosen the 'right-click -> Trash' method, not libtrash. Is that correct?
If so, all's fine. If not, the script simply won't work.
| Quote: | | Should that be "All of importance I carry with me "? |
Could be. I'm not an expert in Latin (far from that), but according to different sources: "All that is mine I carry with me" or "I carry all my things with me". But since I carry them, they must be somehow important.
EDIT:
I put -mmin instead of -ctime in the above line of code (leftover from testing).
Corrected now. Please replace it again, or all files from trash will be removed every hour. Sorry for inconvenience.
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
|
Back to top
|
|
 |
tytower

Joined: 24 Feb 2007 Posts: 433 Location: Green Island Cairns for the winter
|
Posted: Fri 18 Jan 2013, 17:29 Post subject:
|
|
Yes I left that (-mmin) there to prove it and it worked fine .
I'll have to look a bit closer at this though .
The new directory receives everything that was in the trash can so when opened the choices to open restore ,info ,delete,look inside etc come up . Something resets the trash can lid too when it is emptied so Ill try find that and add a line.
If you look inside you get all the "Appinfo.xml" link and "AppRun" file and "info" file for each trashed file and a Directory for the trashed file itself. I have yet to work out what is happening here but all that seems as it should be I suppose but the size of trash is increased by these as you tresh stuff. About 4.3K is added for each file put in there
Certainly it seems to empty Trash properly though as it should . Ill set up a better test over a longer time and let you know.
Thanks
_________________ Neither my Family nor my Property are Government issues. Governments should do what they were designed to do Manage the larger issues best done by Governments
To stop corruption give them 3 times the penalty. Get their agreement on first employment.
|
|
Back to top
|
|
 |
|