Installing and setting up connman
So far I’ve been connecting to wifi using wpa_supplicant and a shell script, but I wanted something more flexible and easier to use. Networkmanager is the obvious choice, but I wanted to try something else, and more lightweight(if possible). So I’ve decided to go ahead and try connman which is a Networkmanager alternative designed by intel and intended for mobile and embedded solutions. At this point it’s also full-featured enough that it can be used on the desktop.
Installation
doas xbps-install -S connman cmst
I decided to install connman along with a graphical network management utility(cmst), and an ncurses based network configurator, unfortunately connman-ncurses crashes all the time, and even segfaults on some actions.
So I decided to install ncman instead. I’ve found the most up to date fork.
Building and installing ncman
First we make a directory for storing the source:
mkdir -p ~/src/ncman
cd ~/src/ncman
Then pull the latest source:
git clone https://github.com/milisarge/ncman.git build
Now we have to fix the source, since ncman was built with -Wall (all warning stop the build process), and there’s function used that’s been deprecated.
Open ~/src/ncman/build/src/ncurses_utils.c in your favourite editor and change line 46 from:
vwprintw(win_footer, msg, args);
to:
vw_printw(win_footer, msg, args);
Install necessary dependancies:
doas xbps-install -S meson ninja cmake dbus-devel json-c-devel ncurses-devel
Build and install ncman:
meson setup build
ninja
doas ninja install
Configuration
To prevent dns overrides by connmand we create /etc/sv/connmand/conf
with the following content:
OPTS="--nodnsproxy"
Next we create /etc/connman/main.conf
with the following contents:
[General]
AllowHostnameUpdates=false
PreferredTechnologies=ethernet,wifi
SingleConnectedTechnology=true
These three config options have the following effects:
-
By default, ConnMan changes the transient hostname on a per network basis. The first option turns off that behaviour.
-
By default ConnMan does not prefer ethernet over wireless, which can lead to it deciding to stick with a slow wireless network even when ethernet is available. The second option fixes that.
-
ConnMan allows you to be connected to both ethernet and wireless at the same time. I prefer to have only one active connection at any given time.
Enabling Connman
First we need to disable dhcpcd(Connman has built in dhcp) and wpa_supplicant:
doas rm /var/service/dhcpcd
doas rm /var/service/wpa_supplicant
Wpa_supplicant service wasn’t even enabled on my system, but I’ve included that for completeness sake.
Next we enable Connman:
doas ln -s /etc/sv/connmand /var/service/
Check if the service is running:
doas sv status /var/service/connmand⏎
run: /var/service/connmand: (pid 6969) 1s
Final steps
Add user to the network
group
doas usermod -a -G network chain
Modifying dbus policies according to this post might be necessary, but it worked for me without this step.
After reloging or rebooting connman should be working.
Network connections can now be controlled with connmanctl(lowest level), ncman, or cmst.
connman-ncurses was last updated 7 years ago, and it already crashed on me when the wrong passphrase was provided. I might update this post if I decide to switch to a more up to date fork.
Edit: Yes, turns out I had the update this post to include the steps necessary to build and install ncman manually.