Skip to content

Instantly share code, notes, and snippets.

@zwim
Last active January 9, 2023 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zwim/40ab3866bee35f414feed95d1717e4c1 to your computer and use it in GitHub Desktop.
Save zwim/40ab3866bee35f414feed95d1717e4c1 to your computer and use it in GitHub Desktop.
Update the clock and battery state every minute
-- a patch for updating the touch menu clock every minute
-- Version 2.0: use closeMenu() to unschedule
-- Version 3.0: use onLeaveStandby to update, too
-- This is just a quick hack, which updates the whole menu.
-- It would be more efficient, if only the TouchMenu.time_info widget would get updated.
local UIManager = require("ui/uimanager")
local TouchMenu = require("ui/widget/touchmenu")
local updateItems_orig = TouchMenu.updateItems
local closeMenu_orig = TouchMenu.closeMenu
TouchMenu.updateItems = function(self)
UIManager:unschedule(self.updateItems)
-- Run original code
updateItems_orig(self)
UIManager:scheduleIn(60.5 - tonumber(os.date("%S")), self.updateItems, self)
end
TouchMenu.closeMenu = function(self)
UIManager:unschedule(self.updateItems)
closeMenu_orig(self) -- this calls onClose
end
TouchMenu.onLeaveStandby = function(self)
TouchMenu.updateItems(self)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment