* HowTo: Detect Laptop waking up from suspend from Emacs
@ 2017-02-11 1:39 raman
2017-02-11 8:55 ` aaermolov
` (3 more replies)
0 siblings, 4 replies; 14+ messages in thread
From: raman @ 2017-02-11 1:39 UTC (permalink / raw
To: emacs-devel
Background:
I run Emacs as my primary environment -- ie I do everything in Emacs
on Linux.
So when I open my laptop lid, my laptop wakes up from suspend and
Emacs is where I left off.
I'd like to set things up so emacs runs a set of actions when the
laptop comes back from suspend -- typically, say 5 seconds after
wake-up. Here, all actions are emacs functions.
So Q:
From Emacs --- perhaps an idle-timer, how do I detect when the laptop
returns from suspend?
--
--
--
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: HowTo: Detect Laptop waking up from suspend from Emacs
2017-02-11 1:39 HowTo: Detect Laptop waking up from suspend from Emacs raman
@ 2017-02-11 8:55 ` aaermolov
2017-02-11 9:10 ` Michael Albinus
` (2 subsequent siblings)
3 siblings, 0 replies; 14+ messages in thread
From: aaermolov @ 2017-02-11 8:55 UTC (permalink / raw
To: raman, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1026 bytes --]
Hi,
depending on your Linux distro you may want to install acpid package
(its name may vary), which brings your a bunch of files, presumably
in /etc/acpi, which describes ACPI events along with handlers to run on
them.
Be wary of this functionality have no direct connection with suspending
itself, AFAIK. For this you may use pm-utils/hibernate-script.
Having all this, you may want to pay attention to lid.sh under
/etc/acpi.
cheers,
Alex
raman@google.com writes:
> Background:
>
> I run Emacs as my primary environment -- ie I do everything in Emacs
> on Linux.
>
> So when I open my laptop lid, my laptop wakes up from suspend and
> Emacs is where I left off.
>
> I'd like to set things up so emacs runs a set of actions when the
> laptop comes back from suspend -- typically, say 5 seconds after
> wake-up. Here, all actions are emacs functions.
>
> So Q:
>
> From Emacs --- perhaps an idle-timer, how do I detect when the laptop
> returns from suspend?
> --
>
> --
>
> --
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: HowTo: Detect Laptop waking up from suspend from Emacs
2017-02-11 1:39 HowTo: Detect Laptop waking up from suspend from Emacs raman
2017-02-11 8:55 ` aaermolov
@ 2017-02-11 9:10 ` Michael Albinus
2017-02-11 16:28 ` raman
2017-02-11 14:54 ` Stefan Huchler
2017-02-11 17:50 ` Tom Tromey
3 siblings, 1 reply; 14+ messages in thread
From: Michael Albinus @ 2017-02-11 9:10 UTC (permalink / raw
To: raman; +Cc: emacs-devel
raman@google.com writes:
Hi,
> Background:
>
> I run Emacs as my primary environment -- ie I do everything in Emacs
> on Linux.
>
> So when I open my laptop lid, my laptop wakes up from suspend and
> Emacs is where I left off.
>
> I'd like to set things up so emacs runs a set of actions when the
> laptop comes back from suspend -- typically, say 5 seconds after
> wake-up. Here, all actions are emacs functions.
>
> So Q:
>
> From Emacs --- perhaps an idle-timer, how do I detect when the laptop
> returns from suspend?
The D-Bus system bus offers the org.freedesktop.UPower.Wakeups interface
(provided, your GNU/Linux system runs the upowerd daemon). Maybe you
could register for the DataChanged signal. I've never tried it myself,
'tho.
Another possibility could be the D-Bus system bus org.freedesktop.login1
interface. Signal PrepareForSleep seems to be emitted in both cases, the
system goes to sleep (argument true), or the system wakes up from sleep
(argument false). You could register for this signal. Again, I've never
tried it myself.
Best regards, Michael.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: HowTo: Detect Laptop waking up from suspend from Emacs
2017-02-11 1:39 HowTo: Detect Laptop waking up from suspend from Emacs raman
2017-02-11 8:55 ` aaermolov
2017-02-11 9:10 ` Michael Albinus
@ 2017-02-11 14:54 ` Stefan Huchler
2017-02-11 17:50 ` Tom Tromey
3 siblings, 0 replies; 14+ messages in thread
From: Stefan Huchler @ 2017-02-11 14:54 UTC (permalink / raw
To: emacs-devel
raman@google.com writes:
> Background:
>
> I run Emacs as my primary environment -- ie I do everything in Emacs
> on Linux.
>
> So when I open my laptop lid, my laptop wakes up from suspend and
> Emacs is where I left off.
>
> I'd like to set things up so emacs runs a set of actions when the
> laptop comes back from suspend -- typically, say 5 seconds after
> wake-up. Here, all actions are emacs functions.
>
> So Q:
>
> From Emacs --- perhaps an idle-timer, how do I detect when the laptop
> returns from suspend?
> --
>
> --
if you run the deamon you could maybe write in some external tools
somethnig like:
/usr/bin/emacsclient -e (wakeup-starter)
and then something like that in your config
(defun...
(sit-for 5)
....)
You can hook that command in I dont know logind? or dbus? udev? as some
rule or maybe even systemd:
https://wiki.archlinux.org/index.php/Power_management#Suspend.2Fresume_service_files
Hope that helps you.
Alternativly you could of course do a polling thing, and start that with
emacs:
(while (t) (when (timestamp differs to much from last-time) (setq
last-time timestamp) (do-your-stuff) (sleep 5)))
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: HowTo: Detect Laptop waking up from suspend from Emacs
2017-02-11 9:10 ` Michael Albinus
@ 2017-02-11 16:28 ` raman
2017-02-11 16:40 ` Michael Albinus
0 siblings, 1 reply; 14+ messages in thread
From: raman @ 2017-02-11 16:28 UTC (permalink / raw
To: Michael Albinus; +Cc: emacs-devel
Michael Albinus <michael.albinus@gmx.de> writes:
Thanks for the dbus pointers -- I was hoping that someone had already
gone down this route:-)> raman@google.com writes:
>
> Hi,
>
>> Background:
>>
>> I run Emacs as my primary environment -- ie I do everything in Emacs
>> on Linux.
>>
>> So when I open my laptop lid, my laptop wakes up from suspend and
>> Emacs is where I left off.
>>
>> I'd like to set things up so emacs runs a set of actions when the
>> laptop comes back from suspend -- typically, say 5 seconds after
>> wake-up. Here, all actions are emacs functions.
>>
>> So Q:
>>
>> From Emacs --- perhaps an idle-timer, how do I detect when the laptop
>> returns from suspend?
>
> The D-Bus system bus offers the org.freedesktop.UPower.Wakeups interface
> (provided, your GNU/Linux system runs the upowerd daemon). Maybe you
> could register for the DataChanged signal. I've never tried it myself,
> 'tho.
>
> Another possibility could be the D-Bus system bus org.freedesktop.login1
> interface. Signal PrepareForSleep seems to be emitted in both cases, the
> system goes to sleep (argument true), or the system wakes up from sleep
> (argument false). You could register for this signal. Again, I've never
> tried it myself.
>
> Best regards, Michael.
--
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: HowTo: Detect Laptop waking up from suspend from Emacs
2017-02-11 16:28 ` raman
@ 2017-02-11 16:40 ` Michael Albinus
2017-02-11 17:32 ` raman
0 siblings, 1 reply; 14+ messages in thread
From: Michael Albinus @ 2017-02-11 16:40 UTC (permalink / raw
To: raman; +Cc: emacs-devel
raman <raman@google.com> writes:
Hi,
> Thanks for the dbus pointers -- I was hoping that someone had already
> gone down this route:-)
<https://github.com/oyvindstegard/emacs-misc/blob/master/elisp/upower.el>
seems to have it implemented. Haven't tested it.
Best regards, Michael.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: HowTo: Detect Laptop waking up from suspend from Emacs
2017-02-11 16:40 ` Michael Albinus
@ 2017-02-11 17:32 ` raman
2017-02-11 18:51 ` Michael Albinus
0 siblings, 1 reply; 14+ messages in thread
From: raman @ 2017-02-11 17:32 UTC (permalink / raw
To: Michael Albinus; +Cc: emacs-devel
thanks for that pointer. I was looking at sauren on melpa that also
implements some dbus listeners. DBus is something I never got around to
learning, guess this is my chance:-)
--
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: HowTo: Detect Laptop waking up from suspend from Emacs
2017-02-11 1:39 HowTo: Detect Laptop waking up from suspend from Emacs raman
` (2 preceding siblings ...)
2017-02-11 14:54 ` Stefan Huchler
@ 2017-02-11 17:50 ` Tom Tromey
2017-02-11 20:57 ` raman
3 siblings, 1 reply; 14+ messages in thread
From: Tom Tromey @ 2017-02-11 17:50 UTC (permalink / raw
To: raman; +Cc: emacs-devel
>>>>> "raman" == raman <raman@google.com> writes:
raman> I'd like to set things up so emacs runs a set of actions when the
raman> laptop comes back from suspend -- typically, say 5 seconds after
raman> wake-up. Here, all actions are emacs functions.
Note that if you're specifically interested in being notified when the
network comes back up, there is a different way to do this with dbus.
See:
https://github.com/tromey/emacs-network-manager
Tom
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: HowTo: Detect Laptop waking up from suspend from Emacs
2017-02-11 17:32 ` raman
@ 2017-02-11 18:51 ` Michael Albinus
2017-02-11 20:56 ` raman
2017-02-13 17:50 ` T.V Raman
0 siblings, 2 replies; 14+ messages in thread
From: Michael Albinus @ 2017-02-11 18:51 UTC (permalink / raw
To: raman; +Cc: emacs-devel
raman <raman@google.com> writes:
> thanks for that pointer. I was looking at sauren on melpa that also
> implements some dbus listeners. DBus is something I never got around to
> learning, guess this is my chance:-)
Good luck! Maybe, (info "dbus") is also helpful.
Ping me, if you run into trouble.
Best regards, Michael.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: HowTo: Detect Laptop waking up from suspend from Emacs
2017-02-11 18:51 ` Michael Albinus
@ 2017-02-11 20:56 ` raman
2017-02-13 17:50 ` T.V Raman
1 sibling, 0 replies; 14+ messages in thread
From: raman @ 2017-02-11 20:56 UTC (permalink / raw
To: Michael Albinus; +Cc: emacs-devel
Thanks Again!
I pulled over upower.el -- turns out it was written originally by the
same person who wrote nm.el that I was already using. I've incorporated
upower.el and nm.el into Emacspeak as a quick hack for now -- will
likely try to grow it into something more full-fledged based on what I
end up needing. But upower.el has already fixed my primary annoyance of
needing to remember to turn the backlight off after waking up from suspend.
--
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: HowTo: Detect Laptop waking up from suspend from Emacs
2017-02-11 17:50 ` Tom Tromey
@ 2017-02-11 20:57 ` raman
0 siblings, 0 replies; 14+ messages in thread
From: raman @ 2017-02-11 20:57 UTC (permalink / raw
To: Tom Tromey; +Cc: emacs-devel
Tom Tromey <tom@tromey.com> writes:
Looking at this now -- I was using a quick hack called nm.el that I had
discovered a few years ago on the net. Speaking of network-manager, I
have longed to get enwc to work on my Ubuntu laptop --- I have never
succeeded in using it to setup a wifi network from scratch. Looking at
your code now >>>>>> "raman" == raman <raman@google.com> writes:
>
> raman> I'd like to set things up so emacs runs a set of actions when the
> raman> laptop comes back from suspend -- typically, say 5 seconds after
> raman> wake-up. Here, all actions are emacs functions.
>
> Note that if you're specifically interested in being notified when the
> network comes back up, there is a different way to do this with dbus.
> See:
>
> https://github.com/tromey/emacs-network-manager
>
> Tom
--
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: HowTo: Detect Laptop waking up from suspend from Emacs
2017-02-11 18:51 ` Michael Albinus
2017-02-11 20:56 ` raman
@ 2017-02-13 17:50 ` T.V Raman
2017-02-13 19:02 ` Michael Albinus
1 sibling, 1 reply; 14+ messages in thread
From: T.V Raman @ 2017-02-13 17:50 UTC (permalink / raw
To: michael.albinus; +Cc: emacs-devel, raman
After playing with dbus on the weekend, and using a combination of
dbus-monitor, gdbus, dbus-send etc to see what dbus did -- it makes me
want some kind of Emacs integration for exploring/discovering dbus
things -- perhaps a company backend for dbus?
--
--
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: HowTo: Detect Laptop waking up from suspend from Emacs
2017-02-13 17:50 ` T.V Raman
@ 2017-02-13 19:02 ` Michael Albinus
2017-02-13 19:05 ` T.V Raman
0 siblings, 1 reply; 14+ messages in thread
From: Michael Albinus @ 2017-02-13 19:02 UTC (permalink / raw
To: T.V Raman; +Cc: emacs-devel
raman@google.com (T.V Raman) writes:
> After playing with dbus on the weekend, and using a combination of
> dbus-monitor, gdbus, dbus-send etc to see what dbus did -- it makes me
> want some kind of Emacs integration for exploring/discovering dbus
> things -- perhaps a company backend for dbus?
Have you tried the introspection functions of dbus.el?
Beside of this, I don't know whether there are so many users of D-Bus in
Emacs, that it pays to write a company backend for this. Personally, I
found the d-feet tool sufficient when exploring D-Bus objects.
Best regards, Michael.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: HowTo: Detect Laptop waking up from suspend from Emacs
2017-02-13 19:02 ` Michael Albinus
@ 2017-02-13 19:05 ` T.V Raman
0 siblings, 0 replies; 14+ messages in thread
From: T.V Raman @ 2017-02-13 19:05 UTC (permalink / raw
To: michael.albinus; +Cc: emacs-devel, raman
Yes, tried the introspect functions. That was when I thought
company-based completion would be nice:-)
Michael Albinus writes:
> raman@google.com (T.V Raman) writes:
>
> > After playing with dbus on the weekend, and using a combination of
> > dbus-monitor, gdbus, dbus-send etc to see what dbus did -- it makes me
> > want some kind of Emacs integration for exploring/discovering dbus
> > things -- perhaps a company backend for dbus?
>
> Have you tried the introspection functions of dbus.el?
>
> Beside of this, I don't know whether there are so many users of D-Bus in
> Emacs, that it pays to write a company backend for this. Personally, I
> found the d-feet tool sufficient when exploring D-Bus objects.
>
> Best regards, Michael.
--
--
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2017-02-13 19:05 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-11 1:39 HowTo: Detect Laptop waking up from suspend from Emacs raman
2017-02-11 8:55 ` aaermolov
2017-02-11 9:10 ` Michael Albinus
2017-02-11 16:28 ` raman
2017-02-11 16:40 ` Michael Albinus
2017-02-11 17:32 ` raman
2017-02-11 18:51 ` Michael Albinus
2017-02-11 20:56 ` raman
2017-02-13 17:50 ` T.V Raman
2017-02-13 19:02 ` Michael Albinus
2017-02-13 19:05 ` T.V Raman
2017-02-11 14:54 ` Stefan Huchler
2017-02-11 17:50 ` Tom Tromey
2017-02-11 20:57 ` raman
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.