Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: trash can for gnome dash/dash to dock

  1. #1
    Join Date
    Jul 2006
    Location
    Here
    Beans
    11,187

    trash can for gnome dash/dash to dock

    alright peoples final script. should be user neutral just place in $HOME/Documents & make executable.

    Code:
    #!/bin/bash
    icon=$HOME/.local/share/applications/trash.desktop
    
    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='$HOME/Documents/trash.sh -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='$HOME/Documents/trash.sh -e'\n' > $icon
    	;;
        d)
    	while sleep 5; do ($HOME/Documents/trash.sh -r &) ; done
    	;;
      esac
    done
    once placed in Documents, open a terminal there, run-> trash.sh -e <- this will create trash.desktop in $HOME/.local/share/applications

    final piece, you need to add to autostart-> trash.sh -d

    example of my ~/.config/autostart/trash-icon.desktop:
    Code:
    [Desktop Entry]
    Type=Application
    Name=Trash Icon
    Icon=user-trash
    Exec=/home/user/Documents/trash.sh -d
    enjoy your new trash icon for dash/dash to dock.

    Screenshot from 2018-05-07 10-39-47.jpgScreenshot from 2018-05-07 10-38-49.jpgScreenshot from 2018-05-08 19-22-01.jpg

    Trash.zip
    Attached Files Attached Files
    Last edited by kerry_s; May 22nd, 2018 at 09:30 PM.

  2. #2
    Join Date
    Jul 2006
    Location
    Here
    Beans
    11,187

    Re: trash can for gnome dash/dash to dock

    the command is now "trash.sh -s" to set everything up

    Code:
    #!/bin/bash
    # trash.sh -s <-create autostart & application
    
    icon=$HOME/.local/share/applications/trash.desktop
    start=$HOME/.config/autostart/trash.desktop
    
    while getopts "reds" opt; do
    	case $opt in
        r)
    	if [ "$(cat $icon | grep Icon=user-trash-full)" ]; then
    		exit 0
    	elif [ "$(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='$HOME/Documents/trash.sh -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='$HOME/Documents/trash.sh -e'\n' > $icon
    	;;
        d)
    	while sleep 30; do ($HOME/Documents/trash.sh -r &) ; done
    	;;
        s)
    	echo -e '[Desktop Entry]\nType=Application\nName=Trash Icon\nIcon=user-trash\nExec='$HOME/Documents/trash.sh -d'\n' > $start && 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='$HOME/Documents/trash.sh -e'\n' > $icon
      esac
    done
    Last edited by kerry_s; May 14th, 2018 at 06:46 PM.

  3. #3
    Join Date
    Apr 2018
    Beans
    62
    Distro
    Ubuntu

    Re: trash can for gnome dash/dash to dock

    Nice script! One thing though: it shouldn't use the "Documents" folder directly because that's language-specific, so if someone doesn't have Ubuntu installed in English, that won't work. It would probably be better to use something like
    Code:
    $(xdg-user-dir DOCUMENTS)
    (which returns the full path to the Documents folder, so it includes /home/user) instead of
    Code:
    $HOME/Documents
    My Ubuntu / Linux / open source website LinuxUprising.

  4. #4
    Join Date
    Jul 2006
    Location
    Here
    Beans
    11,187

    Re: trash can for gnome dash/dash to dock

    i was actually thinking about putting it in it's own folder "Trash" maybe with the script & the icons. so i can just zip it up & attach. ease of use.
    in some themes user-trash & user-trash-full are the same icon, which is why i think i should put the icons, otherwise there will/might be complaints about icon not changing.

    any other thoughts? i been exploring the "gio monitor trash://" but i haven't got a script to work with it yet.

    i'll make the changes & attach. i'm switching to solus mate tonight, some things i want to play with. so i probably won't work on any improvements to the script.

  5. #5
    Join Date
    Jul 2006
    Location
    Here
    Beans
    11,187

    Re: trash can for gnome dash/dash to dock

    Trash.zip

    here's the new file with the changes. unzip in the home folder & enter it, right click-> open terminal here & run ./trash.sh -s

    that's it reboot & it's good to go.

  6. #6
    Join Date
    Oct 2004
    Location
    Denmark - Scandinavia
    Beans
    19,553
    Distro
    Ubuntu Budgie Development Release

    Re: trash can for gnome dash/dash to dock

    Should be default in Ubuntu.

  7. #7
    Join Date
    Jul 2006
    Location
    Here
    Beans
    11,187

    Re: trash can for gnome dash/dash to dock

    i wouldn't say default, more like an option.
    i think since there doing away with the desktop icons, there should be a option to have those on the dock.

    i was looking into maybe doing something for mounted drives/networks. i know there are extensions, but i so hate tiny icons(bad eyes), i'd much rather have it on the dock.
    shelved for now, playing with mate+plank, instead of gnome.

  8. #8
    Join Date
    Apr 2018
    Beans
    62
    Distro
    Ubuntu

    Re: trash can for gnome dash/dash to dock

    I noticed a bug. The second time you empty the trash, the icon no longer changes and it shows that the trash is full. Edit: I think that's because the icon isn't updated if the trash is emptied from Nautilus, and not from the icon context menu
    Last edited by logix2; May 22nd, 2018 at 04:04 PM.
    My Ubuntu / Linux / open source website LinuxUprising.

  9. #9
    Join Date
    Apr 2018
    Beans
    62
    Distro
    Ubuntu

    Re: trash can for gnome dash/dash to dock

    I managed to fix it, now the script will work even if the trash is emptied directly from Nautilus:

    Code:
    #!/bin/bash# trash.sh -s <-create autostart & application
    
    
    icon=$(xdg-user-dir)/.local/share/applications/trash.desktop
    start=$(xdg-user-dir)/.config/autostart/trash.desktop
    
    
    while getopts "reds" opt; do
    	case $opt in
        r)
    	if [ "$(gio list trash://)" ]; then
    		echo -e '[Desktop Entry]\nType=Application\nName=Trash\nComment=Trash\nIcon='$(xdg-user-dir)/Trash/user-trash-full.svg'\nExec=nautilus trash://\nCategories=Utility;\nActions=trash;\n\n[Desktop Action trash]\nName=Empty Trash\nExec='$(xdg-user-dir)/Trash/trash.sh -e'\n' > $icon
    	else
    		echo -e '[Desktop Entry]\nType=Application\nName=Trash\nComment=Trash\nIcon='$(xdg-user-dir)/Trash/user-trash.svg'\nExec=nautilus trash://\nCategories=Utility;\nActions=trash;\n\n[Desktop Action trash]\nName=Empty Trash\nExec='$(xdg-user-dir)/Trash/trash.sh -e'\n' > $icon
    	fi
    	;;
        e)
    	gio trash --empty && echo -e '[Desktop Entry]\nType=Application\nName=Trash\nComment=Trash\nIcon='$(xdg-user-dir)/Trash/user-trash.svg'\nExec=nautilus trash://\nCategories=Utility;\nActions=trash;\n\n[Desktop Action trash]\nName=Empty Trash\nExec='$(xdg-user-dir)/Trash/trash.sh -e'\n' > $icon
    	;;
        d)
    	while sleep 30; do ($(xdg-user-dir)/Trash/trash.sh -r &) ; done
    	;;
        s)
    	echo -e '[Desktop Entry]\nType=Application\nName=Trash Icon\nIcon='$(xdg-user-dir)/Trash/user-trash.svg'\nExec='$(xdg-user-dir)/Trash/trash.sh -d'\n' > $start && echo -e '[Desktop Entry]\nType=Application\nName=Trash\nComment=Trash\nIcon='$(xdg-user-dir)/Trash/user-trash.svg'\nExec=nautilus trash://\nCategories=Utility;\nActions=trash;\n\n[Desktop Action trash]\nName=Empty Trash\nExec='$(xdg-user-dir)/Trash/trash.sh -e'\n' > $icon
      esac
    done
    I'm attaching the new Trash.zip with the fixed version, for anyone interested.
    Attached Files Attached Files
    My Ubuntu / Linux / open source website LinuxUprising.

  10. #10
    Join Date
    Jul 2006
    Location
    Here
    Beans
    11,187

    Re: trash can for gnome dash/dash to dock

    i changed that, that's how i had it before, cause it'll just keep swapping the icon over & over if you don't empty the trash. you can always right click-> empty trash to swap the icon back, whether there is trash or not.

    also if you want the icon to change faster you can change the "while sleep 30;" to "while sleep 5;" it'll just cost a few more kib in memory/ram. i have mine set to 5.

    for me this is just to remind me i have trash, when i don't empty right away & i always use the icon to empty.
    Last edited by kerry_s; May 22nd, 2018 at 08:56 PM.

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •