Raspberry Pi Asked on October 5, 2021
I’m trying to create a desktop shortcut that starts File Manager at a specified directory, in this case a mounted USB drive.
Here’s what I have so far:
Backup.desktop
[Desktop Entry]
Version=1.1
Type=Application
Encoding=UTF-8
Name=Backup
Comment=Backup Drive
Exec=/usr/bin/pcmanfm /mnt/elements
Terminal=false
Categories=FileSystem
But this shows up on the desktop as a regular text file named Backup.desktop
, and when it’s double-clicked it opens in LeafPad.
None of the advice I’m finding addresses these two important issues.
How can I fix this so that it appears as a normal shortcut and runs File Manager?
–EDIT–
Per Roger’s request in the comments, here’s the ls
output:
pi@OFFSITE:~ $ ls -l ~/Desktop/Backup.*
-rw-r--r-- 1 pi pi 202 Jul 19 18:46 /home/pi/Desktop/Backup.desktop
I created backup.desktop in /home/pi/Desktop with the code you posted above. I only changed the folder name from /mnt/elements to /home/pi/Test (since I do not have a /mnt/elements, you will need to make sure whichever folder you use exists and is available when running the script - e.g. that the drive is connected to the Pi). It ran just fine when clicked, but did prompt me to execute, execute in terminal, open, or cancel the operation (see below for how to avoid this and the caveats in doing so).
You can also add a custom icon, by adding the following line to your backup.desktop file:
icon=path_to_icon
for example:
icon=/home/pi/Pictures/icon.png
Alternatively, you can create a simple shell script to do this.
using your favorite editor create the shell script:
nano open_filemanager.sh
add the following code:
#!/usr/bin/env bash
/usr/bin/pcmanfm /mnt/elements
save the script and exit your editor.
Make the script executable:
chmod 744 open_filemanager.sh
Copy the file to the desktop:
cp ./open_filemanager.sh ~/Desktop
You can now double click the script file from the desktop, but you will be prompted whether to open the file or execute it. Choose execute.
This prompt is a security feature, but if you would like to run the script without prompting you can turn it off (note: since you control the script's contents this isn't really an issue for this script, but this will turn the protection off for all executable scripts).
To turn off the prompt:
Open File Manager
Then open the preferences menu (Edit->Preferences)
On the General tab
click "Don't ask options on launch executable file"
Close the preferences dialog and file Maanger.
You should now be able to double click the icon from the desktop with no prompt.
Correct answer by Steve Robillard on October 5, 2021
I'm not sure if it's possible to do it via the GUI. Here're the commands for terminal:
cd ~/Desktop
ln -s /path/to/directory LinkName
Here, the ln
command creates a symlink (symbolic link) with the name LinkName
to the original directory or file, which is like a shortcut. But it actually doesn't open the original directory.
Answered by AnonyoZarif on October 5, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP