Last active
August 12, 2022 05:42
-
-
Save zwim/b0d46fa83d9dbb853324f3e0c17562b5 to your computer and use it in GitHub Desktop.
Patch for KOReader to show a menu entry for usbnet toggle in the network menu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- a patch for KOReader to add a menu entry for usbnet toggle in the network menu | |
-- for usage on a Kobo eReader | |
local logger = require("logger") | |
local usbnet_toggle_path = "/usr/bin/usbnet-toggle" | |
if lfs.attributes(usbnet_toggle_path, "mode") == "file" then | |
local reader_menu_order = require("ui/elements/reader_menu_order") | |
table.insert(reader_menu_order.network, 2, "network_toggle_usbnet") | |
local NetworkMgr = require("ui/network/manager") | |
local _getMenuTable = NetworkMgr.getMenuTable | |
NetworkMgr.getMenuTable = function(self, common_settings) | |
_getMenuTable(self, common_settings) | |
common_settings.network_toggle_usbnet = { | |
text = "USBNetwork", | |
callback = function() | |
os.execute("/bin/sh " .. usbnet_toggle_path) | |
end, | |
checked_func = function(touchmenu_instance) | |
return os.execute("ifconfig | grep usb0") == 0 | |
end, | |
} | |
end | |
else | |
logger.dbg(usbnet_toggle_path, "not found") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment