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

@ -2,6 +2,12 @@
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. 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 ** disconnection
~M-x quiet~ will disconnect from the network, optionally reconnecting after a certain time. ~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 ** 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 ** network interfaces
@ -22,6 +28,6 @@ you may want to ~customize~ or ~setq~ ~quiet-disconnect~ and ~quiet-connect~ to
** further ** further
- Mihaly Csikszentmihályi (1990). Flow: The Psychology of Optimal Experience. Harper & Row. ISBN 9780060162535 - [[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]]
- The Myth of Monotasking. https://hbr.org/2011/11/the-myth-of-monotasking/ - [[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 ;; Copyright 2016 FoAM vzw
;; ;;
;; Author: nik gaffney <nik@fo.am> ;; Author: nik gaffney <nik@fo.am>
;; Created: 2016-05-05 ;; Created: 2016-05-05
;; Version: 0.1 ;; Version: 0.1
;; Keywords: quiet, distraction, network, detachment, offline ;; Keywords: convenience, quiet, distraction, network, detachment, offline
;; X-URL: https://github.com/zzkt/quiet ;; URL: https://github.com/zzkt/quiet
;; This file is not part of GNU Emacs. ;; This file is not part of GNU Emacs.
@ -28,13 +28,13 @@
;;; Commentary: ;;; Commentary:
;; A simple package to disconnect from the online world for a while, ;; 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. ;; which occur once the command is run are guaranteed to be local.
;; ;;
;; 'M-x quiet' will disconnect from the network, optionally ;; 'M-x quiet' will disconnect from the network, optionally
;; reconnecting after a certain time. ;; 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 ;; network access could be seen as a feature, e.g. as a mode-hook (or
;; with defadvice) to your preferred distraction free writing ;; with defadvice) to your preferred distraction free writing
;; environment. ;; environment.
@ -47,25 +47,25 @@
(defcustom quiet-disconnect "networksetup -setairportpower airport off" (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 :type 'string
:options '("networksetup -setairportpower airport off" "ifdown wlan0") :options '("networksetup -setairportpower airport off" "ifdown wlan0")
:group 'quiet) :group 'quiet)
(defcustom quiet-connect "networksetup -setairportpower airport on" (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 :type 'string
:options '("networksetup -setairportpower airport off" "ifup wlan0") :options '("networksetup -setairportpower airport off" "ifup wlan0")
:group 'quiet) :group 'quiet)
(defcustom quiet-timer 0 (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 :type 'integer
:group 'quiet) :group 'quiet)
;;;###autoload ;;;###autoload
(defun quiet () (defun quiet ()
"quieten network distractions for a while..." "Quieten network distractions for a while..."
(interactive) (interactive)
(save-window-excursion (save-window-excursion
(message "disconnecting...") (message "disconnecting...")
@ -74,8 +74,12 @@
(progn (progn
(run-at-time (* quiet-timer 60) nil 'quiet-reconnect)))) (run-at-time (* quiet-timer 60) nil 'quiet-reconnect))))
;; provide a 'disconnect' alias
(fset 'disconnect 'quiet)
;;;###autoload ;;;###autoload
(defun quiet-reconnect () (defun quiet-reconnect ()
"Reconnect to networked distractions."
(interactive) (interactive)
(save-window-excursion (save-window-excursion
(message "reconnecting after ~%d %s" quiet-timer (if (= quiet-timer 1) "minute" "minutes")) (message "reconnecting after ~%d %s" quiet-timer (if (= quiet-timer 1) "minute" "minutes"))