The officially official Devuan Forum!

You are not logged in.

#1 2019-10-07 13:59:45

GNUser
Member
Registered: 2017-03-16
Posts: 494  

ditch your bloated network manager

I have a laptop and my networking needs are quite simple. This is all I need:

a. handful of wireless hotspots (SSID and password) should be remembered
b. at boot, laptop should connect to highest-priority hotspot among those available
c. an icon should appear while I am connected to internet, showing hotspot's SSID

Given such simple needs, for many years I thought having a "network manager" installed was overkill. Finally, for the past few months I've been enjoying a completely network-manager-free computing experience thanks to these two simple shell scripts I wrote:

https://github.com/bdantas/autowifi (currently 63 lines including comments and blank lines)
https://github.com/bdantas/wifi-monitor (currently 51 lines including comments and blank lines)

I'd like to share the scripts with my Devuan friends. If you'd like to use them, all you need to do is:

1. Install some basic packages (you likely have most of them installed already):

sudo apt install procps net-tools wireless-tools wpasupplicant udhcpc curl yad

2. Download the two scripts, put them somewhere in your PATH, adjust the "user variables" at the top as appropriate, change the ssid/password strings at the top of autowifi as appropriate, make the scripts executable

3. Add sudo autowifi & and wifi-monitor &  to your startup jobs (note that wifi-monitor should run without sudo)

4. Disable your current network manager (e.g., sudo update-rc.d network-manager disable)

5. Reboot

If you decide to try it, please let me know how it goes.

Cheers,
Bruno "GNUser"

P.S. If you change your mind and want to go back to using the network manager, just remove the two startup jobs and re-enable the network manager (e.g., sudo update-rc.d network-manager enable)

Last edited by GNUser (2019-10-11 14:43:25)

Offline

#2 2019-10-07 15:26:46

fsmithred
Administrator
Registered: 2016-11-25
Posts: 1,289  

Re: ditch your bloated network manager

It works here in xfce (refracta ascii), but I'm not seeing the icon on the panel. I haven't checked to see if I did anything wrong.

Even better, it installs and runs in my nodbus beowulf, and the icon shows up on lxpanel. Testing in a live-iso running in a VM was less than ideal, and I didn't jump through all the hoops to get it to actually connect. I can do that with an installed system some time.

Thanks.

Offline

#3 2019-10-07 15:37:58

GNUser
Member
Registered: 2017-03-16
Posts: 494  

Re: ditch your bloated network manager

Thanks, fsmithred. Good to know it works in Beowulf with lxpanel smile

It should work in Xfce as well. Note that, in the interest of simplicity, the icon only shows up when internet is connected. If there is no internet connectivity, then no icon is the expected behavior.

Last edited by GNUser (2019-10-07 15:44:29)

Offline

#4 2019-10-10 13:06:02

HevyDevy
Member
Registered: 2019-09-06
Posts: 64  

Re: ditch your bloated network manager

I use setnet by KatolaZ https://github.com/KatolaZ/setnet

Using tint2 i tried out wifi-monitor and it works ok but it would be a nice added extra to have some form of tool-tip to show the essid, the script looks like it should have this but mouse hover for me over the icon reveals nothing. Is that a possibility already or something to be added perhaps?

Last edited by HevyDevy (2019-10-10 13:07:31)

Offline

#5 2019-10-10 13:41:29

GNUser
Member
Registered: 2017-03-16
Posts: 494  

Re: ditch your bloated network manager

@HevyDevy - The script should show the essid when you hover with the mouse over the wifi icon. It uses yad to accomplish this.

What happens when you type this in a terminal?

yad --notification --image=dialog-ok --text="hello world"

You should see "hello world" when you hover over the icon. If you don't see it, it's because yad and tint2 are not playing nice together.

yad works perfectly for me in both MATE and fluxbox.

If you want to use wifi-monitor but are married to tint2, you can swap out yad for some other utility to show the icon+tooltip. I can explore some alternatives.

Offline

#6 2019-10-10 16:03:47

GNUser
Member
Registered: 2017-03-16
Posts: 494  

Re: ditch your bloated network manager

@HevyDevy - I looked around and the only utility I could find to easily put an icon and tooltip in the system tray is yad. It's either yad or roll your own...

...so I did roll my own tiny alternative to yad using python:

#!/usr/bin/python3

import sys
from PyQt4 import QtGui, QtCore

def show_icon(icon, tooltip):
	class SystemTrayIcon(QtGui.QSystemTrayIcon):
		def __init__(self, icon, parent=None):
		   QtGui.QSystemTrayIcon.__init__(self, icon, parent)
		   self.setToolTip(tooltip)
		def exit(self):
		  QtCore.QCoreApplication.exit()

	app = QtGui.QApplication(sys.argv)
	w = QtGui.QWidget()
	trayIcon = SystemTrayIcon(QtGui.QIcon(icon), w)
	trayIcon.show()
	sys.exit(app.exec_())

icon=sys.argv[1]
tooltip=sys.argv[2]
show_icon(icon, tooltip)

If you'd like to try it:
1. Paste this code into a blank text file, name it show-icon, put it somewhere in your PATH, make it executable
2. Install the script's two dependencies: $ sudo apt install python3 python3-pyqt4
3. Test it: $ show-icon /path/to/icon.png "hello world" &

If the yad test I suggested in post #5 doesn't work, try this python script. If the python script ("show-icon") works, let me know and I can customize wifi-monitor for you (to use show-icon instead of yad).

Last edited by GNUser (2019-10-10 20:50:01)

Offline

#7 2019-10-10 20:14:06

bgstack15
Member
Registered: 2018-02-04
Posts: 83  

Re: ditch your bloated network manager

I'm a weak devuaner because I like my xfce too much which comes with dbus. However, I very much appreciate all the tools that help make dbus and NetworkManager obsolete. I do of course use wicd, although I expect that uses dbus.

I bet these scripts could be improved to read /etc/default/autowifi files so the original scripts could be controlled by a dpkg... is anyone interested in seeing some effort on that?


This space intentionally left blank.

Offline

#8 2019-10-11 12:08:26

HevyDevy
Member
Registered: 2019-09-06
Posts: 64  

Re: ditch your bloated network manager

@ GNUser, thanks for your efforts but i think i figured out what is happening. Iwconfig needs root rights (sudo) on my installation so all the script was doing was calling the icon. When i configure iwconfig in sudoers.d to not require a password i get the yad tooltip. Must be a certain $PATH variable set in the refracta nodbus version im using that requires root for iwconfig.

Offline

#9 2019-10-11 12:16:32

GNUser
Member
Registered: 2017-03-16
Posts: 494  

Re: ditch your bloated network manager

@HevyDevy - Good to hear! Glad you figured it out.

Last edited by GNUser (2019-10-11 12:16:48)

Offline

#10 2019-10-11 12:26:42

HevyDevy
Member
Registered: 2019-09-06
Posts: 64  

Re: ditch your bloated network manager

@ GNUser, thanks. forgot i was using zsh with grmls zshrc also. Switched back to bash and added /sbin/ to $PATH and all good.

Offline

#11 2019-10-12 13:21:59

HevyDevy
Member
Registered: 2019-09-06
Posts: 64  

Re: ditch your bloated network manager

Hi GNUser, tricky question for you. When i use ethernet which has a different iface (enp0 etc etc), wifi-monitor shows the wifi icon. How would you incorporate both a wired and wireless icon with tooltips of say ssid for wifi and device for ethernet?

Example.

When wifi is connected have the wifi icon with tooltip showing in systray.


When the ethernet is connected have the wired icon with tooltip showing in systray.

But dont show both icons when only one connection is up, only show the respected icon and tooltip for the connection.

??

I suppose this is going beyond what wifi-monitor was intended for, but you have to agree that having eth and wifi on one script would be cool, you could rename it net-monitor?

Last edited by HevyDevy (2019-10-12 13:32:31)

Offline

#12 2019-10-12 15:44:22

GNUser
Member
Registered: 2017-03-16
Posts: 494  

Re: ditch your bloated network manager

HevyDevy, wifi-monitor is a barebones shell script that assumes the user only uses wifi, never ethernet.

What you are suggesting would certainly be possible, but the more complex logic would require an overhaul of the script.

Feel free to adapt the script to suit your needs. If you run into issues, email me on here and I'll try to help.

Last edited by GNUser (2019-10-12 21:24:18)

Offline

#13 2019-10-13 11:21:13

HevyDevy
Member
Registered: 2019-09-06
Posts: 64  

Re: ditch your bloated network manager

Thanks GNUser, im going to try and do something similar to what you have done when i get the time. Ive just started to learn some awk/gawk so this maybe an avenue where i can do something unique with #!/bin/ awk -f scripts perhaps.

Offline

Board footer