Those who suffer from a flaky wifi connection can use the above script and a desktop launcher to automatically refresh your network connection (rather than rebooting). To have the above script launch in the background (not in a visible terminal window) you must first install a small terminal multiplexer called “tmux”. As the script must be launched as root a small pkexec confirmation window will still pop up asking for the sudo password. There are other methods of refreshing your wifi connection that don’t require root permission, but they are often not as effective as this method. This will allow you to automatically restart your wifi connection from a handy desktop launcher.
Restart your WiFi connection with a Desktop Launcher
Create a file named “wifi-restart.desktop” with a text editor to start your WiFi connection.
Note: You must edit the “Exec” line in the desktop file to reflect the correct path to the “wifi-restart.sh” script in your system.
The desktop file should have the following contents:
Exec=pkexec tmux -c /path/to/script/wifi-restart.sh; sleep2 & exit
Be sure to make the desktop file you created executable.
The desktop file can be placed in your start menu, taskbar, or on your desktop to conveniently restart your wifi connection.