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

Assign an action/cmd to a named part of the format with [[block.click]]'s widget key #1871

Open
tkapias opened this issue Apr 20, 2023 · 2 comments

Comments

@tkapias
Copy link

tkapias commented Apr 20, 2023

Since PR #1686, overriding a default action is easy, you just need to write a block.click for the same button.

There were many elements that made me think that you could also override the default action for a specific part or write a new action or cmd for a specific part:

  • Presence of the widget key for [[block.click]] in the blocks doc.
  • @MaxVerevkin explaining his idea for widget_key+named_arguments in 2 merged PR conversations here and here.
  • The fact that default blocks can already specify click actions to some parts.

But, apparently the widget key in [[block.click]] is not implemented or need more documentation, when I use it, the action or cmd are not applied, even on existing parts like prev, play...

I tried with names arguments too (.str(name:'player')) but it makes the configuration fail.

  • Following @MaxVerevkin, this is what i'd like to do for the music block:
[[block]]
block = "music"
format = " $icon{ $combo.str(max_w:25)  󰥠 $player.str(max_w:7, widget:'player') { $volume_icon $volume |} $prev $play.str(widget:'play') $next |} "
volume_step = 3
[[block.click]]
button = "right"
action = "next_player"
widget = "player"
[[block.click]]
button = "left"
cmd = "urxvtc -e sh -c 'vimpc'"
widget = "player"
[[block.click]]
button = "right"
action = "mpc stop"
widget = "play"
[[block.click]]
button = "left"
action = "play_pause"
widget = "play"
[[block.click]]
button = "up"
action = "volume_up"
[[block.click]]
button = "down"
action = "volume_down"
[block.theme_overrides]
idle_bg = "#303549"
@MaxVerevkin
Copy link
Collaborator

But, apparently the widget key in [[block.click]] is not implemented or need more documentation, when I use it, the action or cmd are not applied, even on existing parts like prev, play...

I tried with names arguments too (.str(name:'player')) but it makes the configuration fail.

Yeah, the name: ... was just an idea and nothing more. It would be convenient to use the placeholder name in widget field of click handler, but I didn't implement it because it would produce even more JSON blocks.

Technically prev, play and other "buttons" do have names, but they are undocumented and should not be relied on.

So yes, the widget key is sort of useless right now.

@softmoth
Copy link
Contributor

Minor note: there is issue #1962 for documenting "button" names.

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

No branches or pull requests

3 participants