Skip to content

Commit

Permalink
feat: assert that yabai, skhd, choose are installed
Browse files Browse the repository at this point in the history
  • Loading branch information
shalomb committed Nov 2, 2024
1 parent f60e5ce commit ae944dc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
**unmarked 🎯**
---

Similar to [`harpoon`](https://github.com/ThePrimeagen/harpoon), unmarked
Similar to [`harpoon`](https://github.com/ThePrimeagen/harpoon/tree/harpoon2), unmarked
is the keyboard user's tool for switching desktop windows using just their
marks.

Expand Down
4 changes: 4 additions & 0 deletions choosecmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ var chooseMarksCmd = &cobra.Command{
Short: "Choose from marked windows",
Long: `Choose from all the marked windows`,
Run: func(_ *cobra.Command, _ []string) {
if !commandExists("choose") {
log.Fatalf("tool 'choose' is not installed. Install with 'brew install choose-gui'")
}

log.Printf("choosing marks under %v", stateHome)
chooseMarks()
},
Expand Down
22 changes: 22 additions & 0 deletions init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import (
"os/exec"

log "github.com/sirupsen/logrus"
)

func init() {
for _, tool := range []string{"ls", "yabai", "skhd"} {
log.Debugf("tool exists: %v -> %v", tool, commandExists(tool))
if !commandExists(tool) {
log.Fatalf("tool %v is not installed. Install with 'brew install %v'", tool, tool)
}
}
}

// as util
func commandExists(cmd string) bool {
_, err := exec.LookPath(cmd)
return err == nil
}

0 comments on commit ae944dc

Please sign in to comment.