This commit is contained in:
lunaticbum 2026-04-01 11:11:50 +09:00
parent 1c6eee6aac
commit 394ea1d581
2 changed files with 44 additions and 7 deletions

View File

@ -8,6 +8,7 @@ import java.awt.MouseInfo
import java.awt.Robot
import java.time.LocalTime
import java.util.concurrent.Executors
import java.util.regex.Pattern
object SystemSleepPreventer {
private var process: Process? = null
@ -146,7 +147,7 @@ object SystemSleepPreventer {
if (now.isAfter(dimTime) || now.isBefore(LocalTime.of(8, 30))) {
setBrightness(0)
} else {
setBrightness(80) // 업무 시간에는 다시 밝게 (80%)
setBrightness(100) // 업무 시간에는 다시 밝게 (80%)
}
}, 0, 10, TimeUnit.MINUTES) // 10분마다 체크
}
@ -154,6 +155,26 @@ object SystemSleepPreventer {
private fun setBrightness(level: Int) {
try {
if (osName.contains("mac")) {
// 1. 0~100의 값을 0~16 단계로 변환
// (level / 100.0 * 16)을 반올림하여 목표 클릭 횟수 결정
// val targetStep = Math.round(level / 100.0 * 16).toInt()
//
// // 2. AppleScript 구성
// // 145(F1)는 어둡게, 144(F2)는 밝게
// val script = """
// tell application "System Events"
// -- 일단 확실하게 최저(0)로 만듦 (16회 반복)
// repeat 16 times
// key code 145
// end repeat
//
// -- 그 다음 목표 단계만큼 밝게 함
// repeat $targetStep times
// key code 144
// end repeat
// end tell
// """.trimIndent()
val keyCode = if (level < 50) 145 else 144 // 145: 감소, 144: 증가
val action = if (level < 50) "어둡게" else "밝게"
@ -166,12 +187,13 @@ object SystemSleepPreventer {
end tell
""".trimIndent()
println(script)
try {
val process = ProcessBuilder("osascript", "-e", script).start()
process.waitFor()
println("🍏 Mac 화면을 $action 설정했습니다. ${keyCode}")
// println("🍏 Mac 밝기를 $level% (약 $targetStep/16 단계)로 설정했습니다.")
} catch (e: Exception) {
println("⚠️ AppleScript 실행 실패: ${e.message}")
println("⚠️ 실행 실패: ${e.message}")
}
} else if (osName.contains("win")) {
// Windows: PowerShell 사용 (0 ~ 100 사이 값)
@ -199,12 +221,14 @@ object SystemSleepPreventer {
}
}
/**
* 모니터를 즉시 잠자기 모드로 전환
*/
fun sleepDisplay() {
try {
setBrightness(0)
setBrightness(10)
println("🌙 [System] 오후 6시 30분: 모니터를 잠자기 모드로 전환합니다.")
} catch (e: Exception) {
println("⚠️ 모니터 잠자기 실패: ${e.message}")
@ -234,7 +258,7 @@ object SystemSleepPreventer {
*/
fun wakeDisplay() {
try {
setBrightness(100)
setBrightness(80)
println("☀️ 오전 8시: 모니터를 깨웁니다.")
} catch (e: Exception) {
println("⚠️ 모니터 깨우기 실패: ${e.message}")

View File

@ -8,6 +8,7 @@ import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.GridItemSpan
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.*
@ -22,6 +23,7 @@ import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import kotlinx.coroutines.launch
import model.ConfigIndex
import model.KisSession
import service.AutoTradingManager
@ -29,6 +31,8 @@ import service.AutoTradingManager
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun TradingDecisionLog() {
val listState = rememberLazyListState()
val coroutineScope = rememberCoroutineScope()
var searchQuery by remember { mutableStateOf("") }
var selectedFilters by remember { mutableStateOf(setOf("전체")) }
val filterOptions = listOf("전체", "BUY", "SELL", "HOLD", "SETTING","ANALYZER","PASS")
@ -64,8 +68,15 @@ fun TradingDecisionLog() {
Row(modifier = Modifier.fillMaxSize().background(Color(0xFFF2F2F2))) {
Column(modifier = Modifier.weight(0.5f).padding(8.dp).fillMaxHeight().background(Color.White)) {
Button(
onClick = {
coroutineScope.launch {
// index 0으로 부드럽게 스크롤 (즉시 이동은 scrollToItem(0))
listState.animateScrollToItem(0)
}
}
) { Text("AI 자동매매 실시간 로그", style = MaterialTheme.typography.h6) }
Text("AI 자동매매 실시간 로그", style = MaterialTheme.typography.h6)
Row(
modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp),
horizontalArrangement = Arrangement.Start
@ -131,7 +142,9 @@ fun TradingDecisionLog() {
Divider(Modifier.padding(bottom = 8.dp))
// [수정] filteredLogs를 사용하여 최신 로그가 위로 오게 표시
LazyColumn(reverseLayout = true) {
LazyColumn(
state = listState,
reverseLayout = true) {
items(filteredLogs) { log ->
Card(
modifier = Modifier.fillMaxWidth().padding(vertical = 4.dp),