Skip to content

Commit

Permalink
Terminal: Better yet, disable it properly on prereq failure
Browse files Browse the repository at this point in the history
  • Loading branch information
NiLuJe committed Jan 21, 2024
1 parent 917d4d5 commit 55cc435
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions plugins/terminal.koplugin/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ local function check_prerequisites()
local ptmx = C.open("/dev/ptmx", bit.bor(C.O_RDWR, C.O_NONBLOCK, C.O_CLOEXEC))
if ptmx == -1 then
logger.warn("Terminal: cannot open /dev/ptmx:", ffi.string(C.strerror(ffi.errno())))
error("Device doesn't meet some of the plugin's prerequisites")
return false
end

if C.grantpt(ptmx) ~= 0 then
logger.warn("Terminal: cannot use grantpt:", ffi.string(C.strerror(ffi.errno())))
C.close(ptmx)
error("Device doesn't meet some of the plugin's prerequisites")
return false
end
if C.unlockpt(ptmx) ~= 0 then
logger.warn("Terminal: cannot use unlockpt:", ffi.string(C.strerror(ffi.errno())))
C.close(ptmx)
error("Device doesn't meet some of the plugin's prerequisites")
return false
end
C.close(ptmx)
return true
Expand All @@ -58,7 +58,8 @@ end
-- So sorry for the Tolinos with (Android 4.4.x).
-- Maybe https://f-droid.org/de/packages/jackpal.androidterm/ could be an alternative then.
if (Device:isAndroid() and Device.firmware_rev < 21) or not check_prerequisites() then
return
logger.warn("Terminal: Device doesn't meet some of the plugin's prerequisites")
return { disabled = true, }
end

local Aliases = require("aliases")
Expand Down

0 comments on commit 55cc435

Please sign in to comment.