21

I wish to write a cinnamon applet. These are based in JavaScript. The code I wish to write changes services (turning them on and off, similar to WebDeveloperMenuApplet). I don't expect the debugging for the service start/stop/restart to work, but I was wondering how I would debug the menu items and the calls to the functions. I also wish to write a configuration applet that would involve some more complex coding or calls to a external server.

Is it possible to load this into a web browser or is there a better way to debugging this? I don't know where the imports command is pulling so I am not sure how to duplicate this in a web browser.

Currently using IntelliJ IDEA as IDE, but quite will to switch to anything for this project.

3 Answers3

20

Your best bet here is the old trick of printing messages to the terminal. Use global.log(...) for it, the lines are sent to the ~/.cinnamon/glass.log file, to watch them just do:

tail -f ~/.cinnamon/glass.log 

Also, as stated by @elParaguayo, type Alt+F2 to bring the Cinnamon prompt, type in lg and press ENTER to show the Looking Glass Debugger topmost dialog, there you can evaluate expressions by typing them in the Exec: input box and watching the results listed in the Results tab.

Community
  • 1
  • 1
higuaro
  • 15,730
  • 4
  • 36
  • 43
  • 4
    There is a shortcut to toggle the Looking Glass Debugger: `Win+L`. And also as mentioned by @lestcape 's answer, `~/.xsession-errors` is also a file that contains useful debug informations. – DLight Dec 16 '16 at 14:55
  • As of Cinnamon 5.4.9, the `Win+L` stopped working for me. Alt+F2 `lg` still does. – ulidtko Sep 12 '22 at 15:43
8

I know this is over a year old now, but I came across it as I was trying to write my own applet so I though I'd share my experiences.

In terms of debugging, I'm not sure these can be done in a browser. I debugged mine by updating my code, re-activating the applet in Cinnamon and then looking at the error log (Alt+F2 and then type lg).

Not a great solution at all, but it's the only solution I've found.

elParaguayo
  • 1,288
  • 1
  • 13
  • 24
5

Use the browser is not possible. You need to read:

  1. ~/.xsession-errors (because not all errors can appear as a cinnamon errors if you interact with other system applications) or you also can read the terminal output of cinnamon (same as xsession-errors, but will be update dynamically). Execute "cinnamon --replace" to enable the output mode, is possible that this will required to be execute more than one time.

  2. ~/.cinnamon/glass.log or you can use Melange - Cinnamon Debugger. Just click on cinnamon panel, TroubleShoot and find the application.

SomeGuyOnAComputer
  • 5,414
  • 6
  • 40
  • 72
lestcape
  • 259
  • 2
  • 9
  • 2
    I needed to restart Cinnamon to read the updated version of the applet (even though I removed/added the applet, it did not help). I found the "Restart Cinnamon" applet for that (can be downloaded at Applets -> Download) [link](https://cinnamon-spices.linuxmint.com/applets/view/14). But I guess this is brute force, so if anyone knows how to do it better then please share. – Attila123 Mar 18 '18 at 11:20
  • 2
    @Attila123: I found typing this at the command line works: `dbus-send --session --dest=org.Cinnamon.LookingGlass --type=method_call /org/Cinnamon/LookingGlass org.Cinnamon.LookingGlass.ReloadExtension string:'app@domain' string:'APPLET'` (where `app@doman` is the UUID for the applet, as defined in metadata.json). Source: https://gist.github.com/hyOzd/35e913db620b3ba086fb – Michael Scheper Jan 24 '19 at 07:34