home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.os.linux.mint      Looks pretty on the outside, thats it!      30,566 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 29,108 of 30,566   
   Mark Bourne to Monsieur   
   Re: Keyboard not working   
   07 Sep 25 11:01:37   
   
   From: nntp.mbourne@spamgourmet.com   
      
   Monsieur wrote:   
   > I want to add a second keyboard layout, but Mint menu > Keyboard does   
   > absolutely nothing. No window opens when I click it.   
   >   
   > When typing cinnamon-settings keyboard I get all this:   
   >   
   > /usr/share/cinnamon/cinnamon-settings/cinnamon-settings.py:458:   
   > DeprecationWarning: Gtk.Window.set_wmclass is deprecated   
   >    self.window.set_wmclass(wm_class, wm_class)   
   > Loading Keyboard module   
   > Traceback (most recent call last):   
   >    File "/usr/share/cinnamon/cinnamon-settings/cinnamon-settings.py",   
   > line 811, in    
   >      window = MainWindow()   
   >               ^^^^^^^^^^^^   
   >    File "/usr/share/cinnamon/cinnamon-settings/cinnamon-settings.py",   
   > line 330, in __init__   
   >      if self.load_sidepage_as_standalone():   
   >         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^   
   >    File "/usr/share/cinnamon/cinnamon-settings/cinnamon-settings.py",   
   > line 464, in load_sidepage_as_standalone   
   >      self.go_to_sidepage(sp_data.sp, user_action=False)   
   >    File "/usr/share/cinnamon/cinnamon-settings/cinnamon-settings.py",   
   > line 185, in go_to_sidepage   
   >      sidePage.build()   
   >    File "/usr/share/cinnamon/cinnamon-settings/bin/SettingsWidgets.py",   
   > line 212, in build   
   >      self.module.on_module_selected()   
   >    File "/usr/share/cinnamon/cinnamon-settings/modules/cs_keyboard.py",   
   > line 513, in on_module_selected   
   >      _config = json.load(config_file)   
   >                ^^^^^^^^^^^^^^^^^^^^^^   
      
   It looks like it's trying to load a config file in JSON format...   
      
   >    File "/usr/lib/python3.12/json/__init__.py", line 293, in load   
   >      return loads(fp.read(),   
   >             ^^^^^^^^^^^^^^^^   
   >    File "/usr/lib/python3.12/json/__init__.py", line 346, in loads   
   >      return _default_decoder.decode(s)   
   >             ^^^^^^^^^^^^^^^^^^^^^^^^^^   
   >    File "/usr/lib/python3.12/json/decoder.py", line 337, in decode   
   >      obj, end = self.raw_decode(s, idx=_w(s, 0).end())   
   >                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^   
   >    File "/usr/lib/python3.12/json/decoder.py", line 355, in raw_decode   
   >      raise JSONDecodeError("Expecting value", s, err.value) from None   
   > json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)   
      
   ...but the file isn't valid JSON (perhaps corrupted or an incorrect   
   attempt at manually editing).   
      
   > I have no idea what I'm looking at here. I see an error in the last   
   > line, but have no clue what to do about it.   
      
    From looking at   
   `/usr/share/cinnamon/cinnamon-settings/modules/cs_keyboard.py` on my   
   system (Mint 22.1), it's basically loading config files in JSON format   
   from subdirectories of `~/.cinnamon/configs/` and   
   `~/.config/cinnamon/spices/` [1].  It doesn't matter if one of those   
   directories doesn't exist (I only have the second) but it'll search   
   whichever ones do exist.   
      
   One of those files is failing to load, but the exception trace doesn't   
   indicate which one.  If there's a file with a ".json" extension that's   
   not valid JSON, it'll fail with something like what you're seeing.   
      
   [1] It's actually bit more complicated than that, only actually looking   
   in subdirectories corresponding to Cinnamon modules that are enabled in   
   gsettings, and not necessarily attempting to load all the files, but if   
   any are invalid it's potential for trouble.   
      
   > Tried upgrading to 22.2 hoping that would fix the issue, but it didn't.   
   >   
   > Also tried sudo apt install --reinstall cinnamon-control-center as   
   > suggested by an AI but that didn't help either.   
      
   The config files are in your home directory, so reinstalling the package   
   is unlikely to make any difference.   
      
   > Any ideas?   
      
   The following Python code (adapted from the `cinnamon-settings` code I   
   was looking at above) should identify any invalid JSON files in places   
   that `cinnamon-settings` might look.  Put the following code below,   
   between the backticks but not including the backticks, in a new file,   
   e.g. `/tmp/check-cinnamon-settings.py`:   
      
   ```   
   import json   
   import os   
   from pathlib import Path   
      
   OLD_SETTINGS_DIR = Path.joinpath(Path.home(), ".cinnamon/configs/")   
   SETTINGS_DIR = Path.joinpath(Path.home(), ".config/cinnamon/spices/")   
      
   for settings_dir in (OLD_SETTINGS_DIR, SETTINGS_DIR):   
        if not Path.exists(settings_dir):   
            continue   
        for spice in os.listdir(settings_dir):   
            config_path = Path.joinpath(settings_dir, spice)   
            for config in os.listdir(config_path):   
                if not config.endswith(".json"):   
                    continue   
                config_json = Path.joinpath(config_path, config)   
                # print(f"Trying: {config_json}")   
                with open(config_json, encoding="utf-8") as config_file:   
                    try:   
                        _config = json.load(config_file)   
                    except Exception as e:   
                        print(f"Invalid JSON: {config_json}")   
                        print(f"  {type(e).__name__}: {e}")   
   ```   
      
   Then run `python3 /tmp/check-cinnamon-settings.py`.  This should list   
   any invalid JSON files, along with a message indicating where the   
   problem is.  For example:   
      
   ```   
   Invalid JSON: /home/mark/.config/cinnamon/spices/invalid@cinnamon.org/1.json   
      JSONDecodeError: Expecting value: line 1 column 1 (char 0)   
   ```   
      
   Unlike the stack trace from `cinnamon-settings` itself, this shows the   
   name of the file that failed to load, and should also check all files   
   rather than stopping at the first error.   
      
   --   
   Mark.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca