• jPV
  • Paladin of the Pegasos
    Paladin of the Pegasos
    jPV
    Posts: 1540 from 2003/2/24
    From: po-RNO
    Hehe, I just made a script in Lua too :D

    If you don't want to have any external dependencies (like SDK or rexxsyslib.library), you can use Lua scripts. They do work out of the box on a plain MorphOS installation.

    Here's the script I made. You can select if you want to modify screens.txt in ENV, ENVARC, or both locations. And the script makes optionally a backup of the original file too.

    Code:
    --[[

    A script to change MorphOS skin prefs. Use at your own risk.

    Usage: LuaX changeskin.lua <location> <screen> <skin>

    - 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
  • »31.01.19 - 15:29
    Profile Visit Website