andreafrancia / trash-cli

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

Incorrect detection of interactive mode #215

Closed Tehgg closed 2 years ago

Tehgg commented 2 years ago

In my xmonad startup script, I run a trash-empty 3. But trash-empty thinks it is in interactive mode (probably because python says it is "in a terminal", whatever that really means) and makes the whole system wait for an input that will never come. In order to fix it, I changed to echo '' | trash-empty 3 and it seems to work.

Wouldn't it be better to have an explicit option to not ask for any confirmation rather than to have an unreliable "interactive mode detection"? (but it will still break dependencies)

andreafrancia commented 2 years ago

You can use trash-empty -f 3 in order to force to not ask confirmation.

Currently trash-cli uses os.isatty(0) to check if the standard input is attached to a terminal. I don't think there are better ways to detect if the tty is a terminal. If someone does please tell me.

You can also consider to using cron typing crontab -e and then adding the line:

@daily /path/to/trash-empty 3