From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Huchler Newsgroups: gmane.emacs.devel Subject: Re: HowTo: Detect Laptop waking up from suspend from Emacs Date: Sat, 11 Feb 2017 15:54:49 +0100 Message-ID: <87tw80lqva.fsf@mail.de> References: <22686.27448.427789.633250@gargle.gargle.HOWL> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1486824916 2467 195.159.176.226 (11 Feb 2017 14:55:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 11 Feb 2017 14:55:16 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 11 15:55:08 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ccZ4u-00009I-0Y for ged-emacs-devel@m.gmane.org; Sat, 11 Feb 2017 15:55:08 +0100 Original-Received: from localhost ([::1]:48602 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ccZ4x-0005at-TV for ged-emacs-devel@m.gmane.org; Sat, 11 Feb 2017 09:55:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ccZ4r-0005ZT-4i for emacs-devel@gnu.org; Sat, 11 Feb 2017 09:55:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ccZ4n-0004WT-Vw for emacs-devel@gnu.org; Sat, 11 Feb 2017 09:55:05 -0500 Original-Received: from [195.159.176.226] (port=48125 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ccZ4n-0004WC-Ow for emacs-devel@gnu.org; Sat, 11 Feb 2017 09:55:01 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1ccZ4d-0007jp-3o for emacs-devel@gnu.org; Sat, 11 Feb 2017 15:54:51 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 47 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:EG0AOIsdiRTD6EjoSFT0FafH5No= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:212225 Archived-At: 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)))