7

Let me start by saying that I'm very new to Ubuntu in general, so I realize this may be a basic question. I'm using xubuntu 14.04. I recently got a wireless usb working by following the steps here.

The instructions say that anytime the kernel updates, I must recompile by entering the following into the terminal:

cd ~/mt7601/src
make clean
make
sudo make install
sudo modprobe mt7601Usta

I'd like to know if there's anyway to create an icon on my desktop that I can just double click that will have the effect of entering the above commands into the terminal?

0

3 Answers 3

13

How to create an icon on your desktop to perform the recompile-job

  1. Open gedit, paste the lines below into the file:

    [Desktop Entry]
    Name=Recompile
    Exec=/bin/bash -c "cd ~/mt7601/src&&make clean&&make&&sudo make install&&sudo modprobe mt7601Usta"
    Type=Application
    Terminal=true
    
  2. Save the file as recompile.desktop on your desktop

  3. Make the file executable by the command:

    chmod +x /path/to/recompile.desktop
    

    After you made it executable, a generic icon will show up on the file (not necessarily the same as in the image, depending on your icon theme).

    enter image description here

  4. Simply double click on the file to run it. it will open a terminal window and ask for your password to run the sudo part of the command:

    enter image description here

Explanation

  • Desktop files (with the extension .desktop) can be used to perform all kinds of applications or tasks. To make it run shell commands, the format is:

    Exec=/bin/bash -c "<command>"
    

    In this case, in the Exec= -line, the commands mentioned in your question are separated by &&, which is effectively the same as placing each command on a new line.

    This makes it unnecessary to create a separate script; all is included in one launcher.

  • To make a .desktop file run from your desktop, you have to make it executable.
    After you made it executable, the name as it appears on your desktop is the name, defined in the line:

    Name=Recompile
    
  • The line:

    Terminal=true
    

    makes the command(s) run in a terminal window.

  • The example file is a very basic one. If you'd like the file to have another icon than the generic one, add a line (e.g.):

    Icon=/path/to/icon.png
    

    enter image description here

More on .desktop files and their required/optional entries here.

1
  • just in case someone else wonders & lose time like I did you cannot use command alias stored in bash-alias in the Exec field
    – mikakun
    Mar 30, 2017 at 11:01
6

You can make a script that can do these commands for you. Simply create a text file located on your desktop that contains the following.

#!/bin/bash
cd ~/mt7601/src
make clean
make
make install
modprobe mt7601Usta

Save it to the desktop as kernelupdate.sh You should then open up a terminal and run the followings commands

cd ~/Desktop/
chmod +x kernelupdate.sh

The script is now executable. You can execute it via the terminal using the following commands:

cd ~/Desktop
sudo ./kernelupdate.sh

Here is the link to a related question that explains how to make it executable via clicking on the icon. How to execute sh script from a desktop shortcut?

3
  • When I try to enter "chmod +e kernelupdate.sh", it says chmod: invalid mode: '+e'
    – jplank
    Apr 19, 2015 at 0:10
  • My apologies, it should be +x. I'll update answer now. Apr 19, 2015 at 0:14
  • I wouldn't recommend running make as root. Apr 19, 2015 at 10:21
4

Low reputation disallows commenting, so the answer instead of comment to Brian's answer.

The script in discussion must be run with root privileges. To avoid some confusion, the shortcut for it's launch should look like

gksudo script_name

The gksudo/gksu command brings up graphical dialogue for entering password

Also, the better place to store executables is not desktop, but your home folder. You may

mkdir ~/bin

And then use this bin directory to store this script. It is not strictly required, but strictly recommended to store programs and data in different places, not in one.

1
  • For one, who proposed to replace gksudo with sudo -i: gksudo does not do the same. GKsudo does not launch login shell Apr 19, 2015 at 6:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .