12 Creating CLIsma app
hupikus edited this page 2026-06-23 01:04:08 -07:00

Intro

CLIsma has 3 classes of applications. they determine the path of an application.

  • default/ is used to refer to system applications.
  • external/ is used to refer to installed third party applications.
  • empty/ is a class that hints that app exists in memory only.
  • classless applications counts as not installed. instead, it uses its folder as class.

All CLIsma save data, such as external/ applications, app saves, and wm preferences, is located in ~/.local/share/CLIsma/.

external/ application code is installed into ~/.local/share/CLIsma/custom/apps/external/, and their saves - into ~/.local/share/CLIsma/config/apps/external/

Default applications could be found in the CLIsma source directory - CLIsma/apps/default/.

Node

Node in CLIsma is a container for an application. Application is a module for its node. The other modules are usually UI and window decoration.

Upon opening an application, for example "default/desktop", CLIsma:

  • creates empty node;
  • reaches for the folder; apps/default/desktop/ in this example
  • reads code inside;
  • adds the application as a module.
  • initializes another modules.

Structure

Application folder could look like this:

coolapp/

.app

coolapp.py

icon.asc

config

icon.asc

Icon of your app. Should be 5 characters in width and 3 in height. If size is different or file is missing or corrupted, icon will be replaced with default one. Example contents of the file:

3 5
/---\
| > |
\___/

.app

Your node config. (Recommended to read about Node first)

.app file has its own parse format: value=key

Examples:

name="CoolApp"
prefHeight=4
prefWidth=45

Arrays is stored like that:

array[]=3
array[]=4
array[]=-8.0

Which results in array = [3, 4, -8.0].

config

config file contains a preset for your application data.

Application code

Getting started

After all this, project is all set. You may have noticed that python file name matches package name. Class name should also match the name. For your app to work, your class should:

  • Inherit Window
  • Have class named same as file name that is same as directory name
  • Have __init__(self, node, args)
  • Respond properly to draw(self, delta); abort(self, delta); resize(self, height, width).

"args" could be None or any other data type.
CLIsma desktop does not use multiprocessing or multiple cpu cores. App should not have blocking code.

To perform expensive operations, pick one option:

  • Split your task into small chunks that could execute in process(self, delta) and not harm the processing thread;
  • Instantiate a thread using python's builtin threading module.

Let's paste this code into coolapp.py:

from type.colors import Colors
from integration.loghandler import Loghandler
from NodeSquad.modules.window import Window

class coolapp(Window):
	def __init__(self, node, args = ''):
		# Base
		self.node = node
		self.controller = node.controller
		self.height = node.height
		self.width = node.width

		# Input
		self.input_subscriptions = [controller.MouseEvents, controller.KeyboardEvents]

		Loghandler.Log("Test app initialized")

	def draw(self, delta):
		self.node.clear()
		self.node.appendStr(self.height // 2, 0, "Hello World!".center(self.width, ' '))

	def abort(self):
		pass

place your app folder in apps/default/ for test and open CLIsma.

Details

  • Users can set their process() rate to whatever they want.
  • You may look at default application's code in apps/default folder - it provides very brief look at the api.