diff --git a/create-link-desktop@DopeyDave/CHANGELOG.md b/create-link-desktop@DopeyDave/CHANGELOG.md new file mode 100644 index 00000000..bd7d37cc --- /dev/null +++ b/create-link-desktop@DopeyDave/CHANGELOG.md @@ -0,0 +1,3 @@ +### 1.0 + +* Initial Release \ No newline at end of file diff --git a/create-link-desktop@DopeyDave/README.md b/create-link-desktop@DopeyDave/README.md new file mode 100644 index 00000000..b9f3dde4 --- /dev/null +++ b/create-link-desktop@DopeyDave/README.md @@ -0,0 +1,21 @@ +Create a Link on the Desktop +======================== + +Description +----------- + +This Action adds the ability to create a link on the Desktop of a file or folder. The link is created using the .desktop file type, which allows for proper path tracking and display on the Desktop. + +The behavior is similar to the Windows "create a shortcut" / "send to desktop" functionality. + +Shortcuts made of hidden files/folders (filename prepended with ".") will be visible on the Desktop. Normally in Cinnamon, hidden files/folders do not display on the Desktop. Although you can enable the "show hidden files" option in Nemo, this only affects Nemo, and does not affect the Desktop display. But by using .desktop shortcut files, this can allow them to appear. This Action takes the existing filename and alters it so Cinnamon does not consider it a hidden item ("_" is prepended). It then keeps the .desktop "Name" attribute true to the file/folder's actual name, since this is the filename that is actually used for display (this is true for Nemo in a folder view as well as Cinnamon on the Desktop). + +This following Actions should be paired for a complete package: +* create-link-desktop@DopeyDave (You Are Here) +* create-link-here@DopeyDave +* follow-desktop-link@DopeyDave + +Usage +----------- + +Right click on a file or folder. Select the new option "Create Link on Desktop". diff --git a/create-link-desktop@DopeyDave/create-link-desktop@DopeyDave.nemo_action.in b/create-link-desktop@DopeyDave/create-link-desktop@DopeyDave.nemo_action.in new file mode 100644 index 00000000..f1e7edcc --- /dev/null +++ b/create-link-desktop@DopeyDave/create-link-desktop@DopeyDave.nemo_action.in @@ -0,0 +1,7 @@ +[Nemo Action] +_Name=Create Link on Desktop +_Comment=For the selected file/folder, create a link (.desktop file) on the Desktop +Exec= +Icon-Name=emblem-symbolic-link +Selection=notnone +Extensions=any; diff --git a/create-link-desktop@DopeyDave/files/create-link-desktop@DopeyDave/create-link-desktop@DopeyDave.sh b/create-link-desktop@DopeyDave/files/create-link-desktop@DopeyDave/create-link-desktop@DopeyDave.sh new file mode 100755 index 00000000..9b9b5329 --- /dev/null +++ b/create-link-desktop@DopeyDave/files/create-link-desktop@DopeyDave/create-link-desktop@DopeyDave.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +# Check if any files/folders are selected +if [ -z "$1" ]; then + echo "No file/folder selected." + exit 1 +fi + +# Get the target file or folder +TARGET="$1" + +# Debug note: +# To print to the system log (file: /var/log/syslog), +# in bash, use the following example: +# logger "Target: $TARGET" + +# If "\" char is in the string +# Note: Use [[double brackets]] +if [[ "$TARGET" == *\\* ]]; then + # Remove all ("//") "\" chars + TARGET="${TARGET//\\}" +fi + +# Extract the filename and path +FILENAME=$(basename "$TARGET") +DIRNAME=$(dirname "$TARGET") + +# Preserve the real filename, which could start with "." (hidden) +NAME_OF_FILE=$FILENAME + +# If the filename starts with a dot, prepend an underscore to the filename +# in order to make it visible on the Desktop +if [[ "$FILENAME" == .* ]]; then + FILENAME="_$FILENAME" +fi + +# Get the path to the Desktop folder +DESKTOP_DIR="$HOME/Desktop" + +# Check if the Desktop folder exists +if [ ! -d "$DESKTOP_DIR" ]; then + echo "Desktop folder not found." + exit 1 +fi + +# Create the .desktop file on the Desktop +# Note: If hidden ("."), "_" is pre-pended so file will be visible on the Desktop +DESKTOP_FILE="${DESKTOP_DIR}/${FILENAME}.desktop" + +# Check if the .desktop file already exists on the Desktop +if [ -e "$DESKTOP_FILE" ]; then + echo "A .desktop file already exists for this item on the Desktop." + exit 1 +fi + +# Determine the icon based on the type of file or folder +if [ -d "$TARGET" ]; then + ICON="folder" +elif file --mime-type "$TARGET" | grep -q 'text/'; then + ICON="text" +elif file --mime-type "$TARGET" | grep -q 'application/pdf'; then + ICON="application-pdf" +elif file --mime-type "$TARGET" | grep -q 'image/'; then + ICON="image-x-generic" +elif file --mime-type "$TARGET" | grep -q 'audio/'; then + ICON="audio-x-generic" +elif file --mime-type "$TARGET" | grep -q 'video/'; then + ICON="video-x-generic" +else # Unknown type + ICON="application-octet-stream" +fi + +# Create the .desktop file content +echo "[Desktop Entry]" > "$DESKTOP_FILE" +echo "Name=$NAME_OF_FILE" >> "$DESKTOP_FILE" # Use real name of file (this will show "." files/folders correctly on Desktop) +echo "URL=file://$TARGET" >> "$DESKTOP_FILE" # URL format needed for Link type +echo "Icon=$ICON" >> "$DESKTOP_FILE" +echo "Terminal=false" >> "$DESKTOP_FILE" +echo "Type=Link" >> "$DESKTOP_FILE" # Type needs to be Link + +# Make the .desktop file executable +chmod +x "$DESKTOP_FILE" + +# Output complete +echo "Created .desktop link on the Desktop: $DESKTOP_FILE" diff --git a/create-link-desktop@DopeyDave/files/create-link-desktop@DopeyDave/icon.png b/create-link-desktop@DopeyDave/files/create-link-desktop@DopeyDave/icon.png new file mode 100644 index 00000000..858e1d0b Binary files /dev/null and b/create-link-desktop@DopeyDave/files/create-link-desktop@DopeyDave/icon.png differ diff --git a/create-link-desktop@DopeyDave/files/create-link-desktop@DopeyDave/metadata.json b/create-link-desktop@DopeyDave/files/create-link-desktop@DopeyDave/metadata.json new file mode 100644 index 00000000..c8bc88d0 --- /dev/null +++ b/create-link-desktop@DopeyDave/files/create-link-desktop@DopeyDave/metadata.json @@ -0,0 +1,7 @@ +{ + "description": "Create a link (shortcut) on the Desktop for a file/folder", + "uuid": "create-link-desktop@DopeyDave", + "name": "Create Link on the Desktop", + "author": "DopeyDave", + "version": "1.0" +} \ No newline at end of file diff --git a/create-link-desktop@DopeyDave/info.json b/create-link-desktop@DopeyDave/info.json new file mode 100644 index 00000000..a72bf873 --- /dev/null +++ b/create-link-desktop@DopeyDave/info.json @@ -0,0 +1,3 @@ +{ + "author": "DopeyDave" +} \ No newline at end of file