Skip to content

Commit

Permalink
Rename Ljinux to Beryllium OS
Browse files Browse the repository at this point in the history
  • Loading branch information
bill88t committed Feb 26, 2024
1 parent 83788fe commit 2ae1d26
Show file tree
Hide file tree
Showing 227 changed files with 1,034 additions and 1,126 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
if cptoml.fetch("usb_msc_available", "LJINUX"):
if cptoml.fetch("usb_msc_available", "BERYLLIUM"):
try:
remount("/", False)
remount("/", True)
except RuntimeError:
if cptoml.fetch("usb_msc_enabled", "LJINUX"):
if cptoml.fetch("usb_msc_enabled", "BERYLLIUM"):
term.write(
f"""\n{colors.red_t}Warning:{colors.endc} USB filesystem is permenantly enabled!
While it is enabled, Ljinux will only be able to
While it is enabled, Beryllium will only be able to
access the file system {colors.red_t}READ ONLY{colors.endc}.
To disable it, {colors.red_t}set usb_msc_enabled to 'false'{colors.endc} in '&/settings.toml'!
Expand All @@ -16,6 +16,6 @@
term.write(
f"""\n{colors.red_t}Warning:{colors.endc} USB filesystem is enabled for this boot!
Please reboot to perform write operations from ljinux.
Please reboot to perform write operations from be.
"""
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
rename_process("waitforconnection")
while True:
for pv[get_pid()]["i"] in range(2):
ljinux.io.ledset(7)
be.io.ledset(7)
sleep(0.1)
ljinux.io.ledset(4)
be.io.ledset(4)
sleep(0.1)
if ljinux.api.console_connected():
if be.api.console_connected():
break
ljinux.io.ledset(4)
be.io.ledset(4)
time.sleep(0.2)
time.sleep(0.2) # Delay for the terminal to get used to it.
term.clear_line()
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
rename_process("advance build date")
systemprints(2, "Advancing time to build date")
if time.localtime()[0] < 2021:
ljinux.based.run(
be.based.run(
"date",
[
"set",
str(ljinux.api.getvar("IMPLEMENTATION_DATE").split("-"))[1:-1]
str(be.api.getvar("IMPLEMENTATION_DATE").split("-"))[1:-1]
.replace("'", "")
.replace(",", ""),
],
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions LjinuxRoot/bin/alias.py → Beryllium/bin/alias.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
rename_process("alias")
try:
vr("inpt", ljinux.based.user_vars["argj"].split())
vr("inpt", be.based.user_vars["argj"].split())
vr("eqpos", vr("inpt")[1].find("=", 0))
vr("cmd", vr("inpt")[1][: vr("eqpos")])
vr("alcmd", vr("inpt")[1][vr("eqpos") + 1 :])
Expand All @@ -13,8 +13,8 @@
vr("alcmd", vr("alcmd")[:-1])
else:
raise IndexError
ljinux.based.alias_dict[vr("cmd")] = vr("alcmd")
ljinux.api.setvar("return", "0")
be.based.alias_dict[vr("cmd")] = vr("alcmd")
be.api.setvar("return", "0")
except IndexError:
ljinux.based.error(1)
ljinux.api.setvar("return", "1")
be.based.error(1)
be.api.setvar("return", "1")
File renamed without changes.
8 changes: 8 additions & 0 deletions Beryllium/bin/betitle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
be.based.run(
"title "
+ be.based.system_vars["USER"]
+ "@"
+ be.based.system_vars["HOSTNAME"]
+ ": "
+ be.api.betterpath()
)
File renamed without changes.
16 changes: 16 additions & 0 deletions Beryllium/bin/cat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
rename_process("cat")
vr("inpt", be.based.user_vars["argj"].split())

try:
with be.api.fopen(vr("inpt")[1], "r") as pv[get_pid()]["f"]:
if vr("f") is None:
be.based.error(4, vr("inpt")[1])
be.api.setvar("return", "1")
else:
for pv[get_pid()]["line"] in vr("f"):
term.nwrite(vr("line"))
vrd("line")
be.api.setvar("return", "0")
except IndexError:
be.based.error(1)
be.api.setvar("return", "1")
2 changes: 1 addition & 1 deletion LjinuxRoot/bin/cd.lja → Beryllium/bin/cd.lja
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# change directory
fpexec /bin/cd.py
fpexec /bin/ljinuxtitle.py
fpexec /bin/betitle.py
19 changes: 19 additions & 0 deletions Beryllium/bin/cd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
rename_process("cd")
vr("capdir", getcwd())
vr("opts", be.api.xarg())
if len(vr("opts")["w"]):
vr("target", vr("opts")["w"][0])
if vr("target") == "-":
vr("target", be.based.user_vars["prevdir"])
else:
vr("target", "~")
vr("dr", be.api.isdir(vr("target")))
if vr("dr") == 1:
chdir(be.api.betterpath(vr("target")))
if vr("capdir") != getcwd():
be.api.setvar("prevdir", vr("capdir"))
be.based.olddir = getcwd()
elif not vr("dr"):
be.based.error(14, "cd")
else:
be.based.error(17, "cd")
File renamed without changes.
File renamed without changes.
46 changes: 23 additions & 23 deletions LjinuxRoot/bin/cp.py → Beryllium/bin/cp.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
rename_process("cp")
try:
vr("rd", getcwd())
vr("src", ljinux.api.betterpath(ljinux.based.user_vars["argj"].split()[1]))
vr("srcisd", ljinux.api.isdir(vr("src"), rdir=vr("rd")))
vr("dst", ljinux.api.betterpath(ljinux.based.user_vars["argj"].split()[2]))
vr("dstisd", ljinux.api.isdir(vr("dst"), rdir=vr("rd")))
vr("src", be.api.betterpath(be.based.user_vars["argj"].split()[1]))
vr("srcisd", be.api.isdir(vr("src"), rdir=vr("rd")))
vr("dst", be.api.betterpath(be.based.user_vars["argj"].split()[2]))
vr("dstisd", be.api.isdir(vr("dst"), rdir=vr("rd")))
vrd("rd")

if vr("srcisd") is 2 or (vr("dstisd") is 2 and vr("dst").endswith("/")):
raise OSError
elif vr("srcisd") is 0 and vr("dstisd") in [0, 2]:
with ljinux.api.fopen(vr("src"), "rb") as pv[get_pid()]["srcf"]:
with be.api.fopen(vr("src"), "rb") as pv[get_pid()]["srcf"]:
vr("srcd", vr("srcf").read())
with ljinux.api.fopen(vr("dst"), "wb") as pv[get_pid()]["dstf"]:
with be.api.fopen(vr("dst"), "wb") as pv[get_pid()]["dstf"]:
if vr("dstf") is None:
raise RuntimeError
vr("dstf").write(vr("srcd"))
elif vr("srcisd") is 1 and vr("dstisd") is 2:
ljinux.api.setvar("argj", "mkdir {}".format(vr("dst")))
ljinux.based.command.fpexec("/bin/mkdir.py")
be.api.setvar("argj", "mkdir {}".format(vr("dst")))
be.based.command.fpexec("/bin/mkdir.py")
gc.collect()
gc.collect()
for pv[get_pid()]["i"] in listdir(vr("src")):
term.write(vr("src") + "/" + vr("i") + " -> " + vr("dst") + "/" + vr("i"))
if ljinux.api.isdir(pv[get_pid()]["src"] + "/" + pv[get_pid()]["i"]):
ljinux.api.setvar(
if be.api.isdir(pv[get_pid()]["src"] + "/" + pv[get_pid()]["i"]):
be.api.setvar(
"argj",
"cp " + vr("src") + "/" + vr("i") + " " + vr("dst") + "/" + vr("i"),
)
ljinux.based.command.fpexec("/bin/cp.py")
be.based.command.fpexec("/bin/cp.py")
vr("src", pv[get_pid()]["src"][: vr("src").rfind("/")])
vr("dst", vr("dst")[: vr("dst").rfind("/")])
vr("srcisd", ljinux.api.isdir(vr("src")))
vr("dstisd", ljinux.api.isdir(vr("dst")))
vr("srcisd", be.api.isdir(vr("src")))
vr("dstisd", be.api.isdir(vr("dst")))
else:
with ljinux.api.fopen(vr("src") + "/" + vr("i"), "rb") as srcf:
with be.api.fopen(vr("src") + "/" + vr("i"), "rb") as srcf:
vr("srcd", srcf.read())
with ljinux.api.fopen(vr("dst") + "/" + vr("i"), "wb") as dstf:
with be.api.fopen(vr("dst") + "/" + vr("i"), "wb") as dstf:
dstf.write(vr("srcd"))
vrd("srcd")
gc.collect()
gc.collect()
elif vr("srcisd") is 0 and vr("dstisd") is 1:
with ljinux.api.fopen(vr("src"), "rb") as pv[get_pid()]["srcf"]:
with ljinux.api.fopen(
with be.api.fopen(vr("src"), "rb") as pv[get_pid()]["srcf"]:
with be.api.fopen(
vr("dst") + "/" + vr("src")[vr("src").rfind("/") + 1 :], "wb"
) as pv[get_pid()]["dstf"]:
if vr("dstf") is None:
raise RuntimeError
vr("dstf").write(vr("srcd"))
ljinux.api.setvar("return", "0")
be.api.setvar("return", "0")

except IndexError:
ljinux.based.error(1)
ljinux.api.setvar("return", "1")
be.based.error(1)
be.api.setvar("return", "1")

except RuntimeError:
ljinux.based.error(7)
ljinux.api.setvar("return", "1")
be.based.error(7)
be.api.setvar("return", "1")

except OSError:
ljinux.based.error(4, f=ljinux.based.user_vars["argj"].split()[1])
be.based.error(4, f=be.based.user_vars["argj"].split()[1])
File renamed without changes.
4 changes: 2 additions & 2 deletions LjinuxRoot/bin/date.py → Beryllium/bin/date.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rename_process("date")
vr("args", ljinux.based.user_vars["argj"].split())
vr("args", be.based.user_vars["argj"].split())
try:
if vr("args")[1] == "set":
import rtc
Expand All @@ -19,7 +19,7 @@
)
) # yr, mon, d, hr, m, s, ss, shit,shit,shit
except IndexError:
ljinux.based.error(1)
be.based.error(1)
del rtc
else:
raise IndexError
Expand Down
File renamed without changes.
File renamed without changes.
18 changes: 9 additions & 9 deletions LjinuxRoot/bin/devmode.py → Beryllium/bin/devmode.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
rename_process("devmode")
vr("opts", ljinux.api.xarg())
if cptoml.fetch("usb_msc_available", "LJINUX"):
vr("opts", be.api.xarg())
if cptoml.fetch("usb_msc_available", "BERYLLIUM"):
if "p" in vr("opts")["o"]:
if not cptoml.fetch("usb_msc_enabled", "LJINUX"):
if not cptoml.fetch("usb_msc_enabled", "BERYLLIUM"):
vr("cont", True)
if "q" not in vr("opts")["o"]: # -q skips message & delay
term.write(
"Enabling ljinux developer mode, permenantly, in 5 seconds..\n"
"Enabling Beryllium developer mode, permenantly, in 5 seconds..\n"
+ "Keep in mind that the board will restart immediately after it's enabled.\n"
+ "Press 'Ctrl + C' to abort."
)
Expand All @@ -15,10 +15,10 @@
except KeyboardInterrupt:
vr("cont", False)
term.write("Aborted.")
ljinux.api.setvar("return", "1")
be.api.setvar("return", "1")
if vr("cont"):
remount("/", False)
cptoml.put("usb_msc_enabled", True, "LJINUX")
cptoml.put("usb_msc_enabled", True, "BERYLLIUM")
remount("/", True)
vr("Exit", True, pid=0)
vr("Exit_code", 245, pid=0)
Expand All @@ -31,7 +31,7 @@
vr("cont", True)
if "q" not in vr("opts")["o"]: # -q skips message & delay
term.write(
"Enabling ljinux developer mode for the next boot, in 5 seconds..\n"
"Enabling Beryllium developer mode for the next boot, in 5 seconds..\n"
+ "To enable permenantly, abort and rerun with -p\n"
+ "Keep in mind that the board will restart immediately after it's enabled.\n"
+ "Press 'Ctrl + C' to abort."
Expand All @@ -41,10 +41,10 @@
except KeyboardInterrupt:
vr("cont", False)
term.write("Aborted.")
ljinux.api.setvar("return", "1")
be.api.setvar("return", "1")
if vr("cont"):
remount("/", False)
cptoml.put("usb_msc_onetime", True, "LJINUX")
cptoml.put("usb_msc_onetime", True, "BERYLLIUM")
remount("/", True)
vr("Exit", True, pid=0)
vr("Exit_code", 245, pid=0)
Expand Down
File renamed without changes.
91 changes: 91 additions & 0 deletions Beryllium/bin/df.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
rename_process("df")
from os import statvfs

vr("dfr", statvfs("/")) # board
del statvfs

vr("opts", be.api.xarg())


def human_readable(whatever):
if whatever < 1024: # kb
return f"{int(whatever)}b"
elif whatever < 1048576: # mb
return f"{int(whatever/1024)}K"
elif whatever < 1073741824: # gb
return f"{int(whatever/1048576)}M"
else:
return f"{int(whatever/1073741824)}G"


# get values in bytes
vr("free", vr("dfr")[1] * vr("dfr")[3])
vr("total", vr("dfr")[1] * vr("dfr")[2])
vr("used", vr("total") - vr("free"))

vr("bs", 2)
vr("bs_sps", " " * vr("bs"))

vr(
"vfree",
(human_readable(vr("free")) if "h" in vr("opts")["o"] else str(vr("free")))
+ vr("bs_sps"),
)
vr(
"vtotal",
(human_readable(vr("total")) if "h" in vr("opts")["o"] else str(vr("total")))
+ vr("bs_sps"),
)
vr(
"vused",
(human_readable(vr("used")) if "h" in vr("opts")["o"] else str(vr("used")))
+ vr("bs_sps"),
)
vr("vperc", (str(int(vr("used") * 100 / vr("total"))) + "%"))

vr("tl", len(vr("vtotal")[: -vr("bs")]))
vr("ul", len(vr("vused")[: -vr("bs")]))
vr("fl", len(vr("vfree")[: -vr("bs")]))
vr("pl", len(vr("vperc")[: -vr("bs")]))

vr("sps", [vr("bs_sps")] * 4)

if vr("tl") < 4:
pv[get_pid()]["vtotal"] += " " * (4 - vr("tl"))
else:
pv[get_pid()]["sps"][0] += (vr("tl") - 4) * " "

if vr("ul") < 4:
pv[get_pid()]["vused"] += " " * (4 - vr("ul"))
else:
pv[get_pid()]["sps"][1] += (vr("ul") - 4) * " "

if vr("fl") < 5:
pv[get_pid()]["vfree"] += " " * (5 - vr("fl"))
else:
pv[get_pid()]["sps"][2] += (vr("fl") - 5) * " "

if vr("pl") < 4:
pv[get_pid()]["vperc"] += " " * (4 - vr("pl"))
else:
pv[get_pid()]["sps"][3] += (vr("pl") - 4) * " "

term.write(
"Filesystem Size{}Used{}Avail{}Use%{}Mounted on\n".format(
vr("sps")[0],
vr("sps")[1],
vr("sps")[2],
vr("sps")[3],
)
+ "/"
+ pv[0]["root"]
+ " {}{}{}{}/".format(
vr("vtotal"),
vr("vused"),
vr("vfree"),
vr("vperc"),
)
)

be.api.setvar("return", "0")
del human_readable
1 change: 1 addition & 0 deletions Beryllium/bin/dir.lja
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo "Are you high? This is beryllium, not bimbows.."
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions LjinuxRoot/bin/dropcache.py → Beryllium/bin/dropcache.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
rename_process("dropcache")
vr("opts", ljinux.api.xarg())
vr("opts", be.api.xarg())
if "help" in vr("opts")["o"] or "h" in vr("opts")["o"]:
term.write("Usage: dropcache\n\nClears all code cache.")
else:
ljinux.code_cache.clear()
be.code_cache.clear()
term.write("Cleared all code cache!")
ljinux.api.setvar("return", "0")
be.api.setvar("return", "0")
File renamed without changes.
Loading

0 comments on commit 2ae1d26

Please sign in to comment.