Skip to content

Commit

Permalink
fix(main): main menu mac system commands, work on pass scripts, stick…
Browse files Browse the repository at this point in the history
…y note pass
  • Loading branch information
johnlindquist committed Aug 12, 2023
1 parent 44e35f7 commit 028c613
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 26 deletions.
17 changes: 0 additions & 17 deletions KIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,30 +314,13 @@ This will open the `kit.log` file in your editor. This is where Script Kit logs

Force the prompt to always open on a specific display.

## Toggle Clipboard/Snippet Watcher

<!-- description: Toggle the clipboard/snippet watcher -->
<!-- value: app/toggle-watcher.js -->
<!-- enter: Toggle -->

## Edit .env

<!-- description: Open the .env file -->
<!-- value: cli/env.js -->
<!-- enter: Edit .env -->

This will open the `.env` file in your editor. This is where Script Kit stores environment variables for your scripts.

## Settings

<!-- description: Manage settings for Kit.app -->
<!-- value: cli/settings.js -->
<!-- enter: Open Settings -->

Hit <kbd>Enter</kbd> to modify Kit.app settings:
- Toggle the menu bar icon
- Toggle open at login
- Toggle auto-update

## Credits

Expand Down
3 changes: 2 additions & 1 deletion src/api/kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1051,8 +1051,8 @@ export let getGroupedScripts = async () => {
kitPath("cli", "processes.js"),
kitPath("cli", "kenv-manage.js"),
kitPath("main", "google.js"),
// kitPath("main", "suggest.js"),
kitPath("main", "datamuse.js"),
kitPath("main", "system-commands.js"),
kitPath("main", "giphy.js"),
kitPath("main", "browse.js"),
kitPath("main", "app-launcher.js"),
Expand All @@ -1072,6 +1072,7 @@ export let getGroupedScripts = async () => {
]

if (isMac) {
kitScripts.push(kitPath("main", "system-commands.js"))
kitScripts.push(kitPath("main", "focus-window.js"))

if (!Boolean(env?.KIT_ACCESSIBILITY)) {
Expand Down
18 changes: 16 additions & 2 deletions src/cli/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ let inputTransformer = keywordInputTransformer(arg?.keyword)
let filePath = await arg(
{
input: (flag?.pass as string) || "",
initialChoices: pleaseType,
...(!arg?.pass && { initialChoices: pleaseType }),
placeholder: "Search Scripts",
debounceInput: 400,
enter: "Run",
preventCollapse: true,

onEscape: async () => {
submit(``)
await mainScript()
Expand All @@ -56,6 +58,7 @@ let filePath = await arg(
escapeShortcut,
{
name: `Edit`,
visible: true,
key: `${cmd}+o`,
onPress: async (input, { focused }) => {
await run(
Expand Down Expand Up @@ -86,7 +89,7 @@ let filePath = await arg(
})
.filter(Boolean)

return filePaths.map(filePath => {
let results = filePaths.map(filePath => {
return {
name: path.basename(filePath),
description: filePath.replace(home(), "~"),
Expand All @@ -96,6 +99,17 @@ let filePath = await arg(
},
}
})

if (results.length === 0) {
return [
{
info: true,
name: `No Results for ${input}`,
},
]
} else {
return results
}
} catch (error) {
setChoices([])
setPanel(
Expand Down
6 changes: 6 additions & 0 deletions src/lib/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ global.unmute = async () => {
)
}

global.logout = async () => {
return await applescript(
String.raw`tell application "System Events" to log out`
)
}

global.lock = async () => {
return await applescript(
String.raw`tell application "System Events" to keystroke "q" using {command down, control down}`
Expand Down
1 change: 0 additions & 1 deletion src/main/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Name: Browse Kit API
// Keyword: api
// Pass: true

import { createGuideConfig } from "./main-helper.js"

Expand Down
1 change: 0 additions & 1 deletion src/main/guide.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Name: Browse Kit Guide
// Keyword: guide
// Pass: true

import { createGuideConfig } from "./main-helper.js"

Expand Down
4 changes: 2 additions & 2 deletions src/main/kit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Name: Manage Kit
// Name: Kit Settings
// Description: Manage Kit Settings
// Keyword: kit
// Pass: true

import { createGuideConfig } from "./main-helper.js"

Expand Down
6 changes: 4 additions & 2 deletions src/main/sticky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Notes are saved to `~/.kenv/sticky.md`.

// Name: Sticky Pad
// Description: Take Quick Notes
// Cache: true
/// Cache: true
// Trigger: ,
// Pass: true

Expand Down Expand Up @@ -52,6 +52,8 @@ contents = await editor({
},
})

if (changed) await writeFile(stickyPath, contents + "\n")
if (changed || arg?.pass) {
await writeFile(stickyPath, contents + "\n")
}

export {}
1 change: 1 addition & 0 deletions src/platform/win32.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ global.setWindowSizeByIndex = notSupported(
)
global.shutdown = notSupported("shutdown")
global.sleep = notSupported("sleep")
global.logout = notSupported("logout")
global.tileWindow = notSupported("tileWindow")
global.find = notSupported("find")
// global.term = notSupported("term")
5 changes: 5 additions & 0 deletions src/types/platform.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ interface CutText {
interface Lock {
(): Promise<string>
}

interface Logout {
(): Promise<string>
}
interface Sleep {
(): Promise<string>
}
Expand Down Expand Up @@ -423,6 +427,7 @@ declare global {
var getWindowsBounds: GetWindowsBounds
var getSelectedDir: GetSelectedDir
var keystroke: KeyStroke
var logout: Logout
var lock: Lock
var openLog: () => void
var organizeWindows: OrganizeWindows
Expand Down

0 comments on commit 028c613

Please sign in to comment.