From ae944dc1fc66bb54f65de13b80cd903d889b7c6b Mon Sep 17 00:00:00 2001 From: "Shalom Bhooshi shalom.bhooshi@takeda.com" Date: Sun, 3 Nov 2024 00:36:44 +0100 Subject: [PATCH] feat: assert that yabai, skhd, choose are installed --- README.md | 2 +- choosecmd.go | 4 ++++ init.go | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 init.go diff --git a/README.md b/README.md index 4ba26d5..2ae7a0a 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/choosecmd.go b/choosecmd.go index 9fe841f..ef40c18 100644 --- a/choosecmd.go +++ b/choosecmd.go @@ -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() }, diff --git a/init.go b/init.go new file mode 100644 index 0000000..01ea846 --- /dev/null +++ b/init.go @@ -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 +}