Skip to content

Instantly share code, notes, and snippets.

@vredesbyyrd
Created January 27, 2023 19:55
Show Gist options
  • Save vredesbyyrd/1c0edc66841e6b9df529a2ae35b68ad2 to your computer and use it in GitHub Desktop.
Save vredesbyyrd/1c0edc66841e6b9df529a2ae35b68ad2 to your computer and use it in GitHub Desktop.
hackish script to open filepaths in new nautilus tab
# Convert desktop file urls to nautilus-friendly local paths.
# Accommodates special characters in directory names (!@#$, etc).
DELAY=$1
FILEURL=$2
FILEPATH="${FILEURL#file://}"
# Check for running instances of $app on current desktop/workspace.# Convert desktop file urls to nautilus-friendly local paths.
# Accommodates special characters in directory names (!@#$, etc).
DELAY=$1
APP=org.gnome.Nautilus
WID=( $(xdotool search --all --desktop $(xdotool get_desktop) --class $APP) )
LASTWID=${WID[*]: -1} # Get PID of newest active filebrowser window.
# If $wid is null launch app with filepath.
if [ -z $WID ]; then
$APP "$FILEPATH"
# If app is already running, activate it and use shortcuts to paste filepath into path bar.
else
xdotool windowactivate --sync $LASTWID key --delay "$DELAY" ctrl+t ctrl+l
xdotool type --delay 1 "$FILEPATH"
xdotool key Return
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment