Ubuntu – How to make a launcher for activate Wifi

command linedriverslaunchernetworkingralink

I have a problem that after every update, because of my Ralink Wifi-Board, the WLAN is not activated and I have to run these commands to make it work again:

cd /home/makkekkazzo/2011_1007_RT5390_RT5392_Linux_STA_V2.5.0.3_DPO/
sudo make
sudo make install
sudo modprobe rt5390sta
sudo ifconfig enp2s0 up
sudo service network-manager restart

For this reason I want to know if it is possible to make a script with only these commands that will run after every update automatically by clicking on it.

Thanks a lot

Best Answer

The most convenient (and flexible) is to create a script for it:

  1. First install gksu:

    sudo apt-get install gksu
    
  2. Then create the script:

    #!/bin/bash
    
    cd /home/makkekkazzo/2011_1007_RT5390_RT5392_Linux_STA_V2.5.0.3_DPO/
    make
    make install
    modprobe rt5390sta
    ifconfig enp2s0 up
    service network-manager restart
    

    make it executable, and subsequently

  3. Create a launcher:

    [Desktop Entry]
    Exec=gksu /path/to/script.sh
    Type=Application
    Name=Update
    Terminal=true
    

    Save it as update.desktop. Also make this file executable and place it somewhere to double click.

    Now when you double click the icon, you will be prompted for your password, and the script will be executed in your terminal.

    OR

    save the .desktopfile in ~/.local/share/applications to make it available in Dash (no need to make it executable then). Log out and back in to show it in Dash.

Notes

  1. gksu does not notify you in case of occuring errors, hence the

    Terminal=true
    

    which will make the script execute in a terminal window.

  2. Inside the script, we do not use the sudo in front of each command, since we run the script with sudo.
  3. You can "pimp" your .desktop file with an icon, by adding a line:

    Icon=/path/to/icon.png
    

    more on .desktop files and their options here.

Related Question