How to turn wifi on/off with desktop icon? (Solved)

Issues and / or general discussion relating to Puppy


Moderator: Forum moderators

Post Reply
JusGellin
Posts: 864
Joined: Fri Jan 19, 2024 11:12 pm
Has thanked: 118 times
Been thanked: 118 times

How to turn wifi on/off with desktop icon? (Solved)

Post by JusGellin »

How could I make two files that could be linked to on the desktop - one to shut wifi off and one to turn wifi on?
I'm not sure where to properly put those files.

I found I could use these commands:
Turn wifi off:
ifconfig wlan0 down

and to turn wifi on:
ifconfig wlan0 up

Thanks

User avatar
Flash
Moderator
Posts: 1034
Joined: Tue Dec 03, 2019 3:13 pm
Location: Arizona, U.S.
Has thanked: 60 times
Been thanked: 140 times

Re: How to turn wifi on/off with desktop icon?

Post by Flash »

If you have a file that you can click on to execute the command, I think you can create a link from the desktop to the file by simply dragging the file to the desktop. This will create on the desktop an icon of the file. Then clicking the file icon on the desktop will execute the command.

Chaos coordinator :?
geo_c
Posts: 3095
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2426 times
Been thanked: 959 times

Re: Desktop Linked Files For Commands

Post by geo_c »

JusGellin wrote: Sun Jun 02, 2024 12:15 am

How could I make two files that could be linked to on the desktop - one to shut wifi off and one to turn wifi on?
I'm not sure where to properly put those files.

I found I could use these commands:
Turn wifi off:
ifconfig wlan0 down

and to turn wifi on:
ifconfig wlan0 up

Thanks

I have desktop files in /usr/share/applications for turning network connections on and off using the ip command. You can make them in a text editor and put them /usr/share/applications They look like this. However I notice in KLV-airedale (Xfce) that the network device isn't available in the taskbar icon until I run ip link set wlan0 up, then it comes back in the icon. Don't know how that will act on other systems.:

/usr/share/netDwlan0.desktop

Code: Select all

[Desktop Entry]
Type=Application
Name=Net DOWN wlan0
Comment=disconnect wlan0
Icon=utilities-terminal
Terminal=false
Exec=ip link set wlan0 down
Categories=ConsoleOnly;System;FileTools;FileManager;Utility;
MimeType=inode/directory;
Keywords=network;ethernet;Launcher;

The desktop file will give you a menu entry, don't know if you can run it from an icon on the desktop though.

Or you could simply put your command in an executable script and drag to the desktop. I think that will create a link.

geo_c
Old School Hipster, and Such

User avatar
mikewalsh
Moderator
Posts: 6573
Joined: Tue Dec 03, 2019 1:40 pm
Location: King's Lynn, UK
Has thanked: 1027 times
Been thanked: 2205 times

Re: Desktop Linked Files For Commands

Post by mikewalsh »

@JusGellin :-

Quite easy, actually.

/Usr/local/bin would be the most appropriate place, I think.

Go into /usr/local/bin. Right-click on any empty bit of the window, then -> New -> Script. Give the script a name, e.g. "Wifi On", and hit 'Create'. Now do the same again, and this time call it "Wifi Off".

Right-click on "Wifi On" -> Open with Geany, OR -> Open as Text. The first line is already showing:-

Code: Select all

#!/bin/sh

This tells the system this will be a Bash script. Now, make the rest of the script read as follows:-

Code: Select all

#!/bin/sh
#
# Turn wifi on
#
ifconfig wlan0 up

.....and make sure to save it before closing. Do the same with "Wifi Off":-

Code: Select all

#!/bin/sh
#
# Turn wifi off
#
ifconfig wlan0 down

.....again, making sure to save it.

~~~~~~~~~~~~~~~~~~~~~

Now, you can drag these two scripts to the desktop. Simples!

You can tart them up with icons (IF you want to). I have hundreds of these, culled from thousands of Google/DuckDuckGo searches over the years. Search for "PNG icons for [whatever]"

Find something you like, then download them. An 'up' arrow & a 'down' arrow might do the job, or perhaps search for actual wifi icons. Once you have them, move them to /usr/share/pixmaps; leave this window open. Now; rt-clk the script -> File 'xxxxxxxx' -> Set icon. A small window opens; literally drag the appropriate icon from /usr/share/pixmaps and drop it onto the space provided in the small window......

.......and now you have a pair of icons on the desk that will do what you want when you click on them.

('Pro' tip here:- Try to find an icon anywhere between 128 x 128 and 512 x 512 in size. ROX automatically resizes everything to 48 x 48 for the desktop, but larger icons will seem sharper and more detailed when re-sized. Don't ask me why, but they just do!)

Any questions, fire away.....

Mike. ;)

JusGellin
Posts: 864
Joined: Fri Jan 19, 2024 11:12 pm
Has thanked: 118 times
Been thanked: 118 times

Re: How to turn wifi on/off with desktop icon?

Post by JusGellin »

@mikewalsh
Just what I needed. It works great.
Thanks

Post Reply

Return to “Users Help”