diff --git a/common/etc/fstab b/common/etc/fstab index b3a1545..eedfbf8 100644 --- a/common/etc/fstab +++ b/common/etc/fstab @@ -1,3 +1,4 @@ packages/common/ascii.lua urlfs http://pastebin.com/raw/u3kcnyjd packages/common/hexedit.lua urlfs https://pastebin.com/raw/Ds9ajsp4 -packages/common/colors.lua urlfs https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/ignore/colors.lua \ No newline at end of file +packages/common/colors.lua urlfs https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/ignore/colors.lua +packages/common/cowsay.lua urlfs https://pastebin.com/raw/n00VQJsw \ No newline at end of file diff --git a/packages.list b/packages.list index 7b0ab09..0e1d400 100644 --- a/packages.list +++ b/packages.list @@ -16,6 +16,7 @@ [ 'neural' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/neural/.package', -- [ 'pickup' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/pickup/.package', [ 'recipeBook' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/recipeBook/.package', + [ 'screenSaver'] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/screenSaver/.package', [ 'secure' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/secure/.package', [ 'shellex' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/shellex/.package', [ 'swshop' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/swshop/.package', diff --git a/screenSaver/.package b/screenSaver/.package new file mode 100644 index 0000000..fe9252d --- /dev/null +++ b/screenSaver/.package @@ -0,0 +1,6 @@ +{ + title = 'Screen Savers', + repository = 'kepler155c/opus-apps/{{OPUS_BRANCH}}/screenSaver', + description = [[ Various screen savers ]], + license = 'MIT', +} diff --git a/screenSaver/autorun/saver.lua b/screenSaver/autorun/saver.lua new file mode 100644 index 0000000..5caca8d --- /dev/null +++ b/screenSaver/autorun/saver.lua @@ -0,0 +1,72 @@ +local Config = require('opus.config') +local Util = require('opus.util') + +local fs = _G.fs +local kernel = _G.kernel +local multishell = _ENV.multishell +local window = _G.window + +if not multishell then + return +end + +local config = Config.load('saver', { + enabled = true, + timeout = 60, + random = true, + specific = nil, +}) + +local BASE = '/packages/screenSaver' +local SAVERS = fs.combine(BASE, 'savers') + +local timer = config.enabled and os.startTimer(config.timeout) +local saverUid + +local function showScreenSaver() + timer = nil + + local files = fs.list(SAVERS) + local saver = config.specific or fs.combine(SAVERS, files[math.random(1, #files)]) + + local w, h = kernel.terminal.getSize() + local win = window.create(kernel.terminal, 1, 1, w, h, true) + saverUid = multishell.openTab({ + path = saver, + focused = true, + title = 'Saver', + window = win, + }) +end + +kernel.hook({ 'mouse_up', 'mouse_drag', 'key_up' }, function() + if config.enabled then + if timer then + os.cancelTimer(timer) + timer = os.startTimer(config.timeout) + elseif saverUid then + multishell.terminate(saverUid) + saverUid = nil + timer = os.startTimer(config.timeout) + end + end +end) + +kernel.hook('timer', function(_, eventData) + if timer and eventData[1] == timer then + showScreenSaver() + end +end) + +kernel.hook('config_update', function(_, eventData) + if eventData[1] == 'saver' then + Util.merge(config, eventData[2]) + if timer then + os.cancelTimer(timer) + timer = nil + end + if config.enabled then + timer = os.startTimer(config.timeout) + end + end +end) diff --git a/screenSaver/etc/fstab b/screenSaver/etc/fstab new file mode 100644 index 0000000..8811c66 --- /dev/null +++ b/screenSaver/etc/fstab @@ -0,0 +1,8 @@ +sys/apps/system/saver.lua linkfs packages/screenSaver/system/saver.lua +packages/screenSaver/savers/timespace.lua urlfs https://raw.githubusercontent.com/Allen2277/Computercraft/master/Time%20Space%20Screensaver +packages/screenSaver/savers/visualizer.lua urlfs https://raw.githubusercontent.com/Allen2277/Computercraft/master/ScreenSaver +packages/screenSaver/savers/random.lua urlfs https://pastebin.com/raw/XXW0r5zt +packages/screenSaver/savers/melting.lua urlfs http://pastebin.com/raw/raUv6Pap +packages/screenSaver/savers/bubbles.lua urlfs https://pastebin.com/raw/3CeFxk9X +packages/screenSaver/savers/fire.lua urlfs https://pastebin.com/raw/4CY4AYj3 +packages/screenSaver/savers/rain.lua urlfs https://pastebin.com/raw/P86Hm99N \ No newline at end of file diff --git a/secure/saver.lua b/screenSaver/savers/life.lua similarity index 100% rename from secure/saver.lua rename to screenSaver/savers/life.lua diff --git a/screenSaver/system/saver.lua b/screenSaver/system/saver.lua new file mode 100644 index 0000000..87e3b5d --- /dev/null +++ b/screenSaver/system/saver.lua @@ -0,0 +1,54 @@ +local Config = require('opus.config') +local UI = require('opus.ui') + +local config = Config.load('saver', { + enabled = true, + timeout = 60, +}) + +local tab = UI.Tab { + tabTitle = 'Screen Saver', + description = 'Screen saver', + label1 = UI.Text { + x = 2, y = 3, + value = 'Enabled', + }, + checkbox = UI.Checkbox { + x = 20, y = 3, + value = config.enabled + }, + label2 = UI.Text { + x = 2, y = 4, + value = 'Timeout', + }, + timeout = UI.TextEntry { + x = 20, y = 4, width = 6, + limit = 4, + transform = 'number', + value = config.timeout, + accelerators = { + enter = 'update', + }, + }, + button = UI.Button { + x = 20, y = 6, + text = 'Update', + event = 'update', + }, +} + +function tab:eventHandler(event) + if event.type =='checkbox_change' then + config.enabled = not not event.checked + + elseif event.type == 'update' then + config.timeout = self.timeout.value + Config.update('saver', config) + + self:emit({ type = 'success_message', message = 'Settings updated' }) + os.queueEvent('config_update', 'saver', config) + end + return UI.Tab.eventHandler(self, event) +end + +return tab diff --git a/secure/autorun/lock.lua b/secure/autorun/lock.lua index 716c4f0..e4ec30d 100644 --- a/secure/autorun/lock.lua +++ b/secure/autorun/lock.lua @@ -6,6 +6,10 @@ local kernel = _G.kernel local keyboard = device.keyboard local multishell = _ENV.multishell +if not multishell then + return +end + local config = Config.load('secure', { enabled = false, timeout = 60, diff --git a/secure/autorun/startup.lua b/secure/autorun/startup.lua deleted file mode 100644 index 2f5d4ed..0000000 --- a/secure/autorun/startup.lua +++ /dev/null @@ -1,4 +0,0 @@ -local fs = _G.fs - --- add a System setup tab -fs.mount('sys/apps/system/secure.lua', 'linkfs', 'packages/secure/system/secure.lua') diff --git a/secure/etc/fstab b/secure/etc/fstab new file mode 100644 index 0000000..dba7c9c --- /dev/null +++ b/secure/etc/fstab @@ -0,0 +1 @@ +sys/apps/system/secure.lua linkfs packages/secure/system/secure.lua \ No newline at end of file