base: Show some toasts on startup.

This commit is contained in:
K. Lange 2021-10-28 19:40:04 +09:00
parent d6fc131912
commit ac262d954a
2 changed files with 45 additions and 0 deletions

44
apps/show-toasts.krk Normal file
View File

@ -0,0 +1,44 @@
#!/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

View File

@ -6,4 +6,5 @@ file-browser --wallpaper &
toastd --really # Daemonizes
cd ~
if not stat -q ~/.tutorial-shown then show-tutorial.sh
show-toasts.krk &
exec panel --really