Skip to content

Instantly share code, notes, and snippets.

@jotafeldmann
Created August 17, 2019 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jotafeldmann/23b654aa7d10426b2ef387eb0775c8e2 to your computer and use it in GitHub Desktop.
Save jotafeldmann/23b654aa7d10426b2ef387eb0775c8e2 to your computer and use it in GitHub Desktop.
#!/bin/bash
icon=$HOME/.local/share/applications/trash.desktop
trash_script_path=/home/j/workspace/libs/trash-icon-on-dock/trash.sh
while getopts "red" opt; do
case $opt in
r)
if [ "$(gio list trash://)" ]; then
echo -e '[Desktop Entry]\nType=Application\nName=Trash\nComment=Trash\nIcon=user-trash-full\nExec=nautilus trash://\nCategories=Utility;\nActions=trash;\n\n[Desktop Action trash]\nName=Empty Trash\nExec='$trash_script_path -e'\n' > $icon
fi
;;
e)
gio trash --empty && echo -e '[Desktop Entry]\nType=Application\nName=Trash\nComment=Trash\nIcon=user-trash\nExec=nautilus trash://\nCategories=Utility;\nActions=trash;\n\n[Desktop Action trash]\nName=Empty Trash\nExec='$trash_script_path -e'\n' > $icon
;;
d)
while sleep 5; do ($trash_script_path -r &) ; done
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment