-
-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Click on parts of external_script module output #2243
Comments
Additional information requested.
It may be easier to write a new/custom module based on this kind of output instead. |
I have a script that is able to print out available updates. It looks like this: https://github.com/syyyr/home-repo/blob/main/apps/py3status-aur.bash
The config currently looks like this:
The full config is here: https://github.com/syyyr/home-repo/blob/main/.config/i3status/config
I'd say it is possible to write my own module for this, and AFAIK, I could make it clickable the way I want. However, it has some disadvantages. I wouldn't like to rewrite my simple script to Python, since it's such a simple one. But if I did, I probably couldn't contribute it to the repo, because it seems to me that it's such a niche. Although, there already is a script for Arch updates, so maybe it could be extended? I'm not sure. Considering all this, I figured it would be nice, if I could make my |
Is this for What does
I'm sure it could... if there are aur helpers that offers them... Gracefully adding them is probably tricky. |
No, it's mainly for
Like I said, it's not mainly for the out-of-update script, but here it is:
This could probably be added in some way to the |
Can you try this? https://github.com/lasers/py3status/tree/newmodule-json_lines |
The |
Just one thing. This prints json per line (package), not a list of JSON objects.
This should work... as long as the value doesn't contain a space or such. - format_json = "[\?color=lightblue {name}] [\?color=red {version}] [\?color=lightgrey&show ->] [\?color=lime {upstream}]"
+ format_json = "[\if=status=UP-TO-DATE [\?color=lightblue {name}] [\?color=red {version}] [\?color=lightgrey&show ->] [\?color=lime {upstream}]]" EDIT: Another way of filtering... Add |
Yep, I'm aware of that :) hence "json_lines"
Yeah... well, to be honest, I'd probably just assure that the script outputs what should be printed. I'm not a big fan of the py3status format string.
Yeah, that's what I would probably do. Or just create a script of my own and exec that. Do you plan on making this module more AUR oriented? Now that I think of it, it could probably be just kind of merged into external_script as a different type of "mode". As in, allow external_script to output its output in a more structured way for py3status. Although I understand that you'd prefer people to write their own modules. |
Also, for my specific usecase, I could just have an "external_script_lines" module, and it would do the job for me. A flag could be added to |
I'm not planning on doing anything with I don't think a flag is needed for This would need |
If Thank you for looking into this by the way. |
Maybe this work... diff --git a/py3status/modules/external_script.py b/py3status/modules/external_script.py
index f103c95..64bf6a4 100644
--- a/py3status/modules/external_script.py
+++ b/py3status/modules/external_script.py
@@ -105,7 +105,7 @@ class Py3status:
output = ""
response["full_text"] = self.py3.safe_format(
- self.format, {"output": output, "lines": len(output_lines)}
+ self.format, {"output": self.py3.safe_format(output), "lines": len(output_lines)}
)
return response
and you use echo "[\?color=lightblue&show $NAME] [\?color=red&show $OLD] ..." |
That would definitely help me remove the need to format stuff myself through HTML. I would just need the inidividual |
I assume It should be possible to make whole thing |
As far as I understand, I have these options:
For number 1, I probably couldn't write anything I could contribute to the repo, for the others, I'm willing to contribute, if needed. Which one of these do you think is the best option for my usecase? |
Okay, I didn't realize that number 3 can just be solved with your patch, and that |
I have reworked my script to output py3status format strings and added an on_click action:
and with this, I got my functionality. The on_click action checks if I clicked on a package (by checking if the package is installed), and then opens the associated AUR page. Unfortunately edit:
The NAME composite still includes the space. But like I said, I don't mind the space as long as it works. |
You can use |
Hi. For the past two months I've been using:
with great success. My config currently looks like this: external_script updates {
cache_timeout = 3600
script_path = '$HOME/apps/py3status-aur.bash updates'
on_click 1 = 'exec pacman -Q $OUTPUT_PART && google-chrome-stable https://aur.archlinux.org/packages/$OUTPUT_PART'
}
external_script out-of-date {
cache_timeout = 3600
script_path = '$HOME/apps/py3status-aur.bash out-of-date'
} and the py3status-aur.bash script is this: https://github.com/syyyr/home-repo/blob/main/apps/py3status-aur.bash but basically, it's a script that outputs a AUR updates in the format I want. Clicking the individual parts in the string works flawlessly, and really helps me lookup issues in AUR packages (for example, if the package fails to build). |
Added echo "[\?color=lightblue&show $NAME] [\?color=red&show $OLD][\?if=$NEW [\?color=lightgrey&show -] [\?color=lime&show $NEW]]"
👍 |
thx got both in for the next release! |
Hi, I'd first just like to say thanks for contributing this project. I've been using it for some time and it generally works great. Unfortunately, as a side effect, this change has caused issues referencing For example, consider a script, #!/usr/bin/env bash
echo abc Previously, the following configuration could be used:
The above now returns Edit: perhaps something like this would serve the needs of both composite and simple text? diff --git a/py3status/modules/external_script.py b/py3status/modules/external_script.py
index 64bf6a45..cfc1b214 100644
--- a/py3status/modules/external_script.py
+++ b/py3status/modules/external_script.py
@@ -105,7 +105,7 @@ class Py3status:
output = ""
response["full_text"] = self.py3.safe_format(
- self.format, {"output": self.py3.safe_format(output), "lines": len(output_lines)}
+ self.format, {"output": self.py3.safe_format(output) if output.startswith("[") else output, "lines": len(output_lines)}
)
return response |
How can we help you today?
Hi, I have this kind of a
external_script
module:It basically just shows which packages from the aur should be updated. Now, I thought it'd be handy if I could click on the package, and it'd open the AUR page for it. Right now, I think it is possible to assign a script to
on_click
and even pass the output of the module to it, but there's no way to know which part of the output was clicked. I see that there's a "composite" module feature, which when clicked exports theOUTPUT_PART
variable to the script, but I found no way to output a composite module from anexternal_script
. Is this something like this doable in py3status? Could it be implemented?Thanks.
Your py3status version
The text was updated successfully, but these errors were encountered: