Navigation Menu

Skip to content

Commit

Permalink
Allow urlOpenCommand to be multiple words.
Browse files Browse the repository at this point in the history
  • Loading branch information
kquick committed Nov 18, 2022
1 parent 8661bff commit dd5c08e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion docs/sample-config.ini
Expand Up @@ -214,7 +214,7 @@
# The command to use to open attachments and URLs found in chat
# messages.
#
# Matterhorn invokes this command with the URL as a command
# Matterhorn invokes this command with the URL appended as the last command
# argument. Matterhorn assumes the command will perform the opening
# asynchronously, i.e., Matterhorn assumes the command will return
# immediately after invoking a background process to open the URL. This
Expand All @@ -232,6 +232,8 @@
# urlOpenCommand = open
# A typical value for this on Linux is:
# urlOpenCommand = xdg-open
# A more complex alternative:
# urlOpenCommand = qutebrowser --backend webengine --no-err-windows -l critical

# This setting indicates whether the URL-opening command is interactive
# in the terminal. Set this to True if your urlOpenCommand is a terminal
Expand Down
11 changes: 7 additions & 4 deletions src/Matterhorn/State/Common.hs
Expand Up @@ -188,7 +188,9 @@ openWithOpener getTarget = do
mhError $ ConfigOptionMissing "urlOpenCommand"
Just urlOpenCommand -> do
targetResult <- getTarget

let cmdWords = T.words urlOpenCommand
(cmds, args) = splitAt 1 (T.unpack <$> cmdWords)
cmd = if null cmds then "$BROWSER" else head cmds
case targetResult of
Left e -> do
mhError e
Expand All @@ -202,8 +204,9 @@ openWithOpener getTarget = do
False -> do
outputChan <- use (csResources.crSubprocessLog)
doAsyncWith Preempt $ do
runLoggedCommand outputChan (T.unpack urlOpenCommand)
[target] Nothing Nothing
runLoggedCommand outputChan cmd
(args <> [target])
Nothing Nothing
return Nothing
True -> do
-- If there isn't a new message cutoff
Expand All @@ -230,7 +233,7 @@ openWithOpener getTarget = do
-- handle management of messages delivered while
-- suspended.
mhSuspendAndResume $ \st -> do
result <- runInteractiveCommand (T.unpack urlOpenCommand) [target]
result <- runInteractiveCommand cmd (args <> [target])

let waitForKeypress = do
putStrLn "Press any key to return to Matterhorn."
Expand Down

0 comments on commit dd5c08e

Please sign in to comment.