Add resolution command #40
@@ -0,0 +1,9 @@
|
|||||||
|
Usage: res [FLAGS]
|
||||||
|
Gets or sets the current resolution.
|
||||||
|
|
||||||
|
FLAGS* Specifies extra options when executing the command.
|
||||||
|
[no flags] Displays the current and maximum resolution.
|
||||||
|
-x [number*] Displays the current and maximum resolution on the x-axis.
|
||||||
|
A new x-axis resolution can be specified as a number.
|
||||||
|
-y [number*] Displays the current and maximum resolution on the y-axis.
|
||||||
|
A new y-axis resolution can be specified as a number.
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
local component = require("component")
|
||||||
|
local gpu = component.gpu
|
||||||
|
local shell = require("shell")
|
||||||
|
|
||||||
|
local args = {...}
|
||||||
|
|
||||||
|
local maxX, maxY = gpu.maxResolution()
|
||||||
|
local curX, curY = gpu.getResolution()
|
||||||
|
|
||||||
|
local function setRes()
|
||||||
|
if not(args[1] == "-x" or args[1] == "-y") then
|
||||||
|
print("\x1b[91mUnknown argument. \x1b[39mTry running \x1b[92m\"help res\"")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local lastarg = ""
|
||||||
|
local x, y
|
||||||
|
for i = 1, 3, 2 do
|
||||||
|
if args[i] == "-x" then
|
||||||
|
if lastarg ~= "x" then
|
||||||
|
x = tonumber(args[i + 1])
|
||||||
|
lastarg = "x"
|
||||||
|
else
|
||||||
|
print("\x1b[91mValue \"x\" was set more than once. \x1b[39mTry running \x1b[92m\"help res\"")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
elseif args[i] == "-y" then
|
||||||
|
if lastarg ~= "y" then
|
||||||
|
y = tonumber(args[i + 1])
|
||||||
|
lastarg = "y"
|
||||||
|
else
|
||||||
|
print("\x1b[91mValue \"y\" was set more than once. \x1b[39mTry running \x1b[92m\"help res\"")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if x then
|
||||||
|
if x > maxX then
|
||||||
|
print("\x1b[91mGPU does not support x higher than " .. maxX)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if y then
|
||||||
|
if y > maxY then
|
||||||
|
print("\x1b[91mGPU does not support y higher than " .. maxY)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if x and not(y) then
|
||||||
|
gpu.setResolution(x, curY)
|
||||||
|
print("Successfully set X resolution from \x1b[93m" .. curX .. "\x1b[39m to \x1b[92m" .. x .. "\x1b[39m.")
|
||||||
|
return
|
||||||
|
elseif not(x) and y then
|
||||||
|
gpu.setResolution(curX, y)
|
||||||
|
print("Successfully set Y resolution from \x1b[93m" .. curY .. "\x1b[39m to \x1b[92m" .. y .. "\x1b[39m.")
|
||||||
|
return
|
||||||
|
else
|
||||||
|
gpu.setResolution(x, y)
|
||||||
|
print("Successfully set resolution from \x1b[93m" .. curX .. "x" .. curY .. "\x1b[39m to \x1b[92m" .. x .. "x" .. y .. "\x1b[39m.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function getRes(val)
|
||||||
|
if val == "x" then
|
||||||
|
print("Current X resolution: \x1b[93m" .. curX)
|
||||||
|
print("Maximum supported X resolution: \x1b[92m" .. maxX)
|
||||||
|
elseif val == "y" then
|
||||||
|
print("Current Y resolution: \x1b[93m" .. curY)
|
||||||
|
print("Maximum supported Y resolution: \x1b[92m" .. maxY)
|
||||||
|
else
|
||||||
|
print("Current resolution: \x1b[93m" .. curX .. "x" .. curY)
|
||||||
|
print("Maximum supported resolution: \x1b[92m" .. maxX .. "x" .. maxY)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if #args == 0 then
|
||||||
|
getRes()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if not(#args == 1) then
|
||||||
|
setRes()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local axis = args[1]
|
||||||
|
if axis == "-x" then
|
||||||
|
getRes("x")
|
||||||
|
elseif axis == "-y" then
|
||||||
|
getRes("y")
|
||||||
|
else
|
||||||
|
print("\x1b[91mUnknown argument. \x1b[39mTry running \x1b[92m\"help res\"")
|
||||||
|
end
|
||||||
@@ -1 +1 @@
|
|||||||
{"prompt":"\u001b[92m%s > \u001b[0m","aliases":{"move":"mv","copy":"cp","ag":"argentum","rename":"mv","..":"cd ..","man":"help","del":"rm","delete":"rm","ren":"mv","remove":"rm","list":"ls","wget":"download","dir":"ls","ps":"lscor","poweroff":"shutdown","restart":"reboot"},"splashMessages":["Made by John Haly- I mean Cerulean Blue.","Welcome! Type \"help\" to get started.","Also try KOCOS!","Welcome back, Commander. We have no idea what we're doing.","99.9% bug-free. The remaining 0.1% are features.","0 days since last error.","Everything is fine. The fire is decorative.","Please don't feed the background processes.","Also has fetch!","Anything red is no man's land. Trust me.","Machine...","Abort, Retry, Fail?","What's the deal with /argentum/store?","So cutting-edge you can't hold it in your hand.","Americans are the reason you see colors on-screen. I'm talking about ANSI escape codes, not politics.","Shoutout to Ponali!"],"path":["/halyde/apps/"],"startupMessage":"\n │\n │ %s\n │ %s\n │\n ","defaultWorkingDirectory":"/home/"}
|
{"prompt":"\u001b[92m%s > \u001b[0m","aliases":{"move":"mv","copy":"cp","ag":"argentum","rename":"mv","..":"cd ..","man":"help","del":"rm","delete":"rm","ren":"mv","remove":"rm","list":"ls","wget":"download","dir":"ls","ps":"lscor","poweroff":"shutdown","restart":"reboot","resolution":"res"},"splashMessages":["Made by John Haly- I mean Cerulean Blue.","Welcome! Type \"help\" to get started.","Also try KOCOS!","Welcome back, Commander. We have no idea what we're doing.","99.9% bug-free. The remaining 0.1% are features.","0 days since last error.","Everything is fine. The fire is decorative.","Please don't feed the background processes.","Also has fetch!","Anything red is no man's land. Trust me.","Machine...","Abort, Retry, Fail?","What's the deal with /argentum/store?","So cutting-edge you can't hold it in your hand.","Americans are the reason you see colors on-screen. I'm talking about ANSI escape codes, not politics.","Shoutout to Ponali!"],"path":["/halyde/apps/"],"startupMessage":"\n │\n │ %s\n │ %s\n │\n ","defaultWorkingDirectory":"/home/"}
|
||||||
|
|||||||
Reference in New Issue
Block a user