[Answered] Cinnamon runs javascript -- How?

Please post suggestions for improvement of Cinnamon here
https://github.com/linuxmint/Cinnamon
Post Reply
markfilipak
Level 5
Level 5
Posts: 589
Joined: Sun Mar 10, 2013 8:08 pm
Location: Ohio (formerly California), USA

[Answered] Cinnamon runs javascript -- How?

Post by markfilipak » Mon Mar 12, 2018 11:16 pm

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 markfilipak on Wed Mar 14, 2018 6:19 pm, edited 3 times in total.
Please don't refer me to github. Their words: "This repository isn't a support forum"
Acer Predator G9-792 > Win10-1511 > VBox > Mint18.2 + Cinnamon -or-
Dell Inspiron 15-3567 > Win10-1709 > VBox > Mint18.2 + Cinnamon

User avatar
Fred Barclay
Level 12
Level 12
Posts: 4158
Joined: Sat Sep 13, 2014 11:12 am
Location: Bumping around in the bush

Re: Cinnamon runs javascript -- How?

Post by Fred Barclay » Mon Mar 12, 2018 11:38 pm

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: 1086
Joined: Sun May 26, 2013 6:25 pm

Re: Cinnamon runs javascript -- How?

Post by JosephM » 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.
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 5
Level 5
Posts: 589
Joined: Sun Mar 10, 2013 8:08 pm
Location: Ohio (formerly California), USA

Re: Cinnamon runs javascript -- How?

Post by markfilipak » Tue Mar 13, 2018 2:04 am

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.
Please don't refer me to github. Their words: "This repository isn't a support forum"
Acer Predator G9-792 > Win10-1511 > VBox > Mint18.2 + Cinnamon -or-
Dell Inspiron 15-3567 > Win10-1709 > VBox > Mint18.2 + Cinnamon

JosephM
Level 6
Level 6
Posts: 1086
Joined: Sun May 26, 2013 6:25 pm

Re: Cinnamon runs javascript -- How?

Post by JosephM » 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.

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 5
Level 5
Posts: 589
Joined: Sun Mar 10, 2013 8:08 pm
Location: Ohio (formerly California), USA

Re: Cinnamon runs javascript -- How?

Post by markfilipak » Tue Mar 13, 2018 5:32 pm

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.
Please don't refer me to github. Their words: "This repository isn't a support forum"
Acer Predator G9-792 > Win10-1511 > VBox > Mint18.2 + Cinnamon -or-
Dell Inspiron 15-3567 > Win10-1709 > VBox > Mint18.2 + Cinnamon

JosephM
Level 6
Level 6
Posts: 1086
Joined: Sun May 26, 2013 6:25 pm

Re: Cinnamon runs javascript -- How?

Post by JosephM » Wed Mar 14, 2018 4:21 am

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.

Post Reply

Return to “Cinnamon”