Sway : Add tooltip for display.

This commit is contained in:
Dmitry Voronin 2024-05-08 21:12:48 +03:00
parent 97645805aa
commit 83a5c4122a
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
3 changed files with 16 additions and 8 deletions

View file

@ -1,4 +1,6 @@
{ setting, style, ... }: {
{ setting, style, ... }: let
refreshInterval = 1;
in {
text = ''
// -*- mode: jsonc -*-
{
@ -69,7 +71,7 @@
},
"custom/powerlimit": {
"exec": "powerlimit waybar",
"interval": 1,
"interval": ${toString(refreshInterval)},
"on-click-right": "powerlimit toggle"
},
"pulseaudio": {
@ -114,12 +116,14 @@
},
"custom/powersave": {
"exec": "powersave waybar",
"interval": 1,
"interval": ${toString(refreshInterval)},
"on-click": "foot -e bash -c btop",
"on-click-right": "powersave toggle"
},
"custom/display": {
"exec": "echo 󰍹",
"exec": "swayscript monbar",
"interval": ${toString(refreshInterval)},
"return-type": "json",
"on-click": "swayscript montoggle",
"on-click-right": "swayscript vrrtoggle"
}

View file

@ -20,13 +20,17 @@
# Toggle monitors.
function montoggle() {
if [[ "$(_monstate)" = "off" ]]; then
monon
else
if [[ "$(_monstate)" = "on" ]]; then
monoff
else
monon
fi
}
function monbar() {
printf "{\"text\": \"󰍹\", \"tooltip\": \"Mon: $(_monstate) / Vrr: $(_vrrstate)\"}\n"
}
function _monstate() {
if [[ "''${1}" = "" ]]; then
cat /tmp/.monstate 2> /dev/null || echo on

View file

@ -29,7 +29,7 @@
function _vrrstate() {
if [[ "''${1}" = "" ]]; then
cat /tmp/.vrrstate 2> /dev/null || off
cat /tmp/.vrrstate 2> /dev/null || echo off
else
echo "''${*}" > /tmp/.vrrstate
fi