diff --git a/plugins/storagestat.koplugin/main.lua b/plugins/storagestat.koplugin/main.lua new file mode 100644 index 000000000..2f8ed5723 --- /dev/null +++ b/plugins/storagestat.koplugin/main.lua @@ -0,0 +1,54 @@ + +local Device = require("device") + +local filter + +-- TODO(Hzj_jie): Find the right filter for PocketBook +if Device:isKobo() or Device:isPocketBook() then + filter = "mmcblk" +elseif Device:isKindle() then + filter = "' /mnt/us$'" +else + return { disabled = true, } +end + +local InfoMessage = require("ui/widget/infomessage") +local UIManager = require("ui/uimanager") +local WidgetContainer = require("ui/widget/container/widgetcontainer") +local _ = require("gettext") + +local StorageStat = WidgetContainer:new{ + name = "storagestat", + menuItem = { + text = _("Storage Statistics"), + callback = function() + local std_out = io.popen( + "df -h | sed -r 's/ +/ /g' | grep " .. filter .. + " | cut -d ' ' -f 3,4,5,6 | " .. + "awk '{print $4 \" U\" $1 \" F\" $2 \" P\" $3}'" + ) + local msg + if std_out then + msg = std_out:read("*all") + std_out:close() + end + if msg == nil or msg == "" then + msg = _("Failed to retrieve storage information.") + end + + UIManager:show(InfoMessage:new{ + text = msg, + }) + end + } +} + +function StorageStat:init() + self.ui.menu:registerToMainMenu(self) +end + +function StorageStat:addToMainMenu(tab_item_table) + table.insert(tab_item_table.plugins, self.menuItem) +end + +return StorageStat diff --git a/plugins/timesync.koplugin/main.lua b/plugins/timesync.koplugin/main.lua index 4dcf113ea..ab26e4230 100644 --- a/plugins/timesync.koplugin/main.lua +++ b/plugins/timesync.koplugin/main.lua @@ -1,7 +1,7 @@ local Device = require("device") -if not (Device:isKobo() or Device:isKindle() or Device:isPocketbook()) then +if not (Device:isKobo() or Device:isKindle() or Device:isPocketBook()) then return { disabled = true, } end