elkowar / eww

ElKowars wacky widgets
https://elkowar.github.io/eww
MIT License
9.14k stars 379 forks source link

[BUG] Listeners aren't function properly (I think?) #1072

Open Zambieslar opened 5 months ago

Zambieslar commented 5 months ago

Checklist before submitting an issue

Description of the bug

Noticed this on a couple of occasions. Not sure if it's my configuration or a bug, but it doesn't seem very intention. I'm using Socat to connect to hyprland's unix socket for receiving messages. I'm then defining a listener to get the messages when they are emitted from the socket.

Reproducing the issue

Use socat -U - UNIX-CONNECT:/tmp/hypr/e93fbd7c4f991cb8ef03e433ccc4d43587923e15_1713287664/.socket2.sock | rg -o --pcre2 "(?<=DP-\d,)\d{1,2}" to open a connection with the unix socket.

Define a listener (this is my configuration):

(deflisten workspace :initial "" "~/.config/hypr/scripts/currentworkspace")

The script contains the command listed above. The command outputs the correct workspace when ran in the terminal. Attempting to use the same script with the configured listen results in the following error:

2024-04-17T01:23:51.003Z ERROR eww::error_handling_ctx   > Failed to send success response from application thread

Caused by:
    channel closed
 2024-04-17T01:23:51.003Z ERROR eww::error_handling_ctx   > Failed to send success response from application thread

Caused by:
    channel closed

Full configuration listed below.

Expected behaviour

I assume the listener is supposed to run a script once and then listen continuously for output base on the documentation located here and then update the output when it receives the message.

Additional context

Full Configuration

Three files in ~/config/eww: 1. eww.yuck 2. eww.scss 3. widgets.yuck 4. polls.yuck

eww.yuck

``` (include "./polls.yuck") (include "./widgets.yuck") (defwindow bar :monitor 0 :windowtype "dock" :exclusive true :class "main_bar" :geometry (geometry :x "0%" :y "10" :width "99%" :height "10px" :anchor "top center") :reserve (struts :side "top" :distance "4%") (bar)) ```

widgets.yuck

``` (defwidget right [] (box :class "right" :orientation "h" :halign "end" :space-evenly false (cpu) (memory) (storage) (time :hours hours :minutes minutes :seconds seconds))) (defwidget cpu [] (box :class "cpu" :orientation "h" :halign "end" :space-evenly false "󰍛 "{round((EWW_CPU.avg),0)}"%")) (defwidget memory [] (box :class "memory" :orientation "h" :halign "end" :space-evenly false "󰘚 "{round((EWW_RAM.used_mem_perc),0)}"%")) (defwidget storage [] (box :class "storage" :orientation "h" :halign "end" :space-evenly false " "{round((EWW_DISK["/"].used_perc),0)}"%")) (defwidget time [hours minutes seconds] (box :orientation "h" :space-evenly false :halign "end" hours minutes seconds (children))) (defwidget workspaces [] (box :class "workspaces" :orientation "h" :space-evenly true :halign "center" :spacing 5 (box :orientation "h" :space-evenly false :halign "start" (button :onclick "~/.config/hypr/scripts/previousworkspace" "󰥼")) (box :class "currentworkspace" :orientation "h" :space-evenly false :halign "center" (label :text "${workspace}" :visible true)) (box :orientation "h" :space-evenly false :halign "end" (button :onclick "~/.config/hypr/scripts/nextworkspace" "󰥭")))) (defwidget currentwindow [] (box :class "current_window" :orientation "h" :halign "start" {getwindow != "" ? "${getwindow}" : ""})) (defwidget bar [] (centerbox :orientation "h" (currentwindow) (workspaces) (right))) ```

polls.yuck

``` (defpoll seconds :interval "1s" :initial "initial-value" :run-while time-visible `date +%S`) (defpoll minutes :interval "60s" :initial "initial-value" :run-while time-visible `date +%M:`) (defpoll hours :interval "5m" :initial "initial-value" :run-while time-visible `date +%H:`) (deflisten workspace :initial "0" "~/.config/hypr/scripts/currentworkspace") (defpoll getwindow :interval "1s" :initial "~" "hyprctl activewindow | rg -o --pcre2 \"(?<=\-\>).*[^:]\"") ```

eww.scss

``` * { all: unset; //Unsets everything so you can style everything from scratch } // Global Styles .bar { font-family: DejaVu Sans Condensed; color: #F3E6BC; padding: 3px; border-radius: 10px; background-color: rgba($color: #1A1B26, $alpha: 1); } .right { margin-right: 5px; } .current_window { font-family: Iosevka Light; } // Style classes .workspaces button:hover { all: unset; color: #76C2EF; } .workspaces { color: #F3E6BC; } .cpu, .storage, .memory { margin-right: 10px; } ```

fabolous005 commented 1 month ago

I got listen to work when returning integers, but not when returning json or yuck literal... so same here

fabolous005 commented 1 month ago

Actually setting flush=True in my script helped me to get json deflisten to work! (As mentioned here)

w-lfchen commented 1 week ago

as of today, the command does not work in my hyprland setup. you might find a working script here

if you can give me a reproducible example, i'll see whether i can investigate this issue. if this has been resolved, please close this issue.