Waybar icon indicating copy to clipboard operation
Waybar copied to clipboard

add click coordinates to script

Open rossmeier opened this issue 1 year ago • 0 comments

The idea is to allow the current relative mouse position {x} and {y} within the widget in percent to be used as an argument to custom scripts

This is a change that I have been using for a while now and that I find really convenient for operating in tablet mode. This way, a script (like [1]) can be used to execute different actions depending on where exactly the mouse (or stylus in the tablet case) clicks. The script can divide the widget surface into a grid of subsurfaces, depending on the reasonable use-case (eg -/+ for brightness, -/mute/+ for volume).

The coordinates are converted to relative percentages within the widget as integers to ease processing by simple scripts that are not capable of complicated math operations. This should still give enough accuracy to accomplish any reasonable subdivision.

One alternative that has been considered considered, to implement the whole grid logic within waybar and allow it to be configured from the config file, as well as different actions for different parts of the grid. This does seem like major feature creep however, compared to the simple implementation that I chose.

If you would be interested in upstreaming this feature, I can add it to the documentation before merging!

[1]

#!/usr/bin/env bash
if [ $1 -gt 50 ]; then
	brightnessctl set 5%+
else
	brightnessctl set 5%-
fi

rossmeier avatar Sep 07 '24 11:09 rossmeier