robothunter
Posts: 3
Joined: Fri May 26, 2017 4:05 pm

Create a desktop shortcut

Thu Jun 13, 2019 1:04 am

I'm not sure why I can't figure this out by myself. It seems like it should be simple but I'm having trouble getting it to work so I'm asking for help. I want to create an icon on my desktop to reboot my pi. Here is what I did:
sudo nano /home/pi/Desktop/reboot.desktop
I entered "sudo shutdown -r" into the file.
That just opened the file when I double clicked on it. Obviously missing something so I tried:
sudo nano /home/pi/Desktop/reboot.sh and entered the same "sudo shutdown -r" and it did the same thing. Can someone please help me out with the piece of the puzzle I am missing?

dl324
Posts: 122
Joined: Mon May 06, 2019 7:33 pm
Location: Pacific Northwest, USA

Re: Create a desktop shortcut

Thu Jun 13, 2019 2:10 am

Is the file executable?

I just tried and you're going to be prompted whether you want to execute the file. That seems to be a feature.

klricks
Posts: 6710
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Create a desktop shortcut

Thu Jun 13, 2019 12:59 pm

This works for me:

Create the file in /home/pi/ (not Desktop)

Code: Select all

nano /home/pi/rboot
Be sure to include the 'shebang'

Code: Select all

#!/bin/bash
sudo shutdown -r now
Make the file executable using chmod command or change the properties (permissions) of the file using filemanager.

Use Main Menu Editor to add your program to the menu of your choice.

Find the file in menu and right click, then select add to desktop
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

robothunter
Posts: 3
Joined: Fri May 26, 2017 4:05 pm

Re: Create a desktop shortcut

Thu Jun 13, 2019 3:10 pm

Thank you very much! I changed the properties with:

Code: Select all

chmod +x /home/pi/rboot
Then went into the file manager to create a desktop link and it's working. Much appreciated. :D

Return to “General discussion”