diff --git a/base/cli/daemon.go b/base/cli/daemon.go index b85367d7..2e7ba76c 100644 --- a/base/cli/daemon.go +++ b/base/cli/daemon.go @@ -177,14 +177,16 @@ func OpenCmds(m *ice.Message, arg ...string) *ice.Message { if len(arg) == 0 || arg[0] == "" { return m } - m.Cmd(SYSTEM, "osascript", "-e", kit.Format(` -tell application "Terminal" - do script "%s" - activate -end tell -`, strings.Join(arg, "; "))) + TellApp(m, "Terminal", kit.Format(`do script %s`, strings.Join(arg, "; ")), "activate") return m } +func TellApp(m *ice.Message, app string, arg ...string) { + OSAScript(m, kit.Format(` +tell application "%s" + %s +end tell +`, app, strings.Join(arg, lex.NL))) +} 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 93999b96..6fcd8d9d 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 lock", 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", 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) @@ -270,7 +270,10 @@ func init() { 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}`) + switch runtime.GOOS { + case DARWIN: + TellApp(m, "System Events", `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:] }) @@ -279,6 +282,7 @@ func init() { mdb.NAME, ice.Info.NodeName, nfs.VERSION, ice.Info.Make.Versions(), ).Option(ice.MSG_ACTION, "") ctx.DisplayStoryJSON(m) + m.Action("lock") }}, }) }