andreafrancia / trash-cli

Command line interface to the freedesktop.org trashcan.
GNU General Public License v2.0
3.53k stars 177 forks source link

Confirm Dialog on `trash-empty` #319

Open bim4n opened 8 months ago

bim4n commented 8 months ago

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

andreafrancia commented 8 months ago

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.

bim4n commented 8 months ago

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 commented 8 months ago

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

bim4n commented 8 months ago

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
andreafrancia commented 8 months ago

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.