From 8d760c1fc762b7ad1d4231912b2a6380e90669d6 Mon Sep 17 00:00:00 2001 From: nrslib <38722970+nrslib@users.noreply.github.com> Date: Sun, 8 Feb 2026 19:36:19 +0900 Subject: [PATCH] =?UTF-8?q?caffeinate=20=E3=81=AB=20-d=20=E3=83=95?= =?UTF-8?q?=E3=83=A9=E3=82=B0=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=E3=80=81?= =?UTF-8?q?=E3=83=87=E3=82=A3=E3=82=B9=E3=83=97=E3=83=AC=E3=82=A4=E3=82=B9?= =?UTF-8?q?=E3=83=AA=E3=83=BC=E3=83=97=E4=B8=AD=E3=81=AE=20App=20Nap=20?= =?UTF-8?q?=E3=81=AB=E3=82=88=E3=82=8B=E3=83=97=E3=83=AD=E3=82=BB=E3=82=B9?= =?UTF-8?q?=E5=87=8D=E7=B5=90=E3=82=92=E9=98=B2=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__tests__/sleep.test.ts | 2 +- src/shared/utils/sleep.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/__tests__/sleep.test.ts b/src/__tests__/sleep.test.ts index e7e821b..cafb307 100644 --- a/src/__tests__/sleep.test.ts +++ b/src/__tests__/sleep.test.ts @@ -71,7 +71,7 @@ describe('preventSleep', () => { expect(spawn).toHaveBeenCalledWith( '/usr/bin/caffeinate', - ['-i', '-w', String(process.pid)], + ['-di', '-w', String(process.pid)], { stdio: 'ignore', detached: true } ); expect(mockChild.unref).toHaveBeenCalled(); diff --git a/src/shared/utils/sleep.ts b/src/shared/utils/sleep.ts index 0c2ec6d..5e8164c 100644 --- a/src/shared/utils/sleep.ts +++ b/src/shared/utils/sleep.ts @@ -8,7 +8,9 @@ const log = createLogger('sleep'); let caffeinateStarted = false; /** - * takt実行中のmacOSアイドルスリープを防止する。 + * takt実行中のmacOSアイドルスリープおよびディスプレイスリープを防止する。 + * -d: ディスプレイスリープ防止(App Nap によるプロセス凍結を回避) + * -i: アイドルスリープ防止 * 蓋を閉じた場合のスリープは防げない(-s はAC電源が必要なため)。 */ export function preventSleep(): void { @@ -26,7 +28,7 @@ export function preventSleep(): void { return; } - const child = spawn(caffeinatePath, ['-i', '-w', String(process.pid)], { + const child = spawn(caffeinatePath, ['-di', '-w', String(process.pid)], { stdio: 'ignore', detached: true, });