Alexays / Waybar

Highly customizable Wayland bar for Sway and Wlroots based compositors. :v: :tada:
MIT License
6.2k stars 686 forks source link

waybar/custom tooltips #3022

Open Flapper01 opened 5 months ago

Flapper01 commented 5 months ago

What has happened to tooltips in custom modules? I have a weather app which returns 2 strings, 'text', and 'tooltip' which used to display on hover, but now 'text' is displayed instead? I have downgraded waybar to previous version.

Flapper01 commented 5 months ago

OK, solved this - I had tooltip-format statements in my custom modules. Removing those has fixed this issue. However, how do I apply pango markup eg fonts to my tooltips if I can't use a tooltip-format?

RobertMueller2 commented 1 month ago

It's possible, but need to mind the levels of escaping. The below works for me.

I think this was only fairly recently fixed with a453ea3c70195803e9962a97f9243c0c78d4ecdc. That should be part of 0.10.3 and later.

#!/bin/sh

TEXT="";
TOOLTIP="DND is enabled";

if [ -e _testxyz ];then
  TEXT="";
  TOOLTIP="<span color=\\\"#ff0000\\\">Notifications are enabled</span>";
  printf '{"text": "%s", "tooltip": "%s"}
' "$TEXT" "$TOOLTIP"
fi

printf '{}'
{
    "layer": "top", // Waybar at top layer
    "position": "top", // Waybar position (top|bottom|left|right)
    "height" : 20,
    "modules-center": ["custom/test-output"],

    "custom/test-output": {
      "format": "{} <span>icon</span>",
      "exec": "./test-output2.sh",
      "return-type":"json",
      "hide-empty-text": true,
      "interval": 1,
    },
}

satty-20240722-20:20:42