How to import St library in gjs
Asked Answered
T

2

6

Answer to a similar question suggests that I cannot import Shell stuff in a standalone mode. However, as I understand it, St is a separate library written in C. Yet I still cannot import it in gjs...

I.e.

$ gjs -c "imports.gi.Gtk"

works (i.e. no output). But

$ gjs -c "imports.gi.St"

fails with

Error: Requiring St, version none: Typelib file for namespace 'St' (any version) not found

Is there any way to import St library from a standalone (not GNOME Shell extension) gjs?

Tunstall answered 22/12, 2012 at 12:5 Comment(0)
C
8

Some of them are not there (e.g. Meta, Shell, St) because they are considered "private". Read more here on how to import them: http://mathematicalcoffee.blogspot.ca/2012/09/developing-gnome-shell-extensions_6.html?m=1

St Lib would really (!!!) help in writing apps with custom interfaces due to the use of CSS. If we could use the library with Clutter and gjs it would really attract developers due the easy of use of St and Shell libraries.

Conglobate answered 5/1, 2013 at 5:47 Comment(3)
But I don't see how to import them in that post. As I understand it, it mostly covers documentation.Tunstall
Hmm, yes I tried to copy the St-1.0.typelib to /usr/lib64/girepository-1.0, after that I can do: imports.gi.St but after creating any St objects I get an errorConglobate
I'm accepting the answer on the basis of "because they are considered 'private'".Tunstall
H
0

Please try:

#!/usr/bin/gjs

const res = imports.gi.GIRepository.Repository

res.prepend_search_path('/usr/lib/x86_64-linux-gnu/mutter-11')
res.prepend_search_path('/usr/lib/gnome-shell')

const St = imports.gi.St;

Depending on your setup, the libraries can be on different location. Please also check https://gist.github.com/buzztaiki/1492431 and Could not find Meta, Shell & St in Python's GTK bindings which gjs has

Hukill answered 15/7, 2023 at 5:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.