trash-cli icon indicating copy to clipboard operation
trash-cli copied to clipboard

Confirm Dialog on `trash-empty`

Open bim4n opened this issue 2 years ago • 5 comments

Empty the trash worx fine, but very silently, Sometimes need a Confirmation Dialog like this:

Screenshot from 2023-11-05 21-05-36

Can you implement it ? a.E. trash-empty --confirm

bim4n avatar Nov 03 '23 18:11 bim4n

Yes, it is something that should be added to trash-empty.

I'm thinking of adding a confirmation prompt, instead of a GUI confirmation. Something like this:

$ trash-empty
Are you sure? (yes/no) 

I'm not confident to add a GUI prompt right now. If you already have a command that prepare the GUI prompt we can see how it can be called from trash-empty.

andreafrancia avatar Nov 05 '23 13:11 andreafrancia

I found this sources for UI-Dialog: https://packages.debian.org/sid/dialog and: https://packages.debian.org/source/sid/dialog

It would be nice when the confirmation did not always come but only via a parameter. For terminal: trash-empty --confirm For automation with GUI Dialog: trash-empty --confirm-ui

What do y think about ?

I use your script for a custom shortcut in kali linux:

Screenshot from 2023-11-05 21-21-52

bim4n avatar Nov 05 '23 21:11 bim4n

Or maybe this: https://help.gnome.org/users/zenity/stable/usage.html.de

bim4n avatar Nov 05 '23 21:11 bim4n

this solution works, but is not optimal:

Screenshot from 2023-11-05 22-13-39


Script-File: empty-trash.sh

#!/bin/bash

count=$(ls -l ~/.local/share/Trash/files/ | grep -v ^- | tr -d "total ")

if [ $count -eq 0 ]
then
    exit
fi

zenity --question --text="Empty all items from Trash?" --ok-label "Empty Trash" --cancel-label "Cancel"

if [ $? -eq 0 ]
then
    trash-empty
fi

bim4n avatar Nov 05 '23 22:11 bim4n

I think this is a good solution, and it is good that GUI elements are outside of the trash-cli package. In this way trash-cli will continue to be easy to be installed in environment that does not have zenity and/or a graphical environment.

andreafrancia avatar Nov 09 '23 10:11 andreafrancia