From 4ea9734088419c89dfda0b8d0248d6649423fe35 Mon Sep 17 00:00:00 2001 From: lunaticbum Date: Mon, 30 Mar 2026 15:11:35 +0900 Subject: [PATCH] ... --- .../kotlin/service/SystemSleepPreventer.kt | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/service/SystemSleepPreventer.kt b/src/main/kotlin/service/SystemSleepPreventer.kt index f66f1cb..b209005 100644 --- a/src/main/kotlin/service/SystemSleepPreventer.kt +++ b/src/main/kotlin/service/SystemSleepPreventer.kt @@ -154,13 +154,6 @@ object SystemSleepPreventer { private fun setBrightness(level: Int) { try { if (osName.contains("mac")) { - // macOS: AppleScript 사용 (0.0 ~ 1.0 사이 값) -// val macLevel = level / 100.0 -// val command = arrayOf("osascript", "-e", -// "tell application \"Image Events\" to set darkness to $macLevel") -// // 참고: 최신 macOS에서는 'display services' 관련 스크립트가 더 정확할 수 있습니다. -// Runtime.getRuntime().exec(arrayOf("osascript", "-e", -// "tell application \"System Events\" to repeat $level times \n key code 107 \n end repeat")) // 밝기 감소 키 반복 val keyCode = if (level < 50) 145 else 144 // 145: 감소, 144: 증가 val action = if (level < 50) "어둡게" else "밝게" @@ -182,8 +175,23 @@ object SystemSleepPreventer { } } else if (osName.contains("win")) { // Windows: PowerShell 사용 (0 ~ 100 사이 값) - val psCommand = "Get-CimInstance -Namespace root/WMI -ClassName WmiMonitorBrightnessMethods | ForEach-Object { \$.WmiSetBrightness(1, $level) }" - ProcessBuilder("powershell.exe", "-Command", psCommand).start() +// val psCommand = "Get-CimInstance -Namespace root/WMI -ClassName WmiMonitorBrightnessMethods | ForEach-Object { \$.WmiSetBrightness(1, $level) }" +// ProcessBuilder("powershell.exe", "-Command", psCommand).start() + // 2: 모니터 끄기, -1: 모니터 켜기, 1: 저전력 모드 + if (level < 50) { + val psCommand = + "Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; public class Monitor { [DllImport(\"user32.dll\")] public static extern int PostMessage(IntPtr hWnd, int hMsg, int wParam, int lParam); public static void Off() { PostMessage((IntPtr)0xffff, 0x0112, 0xF170, 2); } }'; [Monitor]::Off()" + + ProcessBuilder("powershell.exe", "-Command", psCommand).start() + println("🌙 윈도우 모니터를 절전 모드로 전환했습니다.") +// // 0xF140은 화면 보호기를 실행하는 시스템 명령 상수입니다. +// val psCommand = "Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; public class Saver { [DllImport(\"user32.dll\")] public static extern int PostMessage(IntPtr hWnd, int hMsg, int wParam, int lParam); public static void Run() { PostMessage((IntPtr)0xffff, 0x0112, 0xF140, 0); } }'; [Saver]::Run()" +// +// ProcessBuilder("powershell.exe", "-Command", psCommand).start() +// println("🖥️ 화면 보호기를 실행했습니다.") + } else { + + } } println("🔆 밝기를 $level%로 설정했습니다.") } catch (e: Exception) {