Disable networking on user inactivity

I moved from Windoze to Manjaro last year and am really pleased overall.

However, one feature I would dearly love is that the system disables networking if the user is inactive for a period, and reactivates it when they resume activity (‘activity’ defned as using the keyboard/mouse…)

In my situation there is no value in the laptop having network access while I am away from my desk, and I would rather it is actually disabled while I am not there!

I have searched a lot but not found anything like this…

(On windows, this feature used to be part of ‘Zonealarm’)

Suggestions?

Thanks so much!

Welcome to the forum! :wink:

I’m afraid you’ve got some strange ideas regarding network functionality. And most likely, your strange ideas are the result of your experience with Microsoft windows.

First and foremost, in Microsoft Windows, network connectivity often is a security concern because of the vulnerabilities of said platform, and its bad design as an operating system. And then there’s the “phoning home”.

UNIX systems are different. There is nothing phoning home, and having the network connection open does not mean that there would be any other network activity going on than a periodic ping from the router to ensure that your machine is still connected.

Also, in Manjaro concretely, there is nothing accepting any incoming network traffic unless you initiate it through a specific type of connection ─ e.g. a browser pulling in a web page, or an email client polling for new emails at a POP3 mail server.

In short, your request doesn’t make any sense, and there is no way to implement what you want, except by suspending or hibernating the system, which halts all processes in the system. And certain desktop environments ─ I can’t speak for all of them ─ do allow for an automatic suspend-to-RAM after a given timeout.

But that said, suspending the network connection only is not possible, nor is it a rational request. Furthermore, if you’re on WiFi, then every sufficiently long enough interruption in network connectivity may cause your DHCP server to issue you with another IP address than the one you had before. And then this in turn could lead to problems with open applications that were still relying on that network availability.

pamac-daemon regularly checks for package updates online, but still technically true.


Not out-of-the-box, but it might be achievable…
https://wiki.archlinux.org/title/Network_configuration#Enabling_and_disabling_network_interfaces
https://wiki.archlinux.org/title/Zeitgeist

Although configuring your system to suspend might indeed be a better move, since there might be some cases when the user seems inactive but you’d still want to keep the network – like, streaming.


Never heard of data caps? Though we do tend to discourage people worrying about data caps from using rolling distros such as Manjaro…

1 Like

Data capping isn’t going to be affected by the network connection being up or down if nothing is actively using that connection for anything. :man_shrugging:

“Better safe than sorry” i guess…

Thank you for your comments

There is no turnkey solution - but here is some ideas.

The firewalld service contains a trayapplet (install pyqt5 dependency).

The tray-applet contains a panic entry which blocks all network traffic.

You can even script the lock using the command line utility - which opens the possiblity of scripting the lockdown when you lock the system.

Thank you all for taking the time to reply.

So, how did you do?

It was trivially easy. For manual network control I set up two custom key commands:

Disable: sudo nmcli networking off

Enable: sudo nmcli networking on

But also as an automatic system I also had a custom script reading when the mouse changed position and clearing a timer. If the timer reached the timeout point (two minutes for me) then it uses the network disable command.

It works well and reliably.

Thanks

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.