summaryrefslogtreecommitdiff
path: root/pm/sleep.d/55NetworkManager
diff options
context:
space:
mode:
authorVictor Lowther <victor.lowther@gmail.com>2008-05-18 10:27:53 -0500
committerVictor Lowther <victor.lowther@gmail.com>2008-05-18 10:27:53 -0500
commit9eaef4ff2319e3813ba7ce17c30ffcdfb76506c2 (patch)
tree12de900d86996b106c4da2ea73e9b0d1d96e197b /pm/sleep.d/55NetworkManager
parentcc55fcd04883f1462144eb3efdbb1c09fe7d6089 (diff)
Even more reorganization
Diffstat (limited to 'pm/sleep.d/55NetworkManager')
-rwxr-xr-xpm/sleep.d/55NetworkManager40
1 files changed, 40 insertions, 0 deletions
diff --git a/pm/sleep.d/55NetworkManager b/pm/sleep.d/55NetworkManager
new file mode 100755
index 0000000..244e2c7
--- /dev/null
+++ b/pm/sleep.d/55NetworkManager
@@ -0,0 +1,40 @@
+#!/bin/sh
+# If we are running NetworkManager, tell it we are going to sleep.
+# TODO: Make NetworkManager smarter about how to handle sleep/resume
+# If we are asleep for less time than it takes for TCP to reset a
+# connection, and we are assigned the same IP on resume, we should
+# not break established connections. Apple can do this, and it is
+# rather nifty.
+
+. "${PM_FUNCTIONS}"
+
+command_exists dbus-send || exit $NA
+
+suspend_nm()
+{
+ # Tell NetworkManager to shut down networking
+ dbus-send --system \
+ --dest=org.freedesktop.NetworkManager \
+ /org/freedesktop/NetworkManager \
+ org.freedesktop.NetworkManager.sleep
+}
+
+resume_nm()
+{
+ # Wake up NetworkManager and make it do a new connection
+ dbus-send --system \
+ --dest=org.freedesktop.NetworkManager \
+ /org/freedesktop/NetworkManager \
+ org.freedesktop.NetworkManager.wake
+}
+
+case "$1" in
+ hibernate|suspend)
+ suspend_nm
+ ;;
+ thaw|resume)
+ resume_nm
+ ;;
+ *) exit $NA
+ ;;
+esac