Skip to content

Instantly share code, notes, and snippets.

@demmm
Last active July 18, 2026 12:27
Show Gist options
  • Select an option

  • Save demmm/71f3ac5c3c1413c7f6e6500420f75596 to your computer and use it in GitHub Desktop.

Select an option

Save demmm/71f3ac5c3c1413c7f6e6500420f75596 to your computer and use it in GitHub Desktop.
uptime.lua:
==========================
function init()
barWidget.setUpdateInterval(60000)
update()
end
function update()
local command = 'read -r up _ < /proc/uptime; up=${up%.*}; echo "up $((up/86400)) days $(((up%86400)/3600)):$(((up%3600)/60)):$((up%60))"'
noctalia.runAsync(command, function(result)
if result and result.stdout and result.stdout ~= "" then
local formatted_text = result.stdout:gsub("%s*$", "")
local vertical_layout = formatted_text:gsub(".", "%0\n"):gsub("\n$", "")
if barWidget.isVertical() == true
then
barWidget.setText(vertical_layout)
else
barWidget.setText(formatted_text)
end
end
end)
end
en.json:
=========================
{
"title": "Uptime",
"settings.uptime_dir.label": "Label",
"settings.uptime_dir.description": "Text shown in the bar.",
"settings.glyph.label": "Bar glyph"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment