greshake / i3status-rust

Very resourcefriendly and feature-rich replacement for i3status, written in pure Rust
GNU General Public License v3.0
2.85k stars 470 forks source link

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

Open tkapias opened 1 year ago

tkapias commented 1 year ago

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:

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.

[[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 commented 1 year ago

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 commented 8 months ago

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