« ^ »

MacBookを閉じてもスリープさせない

所要時間: 約 1分

スリープさせないようにする(つまり閉じてもスリープしない)

sudo pmset -a disablesleep 1

スリープさせないようにしない(つまり閉じるとスリープする)

sudo pmset -a disablesleep 0

EmacsからM-xで実行できるようにした。

;;; macos-pmset --- macOS Utility. -*- lexical-binding: t -*-

;; Copyright (C) 2023 TakesxiSximada

;; Author: TakesxiSximada
;; Maintainer: TakesxiSximada
;; Version: 1
;; Package-Version: 20231009.0000
;; Package-Requires: ((emacs "29.1"))
;; Date: 2023-10-09

;; This file is part of macos-pmset

;;; License:

;; This program is free software: you can redistribute it and/or
;; modify it under the terms of the GNU Affero General Public License as
;; published by the Free Software Foundation, either version 3 of the
;; License, or (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; Affero General Public License for more details.

;; You should have received a copy of the GNU Affero General Public
;; License along with this program.  If not, see
;; <https://www.gnu.org/licenses/>.

;;; Code:

;;;###autoload
(defun macos-pmset-disable-sleep ()
  (interactive)
  (async-shell-command "sudo pmset -a disablesleep 1"))

;;;###autoload
(defun macos-pmset-enable-sleep ()
  (interactive)
  (async-shell-command "sudo pmset -a disablesleep 0"))

;;; macos-pmset.el ends here