matryer / matryer/xbar-plugins

Not able to get send curl command on click working

Open
#1,775 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Shell
Stars
2.6k
Forks
1.1k
Avg merge
9d 15h
Merged PRs (30d)
1

Description

Dear all, this is not really an issue I assume but more a problem on my end that I don't understand the syntax.

On click I'm trying to send a curl POST command to turn off the lights. I'm using the following code for the plugin:
#!/usr/bin/env bash
echo "TEST | color=green"
echo "---"
echo "Lights off | shell='/usr/bin/curl -X POST --header /"Content-Type: text/plain/" --header /"Accept: application/json/" -d /"OFF/" /"http://192.168.1.108:8080/rest/items/lichtDGBuero/"' terminal=true"

I'm using terminal=true for debugging. In the terminal the command is always wrapped in single quotes which is why it wouldn't execute properly I assume.

Last login: Sat Feb 5 15:50:45 on ttys002
martm106@martm106-AJMD6T ~ % '/usr/bin/curl -X POST --header /Content-Type: text/plain/ --header /Accept: application/json/ -d /OFF/ /http://192.168.1.108:8080/rest/items/lichtDGBuero/'
zsh: no such file or directory: /usr/bin/curl -X POST --header /Content-Type: text/plain/ --header /Accept: application/json/ -d /OFF/ /http://192.168.1.108:8080/rest/items/lichtDGBuero/

I've tried replacing with double quotes, escaping etc. but without any luck. Could anyone here help me what the correct code would be in this case? Thanks so much!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the shell plugin command and terminal output included in the issue, focusing on how the curl command is quoted when terminal=true is used. Check the resulting command in the relevant xbar plugin documentation or examples, then verify that clicking the menu item runs the POST request successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, shell, zsh
Domain
cli, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.