Alexays / Waybar

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

Self-updating lua script (with loops) doesn't show any output #2651

Open maxigaz opened 10 months ago

maxigaz commented 10 months ago

I have a lua script loaded by a custom module in Waybar, which updates itself periodically through its own structure of while loops. Here is how it is configured in ~/.config/waybar/config:

"custom/example": {
    "format": "{}",
    "exec": "lua ~/.config/waybar/scripts/test.lua",
    "tooltip": false,
    "on-click": "pkill -SIGRTMIN+2 waybar",
    "signal": 2
},

If the main logic of the script is wrapped in an infinite while loop, its output is not displayed on Waybar. Here is a minimal example of such a script:

#!/usr/bin/env lua
local function sleep(n)
  os.execute("sleep " .. tonumber(n))
end

while true do
    print('test message')
    sleep(5)
end

If I remove the loop, it works:

#!/usr/bin/env lua
print('test message')

I have this behaviour on Waybar 0.9.24 running on Arch Linux. If I downgrade to Waybar 0.9.22, the issue goes away.

maxigaz commented 7 months ago

If I remove "signal": 2 from the module's configuration, it works.

 "custom/example": {
     "format": "{}",
     "exec": "lua ~/.config/waybar/scripts/test.lua",
     "tooltip": false,
-    "on-click": "pkill -SIGRTMIN+2 waybar",
-    "signal": 2
+    "on-click": "pkill -SIGRTMIN+2 waybar"
 },