Bug 153990 - support scripting/hooks
Summary: support scripting/hooks
Status: RESOLVED UNMAINTAINED
Alias: None
Product: Network Management
Classification: Miscellaneous
Component: Control Module (show other bugs)
Version: 0.7
Platform: Debian testing Linux
: NOR wishlist
Target Milestone: ---
Assignee: Lamarque V. Souza
URL:
Keywords:
: 166090 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-12-13 19:57 UTC by David Bremner
Modified: 2018-09-04 16:21 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
example script to snoop dbus and run user hooks on NM events (2.22 KB, text/plain)
2007-12-13 19:58 UTC, David Bremner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Bremner 2007-12-13 19:57:10 UTC
Version:            (using KDE KDE 3.5.8)
Installed from:    Debian testing/unstable Packages
OS:                Linux

Like several people out there, I wanted to have user (non-root)
scripts run when NM changed state.

I decided to write a quick python script to snoop the dbus, and call 
a function when an interface is brought up or down. Maybe somebody
else will find this useful.

Instead of a director of scripts, just place a file called
.nmdispatchrc in the home directory, containing python code which
defines functions ifup and ifdown. e.g.

def ifup(interface,*args)
    print 'interface '+interface 'brought up'

def ifdown(interface,*args)
    print 'interface '+interface+ ' brought down'

It was suggested by Dan Williams that this functionality 
(or something similar) might be built in to the front end applet.  What do you think?
Comment 1 David Bremner 2007-12-13 19:58:51 UTC
Created attachment 22535 [details]
example script to snoop dbus and run user hooks on NM events
Comment 2 Will Stephenson 2007-12-14 11:03:17 UTC
Good idea, 2 comments about the implementation:

*) KDE 4 abstracts out NetworkManager so it can run on platforms that don't use it.  The events emitted by Solid::Networking that wrap NM events are portable triggers.

*) An increasing number of apps have event driven user scripting interfaces.  Amarok, Kopete, and now KNetworkManager.  An elegant way to do this at a desktop level would be to have a single dispatcher process on the desktop that listens to the bus and starts a script, but provides an API for individual apps to access and modify 'their' scripts.  Consider KNotify as an example of this centralised but locally configurable architecture.  You could use a graphical dbus client like qdbusviewer as a base for this.

Comment 3 Will Stephenson 2009-02-05 14:48:00 UTC
*** This bug has been confirmed by popular vote. ***
Comment 4 Will Stephenson 2009-02-05 14:59:43 UTC
*** Bug 166090 has been marked as a duplicate of this bug. ***
Comment 5 Lamarque V. Souza 2011-10-30 12:40:52 UTC
You can use notifications to execute your scripts. We already have notifications that run before the connection is established (Establishing Network Connection), after it is established (Network Connection Succeeded) and after the connection is closed (Network Connection Disconnected). We just need to implement the one to be executed before disconnections.
Comment 6 Lamarque V. Souza 2011-11-12 19:54:29 UTC
Well, using KNotification always works for user connections, but for system connection it only works if kded is running. To run scripts on all events we need to add the support for it to NM itself. There is an upstream bug already requesting this feature:

https://bugzilla.gnome.org/show_bug.cgi?id=647068
Comment 7 Will Stephenson 2011-12-08 11:40:29 UTC
Reassign Network Management bugs to new maintainer.  Have a lot of fun, Lamarque!
Comment 8 Andrew Crouthamel 2018-09-04 16:21:52 UTC
Hello! Sorry to be the bearer of bad news, but this project has been unmaintained for many years and I will be closing this bug. Please test again with the latest version and file a new bug in plasma-nm. Thank you!