From 2d1c99af5688f0db652240498ba24e547dcde5c3 Mon Sep 17 00:00:00 2001 From: shy Date: Sun, 24 Dec 2023 21:43:21 +0800 Subject: [PATCH] add lock --- base/cli/daemon.go | 3 +++ base/cli/runtime.go | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/base/cli/daemon.go b/base/cli/daemon.go index 28123cd3..b85367d7 100644 --- a/base/cli/daemon.go +++ b/base/cli/daemon.go @@ -185,3 +185,6 @@ end tell `, strings.Join(arg, "; "))) return m } +func OSAScript(m *ice.Message, arg ...string) { + m.Cmd(SYSTEM, "osascript", "-e", arg) +} diff --git a/base/cli/runtime.go b/base/cli/runtime.go index a50c596f..93999b96 100644 --- a/base/cli/runtime.go +++ b/base/cli/runtime.go @@ -163,7 +163,7 @@ const RUNTIME = "runtime" func init() { Index.MergeCommands(ice.Commands{ - RUNTIME: {Name: "runtime info=bootinfo,ifconfig,diskinfo,hostinfo,userinfo,procstat,procinfo,bootinfo,role,api,cli,cmd,mod,env,path,chain,routine auto upgrade restart reboot logs conf", Icon: "Infomation.png", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{ + RUNTIME: {Name: "runtime info=bootinfo,ifconfig,diskinfo,hostinfo,userinfo,procstat,procinfo,bootinfo,role,api,cli,cmd,mod,env,path,chain,routine auto upgrade restart reboot logs conf lock", Icon: "Infomation.png", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, ice.LICENSE) _runtime_init(m) @@ -269,6 +269,9 @@ func init() { "conf": {Help: "配置", Hand: func(m *ice.Message, arg ...string) { OpenCmds(m, kit.Format("cd %s", kit.Path("")), "vim etc/init.shy") }}, + "lock": {Help: "锁屏", Hand: func(m *ice.Message, arg ...string) { + OSAScript(m, `tell application "System Events" to keystroke "q" using {control down, command down}`) + }}, }, ctx.ConfAction("")), Hand: func(m *ice.Message, arg ...string) { kit.If(len(arg) > 0 && arg[0] == BOOTINFO, func() { arg = arg[1:] }) m.Cmdy(ctx.CONFIG, RUNTIME, arg).StatusTime(mdb.TIME, ice.Info.Make.Time,