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 = '' text = ''
// -*- mode: jsonc -*- // -*- mode: jsonc -*-
{ {
@ -69,7 +71,7 @@
}, },
"custom/powerlimit": { "custom/powerlimit": {
"exec": "powerlimit waybar", "exec": "powerlimit waybar",
"interval": 1, "interval": ${toString(refreshInterval)},
"on-click-right": "powerlimit toggle" "on-click-right": "powerlimit toggle"
}, },
"pulseaudio": { "pulseaudio": {
@ -114,12 +116,14 @@
}, },
"custom/powersave": { "custom/powersave": {
"exec": "powersave waybar", "exec": "powersave waybar",
"interval": 1, "interval": ${toString(refreshInterval)},
"on-click": "foot -e bash -c btop", "on-click": "foot -e bash -c btop",
"on-click-right": "powersave toggle" "on-click-right": "powersave toggle"
}, },
"custom/display": { "custom/display": {
"exec": "echo 󰍹", "exec": "swayscript monbar",
"interval": ${toString(refreshInterval)},
"return-type": "json",
"on-click": "swayscript montoggle", "on-click": "swayscript montoggle",
"on-click-right": "swayscript vrrtoggle" "on-click-right": "swayscript vrrtoggle"
} }

View file

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

View file

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