From 89a596a50ec61b8ebd6040b06a7cab994afd1b3a Mon Sep 17 00:00:00 2001 From: joott Date: Tue, 29 Jul 2025 19:08:17 -0400 Subject: full rat --- waybar/config | 12 +++++++++--- waybar/rat.sh | 31 +++++++++++++++++++++++++++++++ waybar/style.css | 11 +++++++++-- 3 files changed, 49 insertions(+), 5 deletions(-) create mode 100755 waybar/rat.sh (limited to 'waybar') diff --git a/waybar/config b/waybar/config index 8da3977..9c89b95 100644 --- a/waybar/config +++ b/waybar/config @@ -3,9 +3,8 @@ "spacing": 4, // Gaps between modules (4px) // Choose the order of the modules - "modules-left": ["sway/workspaces", "sway/mode", "sway/scratchpad", "custom/media"], - "modules-center": ["sway/window"], - "modules-right": ["mpd", "idle_inhibitor", "backlight", "pulseaudio", "network", "temperature", "memory", "battery", "clock", "tray"], + "modules-left": ["sway/workspaces", "sway/mode", "sway/scratchpad", "sway/window"], + "modules-right": ["idle_inhibitor", "backlight", "pulseaudio", "custom/rat", "network", "temperature", "memory", "battery", "clock", "tray"], // Modules configuration "sway/workspaces": { @@ -25,6 +24,13 @@ "tooltip": true, "tooltip-format": "{app}: {title}" }, + "custom/rat": { + "format": "󱌧 {text}", + "return-type": "json", + "exec": "$HOME/.config/waybar/rat.sh 2> /dev/null", + "on-click": "kitty --app-id ration bash -i ration", + "signal": 1, + }, "idle_inhibitor": { "format": "{icon}", "format-icons": { diff --git a/waybar/rat.sh b/waybar/rat.sh new file mode 100755 index 0000000..04cb579 --- /dev/null +++ b/waybar/rat.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +SHARE=$HOME/.local/share/rat + +return_json () { + echo '{"text": "'"$1"'", "class": "'"$2"'"}' +} + +get_time () { + endtime=$(cat $SHARE/data) + remaining=$(($endtime-$(date +%s))) + timer=$(date -u -d @$remaining +%T) + timer=${timer#00:} + timer=${timer#0} + return_json $timer "" +} + +get_program () { + name=$(cat $SHARE/data) + return_json $name "" +} + +status=$(cat $SHARE/status) + +case $status in + 0) return_json caged "" ;; + 1) get_time ;; + 2) return_json waiting waiting ;; + 3) get_program ;; + 4) return_json working "" ;; +esac diff --git a/waybar/style.css b/waybar/style.css index 92c4d65..082ed20 100644 --- a/waybar/style.css +++ b/waybar/style.css @@ -73,7 +73,7 @@ button { #network, #pulseaudio, #wireplumber, -#custom-media, +#custom-rat, #tray, #mode, #idle_inhibitor, @@ -84,11 +84,14 @@ button { border-top: 3px solid @color7; } -#window, #workspaces { margin: 0 4px; } +#window { + margin: 0 20px; +} + /* If workspaces is the leftmost module, omit left margin */ .modules-left > widget:first-child > #workspaces { margin-left: 0; @@ -127,12 +130,15 @@ button { @keyframes blink { to { background-color: #ffffff; + border-top: 3px solid #ffffff; color: #000000; } } +#custom-rat.waiting, #battery.critical:not(.charging) { background-color: #f53c3c; + border-top: 3px solid #f53c3c; color: #ffffff; animation-name: blink; animation-duration: 0.5s; @@ -155,6 +161,7 @@ button { color: #ffffff; } + #network { padding-right: 15px; } -- cgit v1.3