--[[ A script to change MorphOS skin prefs. Use at your own risk. Usage: LuaX changeskin.lua - The "location" argument can be ENV, ENVARC, or BOTH. It defines where the "screens.txt" file is modified. - If the "skin" argument is omitted, the default skin is used. - The "make_backup" setting creates a "screens.txt.bak" file to the corresponding location. - The "screen" argument is case sensitive! Examples: LuaX changeskin.lua ENV Ambient Ater LuaX changeskin.lua BOTH Ambient Default ]] require 'io' require 'os' require 'string' -- CONFIG BEGINS (Use true or false values) make_backup = true -- CONFIG ENDS function change_skin(loc) if make_backup then os.execute('Copy ' .. loc .. ':MUI/screens.txt ' .. loc .. ':MUI/screens.txt.bak CLONE') end local file = io.open(loc .. ':MUI/screens.txt','r') if file then local found local content = file:read('*a') io.close(file) content, found = string.gsub(content, '(N="?' .. screen .. '.-S="?)(%w+)', "%1" .. skin) if found > 0 then file = io.open(loc .. ':MUI/screens.txt','w+') if file then file:write(content) io.close(file) else io.write('Failed to write the file in ' .. loc .. '.\n') end else io.write('Failed to change the skin.\n') end else io.write('Failed to read the file in ' .. loc .. '.\n') end end if #arg > 1 then location = string.upper(arg[1]) screen = arg[2] if arg[3] then skin = arg[3] else skin = 'Default' end if location == 'BOTH' then change_skin('ENVARC') change_skin('ENV') elseif location == 'ENV' then change_skin('ENV') elseif location == 'ENVARC' then change_skin('ENVARC') else io.write('The first argument must be "ENV", "ENVARC", or "BOTH"!\n') end else io.write('At least two arguments (location and screen name) are required.\n') end