Writing GNOME extensions - PureScript

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

Sridhar Ratnakumar
Project using purescript-gjs:

autochill, a gnome extension to help you chill by setting up breath time.

https://github.com/purescript-gjs/purescript-gjs

Contribute to purescript-gjs/purescript-gjs development by creating an account on GitHub.
tristanC

Happy to talk about purescript-gjs here too. I think the GNOME extensions bit should be moved to a separate repository since it is not available with pure gjs runtime.

Sridhar Ratnakumar

I avoided writing GNOME extensions just to stay away from having to write JS/TS. @tristanC Would be great to have a template repo that makes it easy to get started. i.e., open in VSCode with nix-env-selector and have everything ready to go including PureScript language server (all setup via nix).

Sridhar Ratnakumar

Sort of like https://github.com/srid/rust-nix-template

Rust project template with Nix (Flakes) and VSCode support - srid/rust-nix-template
tristanC

I'll populate https://github.com/purescript-gjs/purescript-gnome-shell shortly with instructions to get started

PureScript bindings for writting gnome-shell extension - purescript-gjs/purescript-gnome-shell
tristanC

It seems like we could provide such helper:

type Extension env = {
  init :: env -> Effect Unit,
  enable :: env -> Effect Unit,
  disable :: env -> Effect Unit
}
tristanC

or something along those line. The thing is gnome-shell expect a javascript file i'm currently injecting like this:

const env = PS["AutoChill"].create();
function init() { PS["AutoChill"].init(env)(); }
function enable() { PS["AutoChill"].enable(env)(); }
function disable() { PS["AutoChill"].disable(env)(); }

but that's not good because the env needs to be created by the init function, so i'm actually using a Ref (Maybe env)

tristanC

Here is the bootstrap using some dhall template: https://github.com/purescript-gjs/purescript-gnome-shell/tree/main/demo

PureScript bindings for writting gnome-shell extension - purescript-gjs/purescript-gnome-shell