Skip to content

create-link-desktop@DopeyDave: Add action - #655

Open
DopeyDave wants to merge 1 commit into
linuxmint:masterfrom
DopeyDave:create-link-desktop
Open

DopeyDave wants to merge 1 commit into
linuxmint:masterfrom
DopeyDave:create-link-desktop

Conversation

@DopeyDave

Copy link
Copy Markdown

New Action: Creates a link (shortcut) on the Desktop for a file/folder

Additional information can be found in the README. Please contact me for any questions. Thanks!

Creates a link (shortcut) on the Desktop for a file/folder
@rcalixte

Copy link
Copy Markdown
Member

@DopeyDave

Copy link
Copy Markdown
Author

I believe this already exists:

This one does not handle hidden files and maybe had a few other things that did not work for me. So I created my own.

@Skullckoor

Copy link
Copy Markdown
Contributor

I can offer my own option. More = better. Right?

#!/bin/env sh
if command -v xdg-user-dir > /dev/null 2>&1 && \
    [ -d "$(xdg-user-dir DESKTOP)" ]; then
        DESKTOP="$(xdg-user-dir DESKTOP)"
elif [ -d "${HOME}/Desktop" ]; then
        DESKTOP="${HOME}/Desktop"
else
    exit 1
fi

for var in "${@}"
do
    FULLPATH="$(echo "${var}" | tr -d '\\' )"
    OBJECT=${FULLPATH##*/}
    if [ -e "${DESKTOP}"/"${OBJECT}" ] || [ -h "${DESKTOP}"/"${OBJECT}" ]
    then

############################################################################

title="The object already exists"
text="already on your desktop. Move to trash?"

TRANS="${LANG%.*}"  #   asd_ZXC // for drop ".UTF-8"

if [ -f "$(dirname "$(readlink -f -- "${0}")")"/po/"${TRANS}".po ]; then
    PO="$(dirname "$(readlink -f -- "${0}")")"/po/"${TRANS}".po
elif
    TR="${TRANS%_*}"    #   asd     // drop "_ZXC"
    [ -f "$(dirname "$(readlink -f -- "${0}")")"/po/"${TR}".po ]; then
    PO="$(dirname "$(readlink -f -- "${0}")")"/po/"${TR}".po
fi

if [ ${PO} ]; then
    title=$(grep -A 1 "${title}" ${PO}|sed '1d;s/msgstr //;s/"//g')
    text=$(grep -A 1 "${text}" ${PO}|sed '1d;s/msgstr //;s/"//g')
fi

############################################################################

        if (zenity --question --icon-name=info \
        --title "${title}" --text="${OBJECT}\n${text}"); then
            gio trash "${DESKTOP}"/"${OBJECT}"
        else
            exit 0
        fi
    fi
    ln -s "${FULLPATH}" "${DESKTOP}"/
done

# Bashism
# "$(sed 's/\\//g' <<< "${var}")"
# "$(tr -d '\\' <<< "${var}")"
# POSIX
# "$(echo "${var}" | sed 's/\\//g')"
# "$(echo "${var}" | tr -d '\\' )"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants