Gnus development mailing list
 help / color / mirror / Atom feed
From: David Engster <deng@randomsample.de>
To: Eric Abrahamsen <eric@ericabrahamsen.net>
Cc: Lars Ingebrigtsen <larsi@gnus.org>,  ding@gnus.org
Subject: Re: new wifi connection = nntp timeout = Emacs restart?
Date: Fri, 01 May 2020 22:51:12 +0200	[thread overview]
Message-ID: <87d07ncrb3.fsf@randomsample> (raw)
In-Reply-To: <87sggja7hv.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Fri, 01 May 2020 10:29:48 -0700")

> Hey, that's pretty handy! Just FYI, the function name is quoted
> unnecessarily

Oops...

> and sleep-start is actually nil when it's going to sleep,
> who knows why.

Uhm, not for me. I just tested again to make sure. On sleep it is 't',
on wakup it is nil. This is also the documented behavior:

  The PrepareForShutdown() resp. PrepareForSleep() signals are sent right
  before (with the argument True) and after (with the argument False) the
  system goes down for reboot/poweroff, resp. suspend/hibernate.

https://www.freedesktop.org/wiki/Software/systemd/logind/

> Particularly handy since, in all my years of using dbus machines, I have
> never managed to write a dbus rule that did anything other than fail
> silently. This is useful.

You can actually do pretty nifty things with DBus, but it's... well,
let's say: convoluted. But Michael Albinus has really done a great job
for the Emacs interface, it's really simple to use and well documented.

As for detecting networking changes, I don't think it is possible to do
this with the systemd networking.service only, you'll also need
NetworkManager. I tried NetworkManager years ago and it was... really
not good. I just tried it again today and was happily surprised how well
it works nowadays. Some things just need time.

So NetworkManager will tell you everything you need to know via DBus:

https://developer.gnome.org/NetworkManager/stable/gdbus-org.freedesktop.NetworkManager.html

So from that I guess checking for changes on 'State' makes the most
sense?

(defun my-network-state-handler (name change-vals change-novals)
  (let ((state (assoc "State" change-vals)))
    (when state
      (message "New State: %s" (caadr state)))))

(dbus-register-signal :system
		      "org.freedesktop.Networkmanager"
		      "/org/freedesktop/NetworkManager"
		      "org.freedesktop.DBus.Properties"		      
		      "PropertiesChanged"
		      'my-network-state-handler)

So if you evaluate this and put your network down, you should see
something like

New State: 30
New State: 20

And if you put it up again:

New State: 40
New State: 50
New State: 60
New State: 70

The numbers are explained here:

https://developer.gnome.org/NetworkManager/stable/nm-dbus-types.html#NMState

So from that I guess we should just call gnus-close-all-servers for
state=30:

  Network connections are being cleaned up. The applications should tear
  down their network sessions.

-David


  reply	other threads:[~2020-05-01 20:52 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-16 17:37 Eric Abrahamsen
2020-04-17 11:46 ` Eric S Fraga
2020-04-17 12:20   ` Gijs Hillenius
2020-04-17 12:26     ` Andreas Schwab
2020-04-17 14:51       ` Eric Abrahamsen
2020-04-17 15:38         ` David Engster
2020-04-17 16:35           ` Eric Abrahamsen
2020-04-19  6:37 ` Christian Barthel
2020-04-19 17:32   ` Eric Abrahamsen
2020-04-19 18:02     ` Robert Pluim
2020-04-19 21:23       ` Eric Abrahamsen
2020-04-19 22:10       ` Eric Abrahamsen
2020-04-20  4:54         ` Eric Abrahamsen
2020-04-20  7:40         ` Andreas Schwab
2020-04-20 15:45           ` Eric Abrahamsen
2020-04-20 15:54             ` Robert Pluim
2020-04-20 18:24               ` Eric Abrahamsen
2020-04-21  8:36                 ` Alberto Luaces
2020-04-21 15:53                   ` Eric Abrahamsen
2020-04-22  7:37                     ` Alberto Luaces
2020-04-22  8:28                       ` Alberto Luaces
2020-04-30  5:26       ` Lars Ingebrigtsen
2020-04-30 17:34         ` Eric Abrahamsen
2020-04-30 21:49           ` Lars Ingebrigtsen
2020-04-30 22:11             ` Eric Abrahamsen
2020-05-04 12:53               ` Robert Pluim
2020-05-04 13:13                 ` Andreas Schwab
2020-05-04 13:33                   ` Robert Pluim
2020-05-04 14:35                     ` Andreas Schwab
2020-05-04 14:46                       ` Robert Pluim
2020-05-04 15:10                         ` Andreas Schwab
2020-05-04 16:29                           ` Robert Pluim
2020-05-04 14:51                 ` Lars Ingebrigtsen
2020-05-04 16:13                   ` Robert Pluim
2020-05-04 16:36                     ` Eric Abrahamsen
2020-05-04 17:21                       ` Robert Pluim
2020-05-04 18:01                         ` Lars Ingebrigtsen
2020-05-05  7:41                           ` new wifi connection = nntp timeout = Emacs restart?, " Robert Pluim
2020-05-05  8:19                             ` Lars Ingebrigtsen
2020-05-05 11:55                               ` Robert Pluim
2020-05-19 13:34                                 ` Lars Ingebrigtsen
2020-05-19 13:36                                 ` Lars Ingebrigtsen
2020-05-04 18:47                         ` Eric Abrahamsen
2020-05-04 15:38                 ` Eric Abrahamsen
2020-05-04 16:28                   ` Robert Pluim
2020-04-30 17:38         ` Eric Abrahamsen
2020-04-30 21:51           ` Lars Ingebrigtsen
2020-04-30 22:26             ` Eric Abrahamsen
2020-04-30 22:28               ` Lars Ingebrigtsen
2020-04-30 22:39                 ` Eric Abrahamsen
2020-04-30 22:55                   ` Lars Ingebrigtsen
2020-04-30 23:13                     ` Eric Abrahamsen
2020-04-30 23:23                       ` Lars Ingebrigtsen
2020-05-01  9:46                         ` David Engster
2020-05-01 10:35                           ` David Engster
2020-05-01 17:29                             ` Eric Abrahamsen
2020-05-01 20:51                               ` David Engster [this message]
2020-05-02  0:33                                 ` Eric Abrahamsen
2020-05-02 10:20                                   ` David Engster
2020-05-02 15:13                                     ` Eric Abrahamsen
2020-05-02 16:50                                       ` David Engster
2020-05-02 19:07                                         ` Eric Abrahamsen
2020-05-19 13:23                                           ` Lars Ingebrigtsen
2020-05-21  0:45                                             ` Eric Abrahamsen
2020-06-26  9:38                                               ` Lars Ingebrigtsen
2020-08-21 20:47                             ` Eric Abrahamsen
2020-05-01 18:06                         ` Eric Abrahamsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d07ncrb3.fsf@randomsample \
    --to=deng@randomsample.de \
    --cc=ding@gnus.org \
    --cc=eric@ericabrahamsen.net \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).