Skip to content

Commit

Permalink
Fixed hardcoded Windows executable
Browse files Browse the repository at this point in the history
  • Loading branch information
feature-not-a-bug committed Feb 24, 2025
1 parent 5c4bf69 commit c361a56
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/Patat/Images/WezTerm.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import qualified Data.ByteString.Lazy.UTF8 as BLU
import GHC.Generics (Generic)
import Patat.Cleanup (Cleanup)
import qualified Patat.Images.Internal as Internal
import System.Directory
import System.Environment (lookupEnv)
import System.Process

Expand Down Expand Up @@ -69,7 +70,9 @@ new config = do
drawImage :: FilePath -> IO Cleanup
drawImage path = do
content <- B.readFile path
resp <- fmap BLU.fromString $ readProcess "wezterm.exe" ["cli", "list", "--format", "json"] []

wez <- wezExecutable
resp <- fmap BLU.fromString $ readProcess wez ["cli", "list", "--format", "json"] []
let panes = (A.decode resp :: Maybe [Pane])

Internal.withEscapeSequence $ do
Expand All @@ -88,6 +91,15 @@ wezArString i p | i < p = "width=auto;height=95%;"
| otherwise = "width=100%;height=auto;"


--------------------------------------------------------------------------------
wezExecutable :: IO String
wezExecutable = do
w <- findExecutable "wezterm.exe"
case w of
Nothing -> return "wezterm"
Just x -> return x


--------------------------------------------------------------------------------
imageAspectRatio :: DynamicImage -> Double
imageAspectRatio i = imgW i / imgH i
Expand Down

0 comments on commit c361a56

Please sign in to comment.