[Answered] Cinnamon runs javascript -- How?

Please post suggestions for improvement of Cinnamon on:
https://github.com/linuxmint/Cinnamon
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
markfilipak
Level 6
Level 6
Posts: 1173
Joined: Sun Mar 10, 2013 8:08 pm
Location: Mansfield, Ohio

[Answered] Cinnamon runs javascript -- How?

Post by markfilipak »

This file: '/usr/share/cinnamon/js/ui/panel.js' says that Cinnamon is executing javascript. It is not alone. My Mint has 4248 javascript files.
3 in /etc/
1 in /opt/
114 in /usr/lib/ &
4130 in /usr/share/

How is Cinnamon running javascript? What is the runtime? How is a javascript submitted?

Any reference -- anything at all -- will be gratefully received.

Warm Regards,
Mark.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 4 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
Fred Barclay
Level 12
Level 12
Posts: 4185
Joined: Sat Sep 13, 2014 11:12 am
Location: USA primarily

Re: Cinnamon runs javascript -- How?

Post by Fred Barclay »

I'm afraid I can't tell you how since I try to stay as far away from writing javascript as possible :), but GitHub reports that Cinnamon is 46% javascript so this isn't that surprising.
Maybe looking at the source can help? I think most of the javascript stuff is in js/
https://github.com/linuxmint/Cinnamon

Hopefully someone else with more knowledge can chime in here.
Cheers!
Fred
Image
"Once you can accept the universe as matter expanding into nothing that is something, wearing stripes with plaid comes easy."
- Albert Einstein
JosephM
Level 6
Level 6
Posts: 1459
Joined: Sun May 26, 2013 6:25 pm

Re: Cinnamon runs javascript -- How?

Post by JosephM »

It's done via cjs which you can fiind here: https://github.com/linuxmint/cjs

Cjs is a fork of upstream gnome gjs which gnome-shell uses for the same purpose. They in turn use libmozjs.
When I give opinions, they are my own. Not necessarily those of any other Linux Mint developer or the Linux Mint project as a whole.
markfilipak
Level 6
Level 6
Posts: 1173
Joined: Sun Mar 10, 2013 8:08 pm
Location: Mansfield, Ohio

Re: Cinnamon runs javascript -- How?

Post by markfilipak »

JosephM wrote: Tue Mar 13, 2018 1:23 am It's done via cjs which you can fiind here: https://github.com/linuxmint/cjs

Cjs is a fork of upstream gnome gjs which gnome-shell uses for the same purpose. They in turn use libmozjs.
Thanks Joseph. But you misunderstand my question -- my fault.

I do not have 'cjs' installed, yet Cinnamon runs javascript. The whole UI is javascript residing in '/user/share/cinnamon/js/'. My question is: How does the javascript: '/user/share/cinnamon/js/ui/main.js' get started? -- As you see, I've learned a little bit more since I posted the question.

CORRECTION: I just checked with 'synaptic'. I do have 'cjs' installed. So is 'cjs /user/share/cinnamon/js/ui/main.js' how Cinnamon is started?

Regards,
Mark.
JosephM
Level 6
Level 6
Posts: 1459
Joined: Sun May 26, 2013 6:25 pm

Re: Cinnamon runs javascript -- How?

Post by JosephM »

No, it's actually more complicated than that. That is where the js code is started. Cinnamon is actually started by cinnamon-session which starts all the needed pieces. For the shell itself it also actually starts from the C code which in turn starts the js code. That's super simplified but you get the idea.

Is there a specific purpose you are wondering? You might get a better answer if I understood better what you were after.
When I give opinions, they are my own. Not necessarily those of any other Linux Mint developer or the Linux Mint project as a whole.
markfilipak
Level 6
Level 6
Posts: 1173
Joined: Sun Mar 10, 2013 8:08 pm
Location: Mansfield, Ohio

Re: Cinnamon runs javascript -- How?

Post by markfilipak »

JosephM wrote: Tue Mar 13, 2018 3:23 am No, it's actually more complicated than that. That is where the js code is started. Cinnamon is actually started by cinnamon-session which starts all the needed pieces. For the shell itself it also actually starts from the C code which in turn starts the js code. That's super simplified but you get the idea.
So it's 'cinnamon-session' that makes the transition from ELF to JS, eh? Thanks. Is it 'cinnamon-session' that loads 'cjs' & runs 'cjs /user/share/cinnamon/js/ui/main.js'?

Is there some documentation for this stuff somewhere that you can cite?
Is there a specific purpose you are wondering? You might get a better answer if I understood better what you were after.
I'm a retired engineer. Knowing how systems work makes it easier to maintain & fix them. You're welcome to peruse my profile. Also, I've decided to hack the way the Switcher (default keybinding: Alt-Tab) works -- or, alternatively, crafting & adding handlers to implement exposing/hiding/operating the Panel's 'Window list' applet via the keyboard - and understanding what to touch and what not to touch is part of the needed understanding.
JosephM
Level 6
Level 6
Posts: 1459
Joined: Sun May 26, 2013 6:25 pm

Re: Cinnamon runs javascript -- How?

Post by JosephM »

Also, I've decided to hack the way the Switcher (default keybinding: Alt-Tab) works -- or, alternatively, crafting & adding handlers to implement exposing/hiding/operating the Panel's 'Window list' applet via the keyboard - and understanding what to touch and what not to touch is part of the needed understanding.
You can modify anything inside of /usr/share/cinnamon/js. It's reloaded anytime you restart Cinnamon. Just be aware that if you make a syntax error or something in there it can cause Cinnamon to crash on restart so make sure you are comfortable getting back to a working version. If you do make changes, they will be overwritten with any Cinnamon update.

If you want to modify the window list, since it's an applet, I would simply copy it, rename it, and put it in ~/.local/cinnamon/applets. That way it won't get overwritten and you can use it instead of the built in one.
When I give opinions, they are my own. Not necessarily those of any other Linux Mint developer or the Linux Mint project as a whole.
Locked

Return to “Cinnamon”