Skip to content
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

"Command output" widgets #148

Merged
merged 9 commits into from
Jul 29, 2023
Merged

Conversation

NamorNiradnug
Copy link
Collaborator

@NamorNiradnug NamorNiradnug commented Apr 4, 2023

Fix #124

TODO:

  • use Glib::spawn_async instead of sync version
  • icon_size option

@mrsteve0924
Copy link

mrsteve0924 commented Jun 14, 2023

this would be a cool widget to get implemented. im on xfce now and use their plugin like this a lot. in my wayfire set up i had to move those command outputs to a tmux window instead

metadata/panel.xml Outdated Show resolved Hide resolved
@NamorNiradnug NamorNiradnug requested a review from ammen99 July 28, 2023 01:54
use `Glib::shell_parse_argv` innstead of running with `/bin/bash`

simplify `icon_position` handling

simplify getting chars from output
Copy link
Member

@ammen99 ammen99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks quite good aside from the one comment about max buffer size.

src/panel/widgets/command-output.cpp Outdated Show resolved Hide resolved
@NamorNiradnug NamorNiradnug requested a review from ammen99 July 29, 2023 00:49
@NamorNiradnug NamorNiradnug requested a review from ammen99 July 29, 2023 21:03
Copy link
Member

@ammen99 ammen99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great now, thanks :)

@ammen99 ammen99 merged commit ff9f791 into WayfireWM:master Jul 29, 2023
@birdie-github
Copy link

A huge thank you for the patch.

It looks like "Period" is specified in seconds but it's not mentioned. Please do.

@birdie-github
Copy link

birdie-github commented Jul 29, 2023

One more thing: XFCE's generic monitor plugin allows quite rich output formatting options including setting font, font style, font color, icon, etc. Hopefully you could look into that as well:

https://docs.xfce.org/panel-plugins/xfce4-genmon-plugin/start

That is a ton of work however, so it's really up to you.

What would be really nice to see as the barebones is:

  • Being able to set a tooltip
  • Being able to set a command which gets executed when the applet is clicked
  • Being able to set colors for text fragments inside the applet

In a perfect world it would be great if Wayfire could just use ... XFCE plugins directly. The API is there. XFCE now uses GTK3 which is Wayland compatible.

That will allow you to incorporate a ton of applets basically for free.

@NamorNiradnug
Copy link
Collaborator Author

NamorNiradnug commented Jul 29, 2023

Thanks for your suggestions! Implementing XFCE plugins sounds like a cool idea, I'll look into it.

About other features you mentioned:

  • Being able to set a tooltip

It is able to, use command_output_tooltip_<name> option.

  • Being able to set a command which gets executed when the applet is clicked

Current implementation executes the command on click and updates the label on the panel (that's the same command that is launched periodically). Are you suggesting to make it a separate command?

  • Being able to set colors for text fragments inside the applet

It is able to: it uses Pango Markup and therefore supports colors, font size, styles and etc.

@birdie-github
Copy link

Current implementation executes the command on click and updates the label on the panel (that's the same command that is launched periodically). Are you suggesting to make it a separate command?

Yeah, that's my thinking but I just want to avoid confusion. It won't be nice if clicking the applet could either update it or run an external command, e.g. a terminal application with top in it. So, yeah, we are talking about two different commands, the primary one that generates the applet output and the second one which gets executed when it's called specifically.

XFCE always runs the second command on click, and refreshing requires right mouse clicking and selecting "Update Now" from a pop-up menu. Without a pop-up menu I've now idea how to set them apart. Maybe using middle mouse click?

Anyways, it's all completely up to you. I'm OK if you disregard my request altogether :-)

@mrsteve0924
Copy link

hello, trying to implement this. do i add 'command-output' to 'widgets_x =' in wf-shell.ini?

and then where to add the command to run? thanks

@NamorNiradnug
Copy link
Collaborator Author

hello, trying to implement this. do i add 'command-output' to 'widgets_x =' in wf-shell.ini?

and then where to add the command to run? thanks

Hi. Yes, you add command-output to widgets_x. Then for each command you can specify the following options:

command_output_<name> = <command>  # this one is required
command_output_icon_<name> = <icon-name>
command_output_icon_size_<name> = <size>
# ...

See full list of available options in the metadata/panel.xml file.

@mrsteve0924
Copy link

thanks for the reply. looks good. nice work!

2023-08-02_14:00:48

@soreau
Copy link
Member

soreau commented Sep 29, 2023

thanks for the reply. looks good. nice work!

2023-08-02_14:00:48

This does look nice.. how can I get the weather applet like in this screenshot?

@mrsteve0924
Copy link

@soreau
Copy link
Member

soreau commented Sep 30, 2023

@rodcps
Copy link

rodcps commented Nov 29, 2024

curl -s http://wttr.in/?format=2

check out https://github.com/chubin/wttr.in

I need help using the command-output plugin. I'm a humanities major and I've tried every way to make it work. I'd like to bring up the weather forecast, but I haven't been successful!

I'm editing the wf-shel.ini file and adding the code below:

widgets_center = command-output=curl -H "Accept-Language: pt-br" 'wttr.in/Campinas?format=%l:+%C+%t'

The command output in the bar should be:
Campinas: Overcast +XX°C⏎

But I can't get it to work. I've tried everything. If you can help me with this, I'd appreciate it!

@mrsteve0924
Copy link

mrsteve0924 commented Nov 29, 2024

you need to add 'command-output' to the widget line by itself
widgets_center = command-output

then add your curl statement and other parameters you need to the 'command_output_ ' variable . Here is an example:
command_output_wttr = curl -H "Accept-Language: pt-br" 'wttr.in/Campinas?format=%l:+%C+%t'
command_output_period_wttr = 1200
command_output_tooltip_wttr = echo weather
command_output_icon_wttr =
command_output_icon_size_wttr = 25

@rodcps
Copy link

rodcps commented Dec 1, 2024

you need to add 'command-output' to the widget line by itself widgets_center = command-output

then add your curl statement and other parameters you need to the 'command_output_ ' variable . Here is an example: command_output_wttr = curl -H "Accept-Language: pt-br" 'wttr.in/Campinas?format=%l:+%C+%t' command_output_period_wttr = 1200 command_output_tooltip_wttr = echo weather command_output_icon_wttr = command_output_icon_size_wttr = 25


Thank you very much mrsteve0924! It works now and it looks really cool, just one point to contribute is the line that defines the character size (commands_output_max_chars = 25) which in my case was defined as 2 only, in the end my code looked like this:

commands_output_max_chars = 25
widgets_right = command-output tray volume clock
command_output_wttr = curl wttr.in/Campinas?format=%c%t+%h+%p
command_output_period_wttr = 1200
command_output_tooltip_wttr = echo Time
command_output_icon_wttr =
command_output_icon_size_wttr = 24

Here is the screenshot and thank you very much again!

20241201_08h30m59s_grim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Command output plugin
6 participants