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

Add multi-purpose customizable widgets fo wf-panel #86

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

pacomod
Copy link
Contributor

@pacomod pacomod commented Mar 14, 2021

Hi,
This PR adds multi-purpose customizable widgets to wf-panel:

  • multi-purpose: music player, backlight (see configuration examples below), and hopefully other things I haven't think of yet…
  • customizable: icon, default or dynamic tooltip, mouse buttons and scroll actions can be set by the user.

These are merely 'super'-launchers with a basic widget look (button-like, no animation) and dedicated commands for mouse button/srolll actions and tooltip.
I made this to fit my needs but I hope it can be useful to other wf-shell users as well; it may also be a workaround to issue #22.

Configuration (in wf-shell.ini):
customizables_size = <int>
customizables_spacing = <int>
customizables_invert = <bool>
custom_label_<name> = <string> (mandatory)
custom_icon_<name> = <string>
custom_btn[1-3]_cmd_<name> = <string>
custom_scr_[up|dn]_cmd_<name> = <string>
custom_tooltip_cmd_<name> = <string>

  • customizables_* options impact all customizables widgets
  • custom_*_<name> options are related to custom_label_<name> widget

Important note about custom_tooltip_cmd:
This spawns a synchronous command, therefore waits for it to exit; so be careful with this command.

Configuration example:
customizables_size = 16
customizables_spacing = 2
customizables_invert = true

custom_label_1 = mpc
custom_icon_1 = /usr/share/icons/Adwaita/16x16/emblems/emblem-music-symbolic.symbolic.png
custom_btn1_cmd_1 = mpc toggle
custom_btn2_cmd_1 = mpc consume
custom_btn3_cmd_1 = sonata
custom_scr_up_cmd_1 = mpc seek -00:00:10
custom_scr_dn_cmd_1 = mpc seek +00:00:10
custom_tooltip_cmd_1 = mpc current

custom_label_2 = backlight
custom_icon_2 = /usr/share/icons/Adwaita/16x16/devices/video-display-symbolic.symbolic.png
custom_btn1_cmd_2 = brightnessctl --device=intel_backlight set 1
custom_btn2_cmd_2 = killall kanshi || /usr/bin/kanshi
custom_btn3_cmd_2 = wdisplays
custom_scr_up_cmd_2 = brightnessctl --device=intel_backlight set +1%
custom_scr_dn_cmd_2 = brightnessctl --device=intel_backlight set 1%-
custom_tooltip_cmd_2 = brightnessctl --device=intel_backlight --machine-readable info | cut -d, -f4

Coding notes:
I initially tried to inherit from Launchers but got stuck by LauncherInfo pure abstract struct; then I had either to modify the related code, or create new (well, it's almost a copy of Launchers…) dedicated struct/class and let mainteners decide which way is better ;-).
I tried to follow coding style and indentation found in other files but I may have missed some things.

It has been quite a while I haven't programmed in C++ and I've learnt a lot by reading the existing code and making this!

Many thanks to Wayfire contributors for this great WM!
Cheers!

@pacomod pacomod changed the title Add nulti-purpose customizable widgets fo wf-panel Add multi-purpose customizable widgets fo wf-panel Mar 15, 2021
@ammen99 ammen99 self-requested a review March 22, 2021 18:24
@pacomod pacomod closed this Mar 24, 2021
@pacomod pacomod deleted the branch WayfireWM:master March 24, 2021 16:31
@pacomod pacomod deleted the master branch March 24, 2021 16:31
@pacomod pacomod restored the master branch March 24, 2021 16:54
@pacomod
Copy link
Contributor Author

pacomod commented Mar 24, 2021

Sorry… (branching mistake)

@pacomod pacomod reopened this Mar 24, 2021
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.

Sorry for the long delay, looks good overall, and makes for an interesting widget.

@@ -194,6 +195,8 @@ class WayfirePanel::impl
return Widget(new WayfireMenu());
if (name == "launchers")
return Widget(new WayfireLaunchers());
if (name == "custom")
Copy link
Member

Choose a reason for hiding this comment

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

custom sounds quite generic to me. Maybe custom-buttons ?


WfCustomizableButton::WfCustomizableButton()
{
/* I tried to set these as class variables (static),
Copy link
Member

Choose a reason for hiding this comment

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

wf-options need to be created after loading the config file, which happens before widgets are initialized, but it won't work before that :)

{
info->execute(ev->button);
}
if (ev->button == 1 && ev->type == GDK_BUTTON_PRESS)
Copy link
Member

Choose a reason for hiding this comment

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

this doesn't seem to be doing anything, maybe we should remove it?

std::string output;
if (info->cmd_tooltip.length() > 0)
{
info->execute(info->cmd_tooltip, &output);
Copy link
Member

Choose a reason for hiding this comment

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

This is a cool idea, hadn't thought about it, +1

@godalming123
Copy link

what about

[customizables]
size = auto
spacing = 10
invert=false

uptime_pretext = "uptime: "
uptime_text = 0 ; gets ovewritten by uptime_text_command
umtime_text_command = uptime
uptime_infront_icon = /some/icon/path.jpg
uptime_refresh_speed = 3s
uptime_btn1 = alacritty --execute echo "some text with uptime information"
uptime_tooltip = uptime

something similar to polybar modules where you can specify a command to calculate the text by running a command repeatedly. I also think you could have a customizables section this in my opinion improves readability and they could possibly be implemented into the dock as well

@@ -189,5 +189,20 @@
<default>2.5</default>
</option>
</group>
<group>
Copy link
Member

Choose a reason for hiding this comment

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

Hi, thanks for your work here. I wonder if this will include a tray or make it possible? I did want to comment on one thing I noticed:

The style for the xml files isn't enforced by CI, but I would like to see whitespace style consistency. Here, tabs should be used, not spaces.

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.

4 participants