Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function question {
- ICON=/home/tri/icons/question.png
- if [[ -z $DISPLAY ]] || tty|grep -q pts; then
- dialog --title Question --yesno "$*" 0 0
- else
- yad --window-icon $ICON --image $ICON --center --on-top --title Question --text "$*" --button Yes:0 --button No:1
- fi
- }
- function checksize(){
- S=(`du -bs "$1"`)
- if [ $S -gt 1000000000 ]; then
- question "$1 size is greater than 1GB. Delete permanently? \nNo will move it to trash"
- else
- return 1
- fi
- }
- [ $# -eq 0 ] && exit
- TRASHCAN="$HOME/.local/trash"
- mkdir -p $TRASHCAN
- case $1 in
- *empty*)
- rm -rf $TRASHCAN/* ;;
- *restore*)
- shift
- for i; do
- if [ ${i:0:1} = "_" ]; then
- F=${i##*/}
- F=${F//_/\/}
- if [ -e "$F" ]; then
- question "$F existed. Do you want to overwrite?"
- [ $? -eq 0 ] && mv -f "$i" "$F"
- else
- mv "$i" "$F"
- fi
- fi
- done ;;
- *)
- for i; do
- checksize "$i"
- if [ $? -eq 1 ]; then
- cd `dirname "$i"`
- F=${PWD//\//_}_${i##*/}
- mv -f "$i" $TRASHCAN/"$F"
- else
- rm -rf "$i"
- fi
- done ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment