0

I need guidance putting this together. I am trying to create two Desktop Shortcuts.

These are the Desktop Shortcut names:

  1. Coffee Shop WiFi
  2. Home WiFi

The purpose of creating two Desktop shortcuts is to disable my Intel wireless card and activate my Wireless USB Adapter when I am working at coffee shop.

The second Desktop Shortcut is to disable USB wireless adapter and reactivate my Intel Wireless Card.

You can find out more information here:

Wifi is not working. Intel Wi-Fi 6 AX200 Kubuntu 21.10 HP Omen

I found a similar post to accomplish this task below:

1.Add a shell script with sudo to launcher as shortcut in Ubuntu 19.10

2.How to create desktop shortcut launcher on Ubuntu 18.04 Bionic Beaver Linux

3.How to create desktop shortcut or launcher on Linux

The problem is these articles are outdated and confusing. So far, I ran this command to create a Coffee Shop Wi-Fi desktop Icon:

krillavilla@Krillavilla-Omega:~/Downloads$ gedit /usr/share/applications/CoffeeShopWifi.desktop

The text file is below:

[Desktop Entry]
Version=1.0
Type=Application
Terminal=true
Name=Coffee Shop WiFi
Icon=/home/krillavilla/Downloads/CoffeShopWifi.png
Exec= # does the sudo command goes here? 
X-MultipleArgs=false
Categories=GNOME;GTK;
#StartupNotify=true
GenericName=Coffee Shop WiFi
Path=/tmp/

Also, do I add entry for Sudo script? The commands are below:

  1. sudo modprobe -r iwlwifi >>> This disables Intel Wireless Card and Activate WLAN1
  2. sudo modprobe iwlwifi >>> This reactivates Intel Wireless Card and Disable USB Wireless Adapter (WLAN1)

This is where I am stuck at. I need help

1 Answers1

1

You're on the right track. It looks like you need to write a few bash scripts first. Then you can create .desktop files for each script.

Let's use the two commands from the example you used in your question. First, you should test them in your terminal to make sure they actually do what you want. Then you can make a script to run those commands:

  • cd to the path where you want the scripts to live. In this case we are going to put the scripts at ~/scripts/:

    cd ~/scripts/
    
  • Now create the script and make it executable. In this example, the script is named enableintel.sh:

    touch enableintel.sh
    chmod +x enableintel.sh
    
  • Open the script for editing:

    nano enableintel.sh
    
  • Using the commands from your example, add the following contents, then save and exit the text editor:

    #!/bin/sh
    sudo modprobe -r iwlwifi
    sudo modprobe iwlwifi
    
  • Test the script:

    ./enableintel.sh
    

If the script works, now you can link to it with a .desktop entry. Here's what that should look like:

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/home/krillavilla/scripts/enableintel.sh
Name=Enable Intel Wireless
Icon=/home/krillavilla/Downloads/CoffeShopWifi.png

If you want the icon on your desktop, then you can put the .desktop file in ~/Desktop.

I used the same icon path you indicated in your question, however I would not recommend putting it in a location like ~/Downloads which tends to get cluttered.

You'll just need to write another script and .desktop file for the reverse action.

Nmath
  • 12,333