toaruos/apps/show-toasts.krk

45 lines
1.3 KiB
Plaintext
Raw Normal View History

2021-10-28 13:40:04 +03:00
#!/bin/kuroko
import kuroko
import os
import fileio
import time
time.sleep(2)
try:
let meminfo = {}
let data
with fileio.open('/proc/meminfo','r') as f:
data = f.readlines()
for line in data:
if not ':' in line: continue
let bits = line.strip().split(':',1)
meminfo[bits[0].strip()] = bits[1].strip()
if 'MemTotal' in meminfo:
let kB = int(meminfo['MemTotal'])
if kB < 1000000:
let sock = os.open("/dev/pex/toast",os.O_WRONLY)
let msg = '{"icon":"/usr/share/icons/48/help.png","body":"<b>Low System Memory</b><br>At least 1GiB of RAM is<br>recommended for the Live CD.<br>' + str(kB//1024) + 'MiB was detected."}'
os.write(sock,msg.encode())
try:
let manifest
with fileio.open('/var/msk/manifest','r') as f:
manifest = f.readlines()
let count = 0
for line in manifest:
if line.startswith('['):
count++
if count:
let sock = os.open("/dev/pex/toast",os.O_WRONLY)
let msg = '{"icon":"/usr/share/icons/48/package.png","body":"<b>Packages Available</b><br>' + str(count) + ' package' + ('s' if count > 1 else '') + ' are available from<br>the package repository."}'
os.write(sock,msg.encode())
return 0