This commit is contained in:
nik gaffney 2019-12-30 17:44:26 +10:30
parent 6f20309f99
commit e090a21d06
2 changed files with 24 additions and 14 deletions

View file

@ -1,7 +1,13 @@
** quiet
** quiet
A simple package to disconnect from the online world for a while, possibly reconnecting later. Any interruptions or distractions which occur once the command is run are guaranteed to be local.
[[http://melpa.org/#/quiet][file:http://melpa.org/packages/quiet-badge.svg]]
** installation
the package can be installed from melpa ~M-x package-install [RET] quiet [RET]~
** disconnection
~M-x quiet~ will disconnect from the network, optionally reconnecting after a certain time.
@ -10,7 +16,7 @@ the function ~quiet~ can be used anywhere in emacs where a lack of network acces
** reconnection
~M-x quiet-reconnect~ will manually reconnect to the network, however you can enable a timer to automatically reconnect by setting ~quiet-timer~ to a number of minutes. e.g. ~(setq quiet-timer 60)~ will enable ~quiet~ to reconnect after one hour. if ~quiet-timer~ is set to 0 it won't reconnect automatically.
~M-x quiet-reconnect~ will manually reconnect to the network, however you can enable a timer to automatically reconnect by setting ~quiet-timer~ to a number of minutes. e.g. ~(setq quiet-timer 60)~ will enable ~quiet~ to reconnect after one hour. if ~quiet-timer~ is set to ~0~ it won't reconnect automatically.
** network interfaces
@ -22,6 +28,6 @@ you may want to ~customize~ or ~setq~ ~quiet-disconnect~ and ~quiet-connect~ to
** further
- Mihaly Csikszentmihályi (1990). Flow: The Psychology of Optimal Experience. Harper & Row. ISBN 9780060162535
- The Myth of Monotasking. https://hbr.org/2011/11/the-myth-of-monotasking/
- [[https://www.worldcat.org/title/flow-the-psychology-of-optimal-experience/oclc/848200090][Mihaly Csikszentmihályi (1990). Flow: The Psychology of Optimal Experience. Harper & Row. ISBN 9780060162535]]
- [[https://hbr.org/2011/11/the-myth-of-monotasking/][The Myth of Monotasking]].

View file

@ -1,12 +1,12 @@
;;; quiet.el --- disconnect from the online world for a while
;;; quiet.el --- Disconnect from the online world for a while
;; Copyright 2016 FoAM vzw
;;
;; Author: nik gaffney <nik@fo.am>
;; Created: 2016-05-05
;; Version: 0.1
;; Keywords: quiet, distraction, network, detachment, offline
;; X-URL: https://github.com/zzkt/quiet
;; Keywords: convenience, quiet, distraction, network, detachment, offline
;; URL: https://github.com/zzkt/quiet
;; This file is not part of GNU Emacs.
@ -28,13 +28,13 @@
;;; Commentary:
;; A simple package to disconnect from the online world for a while,
;; possibly reconnecting later. Any interruptions or distractions
;; possibly reconnecting later. Any interruptions or distractions
;; which occur once the command is run are guaranteed to be local.
;;
;; 'M-x quiet' will disconnect from the network, optionally
;; reconnecting after a certain time.
;;
;; the function 'quiet' can be used anywhere in emacs where a lack of
;; the function 'quiet' can be used anywhere in Emacs where a lack of
;; network access could be seen as a feature, e.g. as a mode-hook (or
;; with defadvice) to your preferred distraction free writing
;; environment.
@ -47,35 +47,39 @@
(defcustom quiet-disconnect "networksetup -setairportpower airport off"
"Shell command to turn off network connection(s)"
"Shell command to turn off network connection(s)."
:type 'string
:options '("networksetup -setairportpower airport off" "ifdown wlan0")
:group 'quiet)
(defcustom quiet-connect "networksetup -setairportpower airport on"
"Shell command to turn on network connection(s)"
"Shell command to turn on network connection(s)."
:type 'string
:options '("networksetup -setairportpower airport off" "ifup wlan0")
:group 'quiet)
(defcustom quiet-timer 0
"Timer to reconnect network after a given time (in minutes). A value of 0 will leave the connection off"
"Timer to reconnect network after a given time (in minutes). A value of 0 will leave the connection off."
:type 'integer
:group 'quiet)
;;;###autoload
(defun quiet ()
"quieten network distractions for a while..."
"Quieten network distractions for a while..."
(interactive)
(save-window-excursion
(message "disconnecting...")
(async-shell-command quiet-disconnect))
(if (not (= quiet-timer 0))
(progn
(progn
(run-at-time (* quiet-timer 60) nil 'quiet-reconnect))))
;; provide a 'disconnect' alias
(fset 'disconnect 'quiet)
;;;###autoload
(defun quiet-reconnect ()
"Reconnect to networked distractions."
(interactive)
(save-window-excursion
(message "reconnecting after ~%d %s" quiet-timer (if (= quiet-timer 1) "minute" "minutes"))