Skip to content

create-link-here@DopeyDave: Add action#658

Open
DopeyDave wants to merge 2 commits intolinuxmint:masterfrom
DopeyDave:create-link-here
Open

create-link-here@DopeyDave: Add action#658
DopeyDave wants to merge 2 commits intolinuxmint:masterfrom
DopeyDave:create-link-here

Conversation

@DopeyDave
Copy link
Copy Markdown

New Action: Creates a .desktop shortcut file in this location for a file/folder

Resubmitting #656 with added information in the README to clarify this Action's difference from Nemo's "Make Link". Please read the README for a full explanation.

As stated previously, please contact me with any questions about the Action, especially if anything is unclear to you.

DopeyDave added 2 commits May 9, 2025 22:58
Creates a link (shortcut) in the same folder as a file/folder
added explanation of the difference between Nemo's "Make Link" and this action
@mtwebster
Copy link
Copy Markdown
Member

/review-action

@mtwebster
Copy link
Copy Markdown
Member

Nemo Action Review (Automated)

This is an automated review generated by Claude. It may contain inaccuracies — maintainers should verify any findings.

I have all the information needed. Let me write the review.

PR Review: create-link-here@DopeyDave

This action creates a .desktop shortcut file (Type=Link) for a selected file or folder in the same directory.


Issues

A. Selection=notnone but script only handles a single file

create-link-here@DopeyDave.nemo_action.in:6Selection=notnone means "one or more files selected." However, the script only processes $1:

TARGET="$1"

If a user selects multiple files, %F expands to all paths but "$1" would only contain the first one (or all paths concatenated into one string depending on how nemo resolves the quoting). Either way, multi-selection silently does the wrong thing.

Fix: Change Selection=notnone to Selection=s (single file only), since the script is designed for one file at a time. Or, add a loop in the script to handle multiple files.


B. Unnecessary backslash stripping may corrupt filenames

create-link-here@DopeyDave.sh:18-22:

if [[ "$TARGET" == *\\* ]]; then
  TARGET="${TARGET//\\}"
fi

This silently strips all backslash characters from filenames. While backslashes in filenames are uncommon on Linux, they are valid characters. This could cause the script to target the wrong file (or a nonexistent one) if a filename legitimately contains backslashes. Can you explain the rationale for this? If nemo is adding escape characters during token expansion, that would be a Quote/EscapeSpaces field concern that should be addressed in the action definition rather than by stripping in the script.


C. Redundant file --mime-type calls

create-link-here@DopeyDave.sh:51-63 — The file --mime-type command is run up to 5 times on the same file (once per elif). This is in the Exec path (runs on click, not right-click) so it's not a UI-blocking performance concern, but it's wasteful. Store the result once:

MIMETYPE=$(file --mime-type -b "$TARGET")
if [ -d "$TARGET" ]; then
  ICON="folder"
elif [[ "$MIMETYPE" == text/* ]]; then
  ICON="text"
elif [[ "$MIMETYPE" == application/pdf ]]; then
  ICON="application-pdf"
elif [[ "$MIMETYPE" == image/* ]]; then
  ICON="image-x-generic"
elif [[ "$MIMETYPE" == audio/* ]]; then
  ICON="audio-x-generic"
elif [[ "$MIMETYPE" == video/* ]]; then
  ICON="video-x-generic"
else
  ICON="application-octet-stream"
fi

This also avoids spawning grep for each check.


D. Debug comments should be removed

create-link-here@DopeyDave.sh:12-16:

# Debug note:
# To print to the system log (file: /var/log/syslog),
#   in bash, use the following example:
#   logger "Target: $TARGET"

These personal development notes shouldn't be shipped in the final action.


Minor Suggestions

  • Missing Dependencies: The script uses the file command (lines 51-62). While file is nearly universal on Linux, adding Dependencies=file; to the action definition would be consistent with best practices and prevent a confusing failure on minimal systems.

  • .desktop file construction (lines 66-71): Using individual echo statements with >> appends works but is fragile — if the script is interrupted mid-write, you get a partial .desktop file. A heredoc or cat > "$DESKTOP_FILE" << EOF approach would be more robust and readable.


Automated review of 5d48979 — last updated 2026-02-21 21:24 UTC

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.

2 participants