Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 14 Dec 2019, 07:58
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
ROX: How to send files to Trash
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [9 Posts]  
Author Message
MochiMoppel


Joined: 26 Jan 2011
Posts: 1946
Location: Japan

PostPosted: Thu 31 Jul 2014, 23:24    Post subject:  ROX: How to send files to Trash
Subject description: ...using the keyboard
 

Puppy's default deletion process (Ctrl+X) deletes files/folders permanently. The following keyboard shortcut (Ctrl+Shift+X) avoids the permanent deletion by sending files/folders to the Trash bin.

The shortcut doesn't use the clipboard, but uses xclip, which should be updated to handle non-ASCII filenames properly (see http://www.murga-linux.com/puppy/viewtopic.php?t=95018)

Step 1: Edit the file /root/.jwm/jwmrc-personal. Add the red lines:
    <Key mask="A" key="F1">root:3</Key>
    <Key mask="A" key="F2">window</Key>

    <Key mask="CS" key="x">exec:
    FPATHS=\"$(xclip -o|sed 's/[ ]*$//;s_ /_" "/_g')\"
    FCOUNT=$(echo "$FPATHS" | awk -F"\"/" '{print NF-1}'); ((FCOUNT))|| exit
    Xdialog --yesno "Send $FCOUNT file(s) to the Trash Bin?" 0 0 || exit
    eval /usr/local/apps/Trash/AppRun $FPATHS
    </Key>
Step 2: Restart JWM
SendToTrash.png
 Description   Select files and press Ctrl+Shift+X
 Filesize   96.77 KB
 Viewed   600 Time(s)

SendToTrash.png

Back to top
View user's profile Send private message 
Flash
Official Dog Handler


Joined: 04 May 2005
Posts: 13396
Location: Arizona USA

PostPosted: Fri 01 Aug 2014, 00:03    Post subject:  

How hard do you think would it be to incorporate this into Copy Fast? Would it even be worth doing?
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1946
Location: Japan

PostPosted: Fri 01 Aug 2014, 20:09    Post subject:  

This would be for don570 to decide, but I can't see why you would want to integrate it. CopyFast has a very limited scope (copies exactly 1 file/folder to 1 destination), and for that it uses a huge code overhead. If you want to use the context menu (as CopyFast does) there are much, much easier solutions.
Back to top
View user's profile Send private message 
nic007


Joined: 13 Nov 2011
Posts: 3200
Location: Cradle of Humankind

PostPosted: Fri 01 Aug 2014, 20:46    Post subject:  

Good but giving a choice to send to trash or delete permanently in the first place would be even better. Can this be done as it will be an improvement on the ways linux and windows do things by default? I have trash in my "open with" menu which should actually be "send to" for this purpose. I suppose your workaround only applies for keyboard usage?
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1946
Location: Japan

PostPosted: Sat 02 Aug 2014, 23:28    Post subject:  

nic007 wrote:
Good but giving a choice to send to trash or delete permanently in the first place would be even better. Can this be done as it will be an improvement on the ways linux and windows do things by default?
Yes, but my intention was to keep the code as simple a possible. This way it can be used as a template for any script/shortcut that needs a list of files selected in ROX as input.
Quote:
I suppose your workaround only applies for keyboard usage?
I don't see it as a "workaround" and keyboard shortcut is only one possible usage. If you like you can turn it into a desktop button or whatever you fancy.
Back to top
View user's profile Send private message 
nic007


Joined: 13 Nov 2011
Posts: 3200
Location: Cradle of Humankind

PostPosted: Sun 03 Aug 2014, 03:38    Post subject:  

So, how about giving a choice for starters (permanent delete or send to trash). Any ideas?
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1946
Location: Japan

PostPosted: Tue 05 Aug 2014, 23:44    Post subject:  

nic007 wrote:
So, how about giving a choice for starters (permanent delete or send to trash). Any ideas?

How about this?
Code:
<Key mask="CS" key="x">   exec:
   FPATHS=\"$(xclip -o|sed 's/[ ]*$//;s_ /_" "/_g')\"
   FCOUNT=$(echo "$FPATHS" | awk -F"\"/" '{print NF-1}'); ((FCOUNT))|| exit
   ANSWER=$(gxmessage -bg "#008080" -fg white -fn "bold 12" -center -print -buttons "Delete permanently":0,"Send to Trash":1,"Cancel":2 -default "Send to Trash" $'\n\t\t\tDelete '$FCOUNT' file(s) ?')
   case $ANSWER in
     "Delete permanently") ERR=$(eval rm -fr $FPATHS 2>&1) ;;
     "Send to Trash"     ) eval /usr/local/apps/Trash/AppRun $FPATHS ;;
   esac
   [ "$ERR" ] && gxmessage -name "Ups, smells like error" -bg red -fg white -center -buttons "OK":0 -default "OK" "$ERR"
</Key>


When deleting permanently, the script traps errors and shows a dialog with error messages. Doing the same for "Send to Trash" would be possible, but not practical: As if it where not enough to play an annoying barking sound whenever sending something to trash, the application also sends a bogus error message (translating into "I have just barked!"), which would turn such approach into an additional annoyance Crying or Very sad
Trash_Delete_Shortcut.png
 Description   
 Filesize   74.19 KB
 Viewed   465 Time(s)

Trash_Delete_Shortcut.png

Back to top
View user's profile Send private message 
nic007


Joined: 13 Nov 2011
Posts: 3200
Location: Cradle of Humankind

PostPosted: Fri 08 Aug 2014, 22:17    Post subject:  

MochiMoppel wrote:
nic007 wrote:
So, how about giving a choice for starters (permanent delete or send to trash). Any ideas?

How about this?
Code:
<Key mask="CS" key="x">   exec:
   FPATHS=\"$(xclip -o|sed 's/[ ]*$//;s_ /_" "/_g')\"
   FCOUNT=$(echo "$FPATHS" | awk -F"\"/" '{print NF-1}'); ((FCOUNT))|| exit
   ANSWER=$(gxmessage -bg "#008080" -fg white -fn "bold 12" -center -print -buttons "Delete permanently":0,"Send to Trash":1,"Cancel":2 -default "Send to Trash" $'\n\t\t\tDelete '$FCOUNT' file(s) ?')
   case $ANSWER in
     "Delete permanently") ERR=$(eval rm -fr $FPATHS 2>&1) ;;
     "Send to Trash"     ) eval /usr/local/apps/Trash/AppRun $FPATHS ;;
   esac
   [ "$ERR" ] && gxmessage -name "Ups, smells like error" -bg red -fg white -center -buttons "OK":0 -default "OK" "$ERR"
</Key>


When deleting permanently, the script traps errors and shows a dialog with error messages. Doing the same for "Send to Trash" would be possible, but not practical: As if it where not enough to play an annoying barking sound whenever sending something to trash, the application also sends a bogus error message (translating into "I have just barked!"), which would turn such approach into an additional annoyance Crying or Very sad

Tried this with Puppy 412. Can't see the top message (eg, delete these 2 files?)
Back to top
View user's profile Send private message 
musher0

Joined: 04 Jan 2009
Posts: 14549
Location: Gatineau (Qc), Canada

PostPosted: Wed 07 Dec 2016, 01:42    Post subject:  

Hello MochiMoppei, nic007 and all.

Here is an adaptation of the above for pekwm.

I've made Mochi's original into a separate script, which is called, AFTER
THE FILE HAS BEEN HIGHLIGHTED, by the key combo Ctrl-Shift-x.

Simply copy and paste the line at the bottom of this script, the one start-
ing with the word "Keypress", in pekwm's < keys > file after line 78 or so
in section "External Commands". Then restart pekwm for it to take effect.

~~~

The advantage of having it as a separate script is that you can also make
symbolic links of it:
-- in the general SendTo directory, and / or
-- in a sub-directory for a particular file type of SendTo.
In this case, again, you highlight the file to delete, but you click on the
symbolic link in the right-click menu of the ROX-Filer.

As Mochi mentioned above, it will also work if you put an icon of this
script on your desktop. In this case, you highlight the file you wish to
delete, as in the above procedures, and you click on the desktop icon.

~~~

Please note that this script is an add-on to BarryK's Trash ROX-App at
/usr/local/apps/Trash. It won't work without it -- to state the obvious!

~~~

Before you ask: the explanations above are the translation of the
comments in French in the script below.

~~~

Any feedback or suggestions for improvement welcome. TIA.
If comments are positive I will make a pet archive of this.

~~~

Last but not least: many thanks to MochiMoppei for his initial idea/insight.

BFN.

~~~~~~~

Code:
#!/bin/sh
# /usr/local/bin/DelPermOrTrash.sh
#
# Requis : l'appli ROX de BarryK à /usr/local/apps/Trash.
# Required: BarryK's Trash ROX-App at /usr/local/apps/Trash.
#
# Dérivé de : MochiMoppei,
# http://www.murga-linux.com/puppy/viewtopic.php?p=792936&sort=lastpost#792936
#
# Adapté pour pekwm 'keys' (voir au bas du script) par musher0, 5 déc. 2016.
#
# Comment faire
# -=> On doit d'abord surligner le fichier. <=-
# ==============================================
# Si on a surligné le fichier, cette astuce peut s'utiliser, non seulement
# avec la combinaison de touches Ctrl-Motion-x dans pekwm,
# mais aussi
# à partir d'une icône sur le bureau OU
# de liens symb. dans
# -- le répertoire SendTo correpondant au type de fichier OU
# -- le répertoire SendTo général.
####
FPATHS=\"$(xclip -o|sed 's/[ ]*$//;s_ /_" "/_g')\"
FCOUNT=$(echo "$FPATHS" | awk -F"\"/" '{print NF-1}'); ((FCOUNT))|| exit
ANSWER=$(gxmessage -bg "#008080" -fg white -fn "bold 12" -center -print -buttons "Delete permanently":0,"Send to Trash":1,"Cancel":2 -default "Send to Trash" $'\n\t\t\tDelete '$FCOUNT' file(s) ?')

case $ANSWER in
   "Delete permanently") ERR=$(eval rm -fr $FPATHS 2>&1) ;;
   "Send to Trash"     ) eval /usr/local/apps/Trash/AppRun $FPATHS ;;
esac
[ "$ERR" ] && gxmessage -name "Ups, smells like error" -bg red -fg white -center -buttons "OK":0 -default "OK" "$ERR"

#############################################
# Entrée dans le fichier keys de pekwm :
# Keypress = "Ctrl Shift x" { Actions = "Exec /usr/local/bin/DelPermOrTrash.sh &" }
# Copier-coller après la ligne 78, dans la section "External Commands".
#############################################

_________________
musher0
~~~~~~~~~~
Je suis né pour aimer et non pas pour haïr. (Sophocle) /
I was born to love and not to hate. (Sophocles)
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [9 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1027s ][ Queries: 12 (0.0368s) ][ GZIP on ]