remove alternates - add ccemux peripherals upon system startup
This commit is contained in:
@@ -1,20 +1,11 @@
|
||||
local ccemux = _G.ccemux
|
||||
local fs = _G.fs
|
||||
local peripheral = _G.peripheral
|
||||
local textutils = _G.textutils
|
||||
|
||||
if ccemux then
|
||||
-- add a System setup tab
|
||||
fs.mount('sys/apps/system/ccemux.lua', 'linkfs', 'packages/ccemux/system/ccemux.lua')
|
||||
|
||||
local Config = require('opus.config')
|
||||
|
||||
for k,v in pairs(Config.load('ccemux')) do
|
||||
if not peripheral.getType(k) then
|
||||
ccemux.attach(k, v.type, v.args)
|
||||
end
|
||||
end
|
||||
|
||||
_G.kernel.hook('clipboard_copy', function(_, args)
|
||||
local data = args[1]
|
||||
if type(data) == 'table' then
|
||||
|
||||
20
ccemux/bin/emustartup.lua
Normal file
20
ccemux/bin/emustartup.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
local ccemux
|
||||
ccemux = _G.ccemux
|
||||
local fs
|
||||
fs = _G.fs
|
||||
local peripheral
|
||||
peripheral = _G.peripheral
|
||||
local unserialize
|
||||
unserialize = _G.textutils.unserialize
|
||||
local CONFIG = 'usr/config/ccemux'
|
||||
if ccemux and fs.exists(CONFIG) then
|
||||
local f = fs.open(CONFIG, 'r')
|
||||
local c = unserialize(f.readAll())
|
||||
f.close()
|
||||
for k, v in pairs(c) do
|
||||
if not peripheral.getType(k) then
|
||||
ccemux.attach(k, v.type, v.args)
|
||||
print(k)
|
||||
end
|
||||
end
|
||||
end
|
||||
16
ccemux/bin/emustartup.moon
Normal file
16
ccemux/bin/emustartup.moon
Normal file
@@ -0,0 +1,16 @@
|
||||
import ccemux from _G
|
||||
import fs from _G
|
||||
import peripheral from _G
|
||||
import unserialize from _G.textutils
|
||||
|
||||
CONFIG = 'usr/config/ccemux'
|
||||
|
||||
if ccemux and fs.exists CONFIG
|
||||
f = fs.open(CONFIG, 'r')
|
||||
c = unserialize(f.readAll())
|
||||
f.close()
|
||||
|
||||
for k,v in pairs c
|
||||
if not peripheral.getType(k)
|
||||
ccemux.attach(k, v.type, v.args)
|
||||
print k
|
||||
@@ -1,5 +1,6 @@
|
||||
local Config = require('opus.config')
|
||||
local UI = require('opus.ui')
|
||||
local Util = require('opus.util')
|
||||
|
||||
local ccemux = _G.ccemux
|
||||
|
||||
@@ -62,7 +63,23 @@ function tab:updatePeripherals(config)
|
||||
self.grid:update()
|
||||
end
|
||||
|
||||
function tab.bootCheck()
|
||||
local startupFile = 'packages/ccemux/bin/emustartup.lua'
|
||||
|
||||
local c = Util.readTable('.startup.boot')
|
||||
if c then
|
||||
for _,v in pairs(c.preload) do
|
||||
if v == startupFile then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
table.insert(c.preload, startupFile)
|
||||
Util.writeTable('.startup.boot', c)
|
||||
end
|
||||
|
||||
function tab:enable()
|
||||
self:bootCheck()
|
||||
local config = Config.load('ccemux')
|
||||
|
||||
local choices = { }
|
||||
|
||||
Reference in New Issue
Block a user