Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Touché doesn't start on Ubuntu 18.04 #18

Closed
iamjackg opened this issue Apr 6, 2021 · 12 comments
Closed

Touché doesn't start on Ubuntu 18.04 #18

iamjackg opened this issue Apr 6, 2021 · 12 comments
Milestone

Comments

@iamjackg
Copy link

iamjackg commented Apr 6, 2021

Describe the bug

Touché doesn't start on Ubuntu 18.04

Expected behaviour

The main window should appear

Actual behaviour

Nothing happens :P

Logs

When running manually from the terminal, this is all I get:

$ com.github.joseexposito.touche
Gjs-Message: 11:56:26.731: JS LOG: Granite is not available
Gjs-Message: 11:56:26.744: JS WARNING: [resource:///com/github/joseexposito/touche/js/com.github.joseexposito.touche.js line 540 > eval 52]: reference to undefined property "forced"
Gjs-Message: 11:56:26.828: JS LOG: Reading configuration file "/home/jack/.config/touchegg/touchegg.conf"
Gjs-Message: 11:56:26.828: JS WARNING: [resource:///com/github/joseexposito/touche/js/com.github.joseexposito.touche.js line 1251 > eval 54]: reference to undefined property "position"
Gjs-Message: 11:56:26.828: JS WARNING: [resource:///com/github/joseexposito/touche/js/com.github.joseexposito.touche.js line 1322 > eval 109]: reference to undefined property "_text"

(com.github.joseexposito.touche:11390): Gjs-WARNING **: 11:56:26.830: JS ERROR: Error: Text data outside of root node.
Line: 0
Column: 28
Char: ]
error@webpack:///../node_modules/sax/lib/sax.js?:684:10
strictFail@webpack:///../node_modules/sax/lib/sax.js?:711:7
write@webpack:///../node_modules/sax/lib/sax.js?:1104:15
module.exports@webpack:///../node_modules/xml-js/lib/xml2js.js?:411:5
loadConfig@webpack:///../src/config/xml-config.js?:77:20
loadFromFile@webpack:///../src/config/model.js?:97:5
showMainView@webpack:///../src/app-window.js?:89:5
_init@webpack:///../src/app-window.js?:64:7
main/<@webpack:///../src/index.js?:66:22
main@webpack:///../src/index.js?:71:10
run@resource:///org/gnome/gjs/modules/package.js:225:12
@/usr/bin/com.github.joseexposito.touche:11:1

^C

Nothing appears, nothing else happens, and I have to Ctrl+C out of the app.

Your environment

  • Touché version: 2.0.8
  • Touchégg version: 1.0.4
  • Operating System: Ubuntu 18.04
  • Desktop Environment: Gnome
  • Installation method: Debian package
@JoseExposito
Copy link
Owner

Hi! It looks like your config file (placed at ~/.config/touchegg/touchegg.conf) contains text outside the root node.

If you are not familiar with XML, feel free to post it here so I can help you to fix it

@iamjackg
Copy link
Author

iamjackg commented Apr 6, 2021

I should have added that this happens even without a config file. I did notice that the error was coming from the XML parsing library, so I tried adding the default config from the touchegg repo, but that didn't work either.

@iamjackg
Copy link
Author

iamjackg commented Apr 6, 2021

Is there a fallback location for the config file somewhere that might be picked up instead? 🤔

@iamjackg
Copy link
Author

iamjackg commented Apr 6, 2021

Ah, found it:

* @returns {string} System config file path (/usr/share/touchegg/touchegg.conf).

This file looks OK, and yet I still get the error. This is very odd!

@JoseExposito
Copy link
Owner

Yes, as you found out, the system level config file is placed at /usr/share/touchegg/touchegg.conf.

If ~/.config/touchegg/touchegg.conf is not present, the system file is used.

Could you copy and paste the contents of your config file, pleas? (System and/or home please)
Just to make sure it is not corrupted. It is weird, because the parser is convinced that something is going on, but the default config should be fine.

@iamjackg
Copy link
Author

iamjackg commented Apr 6, 2021

Actually hang on -- I wonder if this is some weird issue with xml-js, because it's reporting an error with a ] character, but there definitely are no square brackets in the conf file. I get this same error even if I put random content in the file in both locations.

@iamjackg
Copy link
Author

iamjackg commented Apr 6, 2021

Ah-ha, here we go -- for whatever reason, readFile in xml-config.js is returning "[object GjsModule byteArray]" instead of the actual contents of the file. The XML library is then trying to parse that.

@iamjackg
Copy link
Author

iamjackg commented Apr 6, 2021

More clues! Here's a comment from somebody running into the same issue -- paradoxxxzero/gnome-shell-system-monitor-applet#520 (comment)

Looks like it's an issue with my version of Gnome Shell being older, which makes sense since I'm on 18.04. I previously installed Touché on 20.04 and had no issues. Yay for breaking changes in the Gnome API 😞

@iamjackg
Copy link
Author

iamjackg commented Apr 6, 2021

Alright, one last comment, then I'm done with all the spam. I managed to hack it to a working state by simply returning contents in readFile and freeing it inside loadConfig. This is pretty ugly but at least it'll allow me to use it :)

If you get around to adding a conditional to fix this for older Gnome versions I'm happy to test it out for you!

Cheers, and thanks for building all this -- it's great and makes using Linux on my laptop a much, much nicer experience.

@JoseExposito
Copy link
Owner

Hi and thanks for investigating this.

I wish every bug report were like this one, where the reporter solve their own bug 😆

Yes, it looks like the API is broken so, 2 options here:

  • It shouldn't happen with the Flatpak version, so you can always use that build and get updates for free
  • I know Flatpak is not for every one, so, does this method work for you?
  /**
   * @param {string} path File path.
   * @returns {string} The file contents.
   */
  static readFile(path) {
    const file = Gio.File.new_for_path(path);
    const [success, contents] = file.load_contents(null);

    if (!success) {
      // TODO Handle this error
      throw new Error('Error loading config file');
    }

    let str = ByteArray.toString(contents, 'UTF-8');

    // Workaround for GNOME 3.28:
    // https://github.com/JoseExposito/touche/issues/18
    // https://github.com/paradoxxxzero/gnome-shell-system-monitor-applet/issues/520#issuecomment-489533051
    if (str.match(/GjsModule byteArray/)) {
      str = `${contents}`;
    }

    GLib.free(contents);
    return str;
  }

@JoseExposito
Copy link
Owner

I just tested it and it worked, fixed in master in case you want to build it 😄

@JoseExposito JoseExposito added this to the 1.0.5 milestone Apr 11, 2021
@iamjackg
Copy link
Author

Thank you so much! Sorry for the delay, I had a busy week 😬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants