element-desktop icon indicating copy to clipboard operation
element-desktop copied to clipboard

System-wide config.json for riot-desktop

Open grahampugh opened this issue 5 years ago • 24 comments

I am trying to set the default URL for the desktop client on Mac. As far as I can understand from the documentation at https://github.com/vector-im/riot-web/blob/master/docs/config.md#desktop-app-configuration I should be able to put a file at ~/Library/Application Support/Riot/config.json, containing the following:

{
    "default_server_name": "staffchat.myserver.com",
}

However, this does not seem to achieve my goal. The URL offered at sign in is still https://matrix-client.matrix.org. I suspect that I am misunderstanding the documentation, or that it is incorrect or lacking the required information.

Describe the solution you'd like I would like clear documentation on how config.json should be used, and where is should/can be saved.

Describe alternatives you've considered Note that I have also tried this location, as this would be more useful for a managed Mac to apply to all users: /Library/Application Support/Riot/config.json This also had no effect.

Additional context The idea solution would be that a Configuration Profile could be deployed in order to apply settings on Mac clients. This is the well established and well-documented method for applying settings to Mac applications, and would be required if you ever wished to deploy the application via the Mac App Store.

grahampugh avatar Mar 18 '20 13:03 grahampugh

You've understood everything about the location of the file correctly, the problem is you have created an invalid JSON file. The trailing comma is not allowed in JSON, remove that and it should work properly.

aaronraimist avatar Mar 18 '20 16:03 aaronraimist

@aaronraimist Thanks that did work, but only when placed in ~/Library/Application Support/Riot/config.json - it doesn't look at /Library/Application Support/Riot/config.json.

Most Mac apps have a hierarchy of settings so that they can be globally administered:

  1. Configuration Profile deployed by MDM.
  2. Global Preference file placed in /Library/Preferences, for example /Library/Preferences/im.riot.app.plist.
  3. User preference file placed in ~/Library/Preferences, for example ~/Library/Preferences/im.riot.app.plist.

For those apps that have not adopted the above standard method, there is still normally a method to deploy global standards, for example in /Library/Application Support/Riot/config.json or occasionally within the application bundle, e.g. /Applications/Riot.app/Contents/Resources/config.json.

Are there any opportunities to supply global settings? Per-user settings do not deploy well on Mac, especially from macOS 10.15 Catalina onwards, where User folders are protected.

For info, Mozilla have recently added the opportunity to supply settings for Firefox via Config Profile along with the config.json method.

grahampugh avatar Mar 19 '20 09:03 grahampugh

Its based on https://www.electronjs.org/docs/api/app#appgetpathname which is ~/Library/Application Support/...

t3chguy avatar Mar 19 '20 09:03 t3chguy

Ah yes, there is a long-standing plea by Mac Admins to get Electron to properly support global configurations.

grahampugh avatar Mar 19 '20 09:03 grahampugh

So to clarify, you want a Third config?

  1. build config, shipped inside the asar archive
  2. (new) installation config, somewhere near the install path
  3. profile config, specified by the user as per https://github.com/vector-im/riot-desktop#user-specified-configjson

t3chguy avatar May 19 '20 11:05 t3chguy

@t3chguy something like that, yes. As I said, most Mac applications provide the ability to set global settings which take precedence over user-specific settings, so that administrators can pre-define certain settings, such as whether the user should be able to search for and download updates, or to predefine server settings for everyone who will use the computer.

I'm aware that most electron apps often don't adhere as well to the standards for Mac as described in my post on March 19, but many still provide some option to set configuration for all users via a config.json outside of the user folders. Something along those lines would be great!

grahampugh avatar May 19 '20 17:05 grahampugh

Same Problem on Linux with the debian packages. Until now, I was overwriting /opt/Riot/resources/webapp/config.json with a custom one after every riot-web package update. So my clients where having the correct default home/identity server setup. Since the update to 1.6.3 this file is ignored so I had to create a ~/.config/Riot/config.json for every single user in their home directory, which is not very practical to deploy changes in the config. I would really love to see a config.json for system config, which is not overwritten by the package updates too :)

airblag avatar Jun 05 '20 11:06 airblag

The internal move to https://github.com/vector-im/riot-desktop in 1.6 is what changed the internal structure, its not as new as 1.6.3.

@airblag just out of interest, would you prefer it in /etc/riot-desktop/config.json or is /opt/riot-desktop/config.json fine too?

t3chguy avatar Jun 05 '20 11:06 t3chguy

The internal move to https://github.com/vector-im/riot-desktop in 1.6 is what changed the internal structure, its not as new as 1.6.3.

Yeah, I blocked the update until I found a solution for this, that why I first tried with 1.6.3

@airblag just out of interest, would you prefer it in /etc/riot-desktop/config.json or is /opt/riot-desktop/config.json fine too?

If it's not overwritten by the package update, I don't really care where is it. But /etc/riot-desktop is a nice place I would think.

airblag avatar Jun 05 '20 11:06 airblag

Has there been a change in the config.json syntax with the move to Element (Riot).app? Our existing method of pre-creating the file at $HOME/Library/Application Support/Riot/config.json no longer picks up the settings now that I'm installing Element (Riot).app, and if I create the file at $HOME/Library/Application Support/Element/config.json, it results in an error message at start up. There is also no effect if I put the file in $HOME/Library/Application Support/Element (Riot)/config.json, though this folder is created on startup.

Also, any progress with the idea of a global config file at /Library/Application Support/Element/config.json (or whichever folder will become the default..!)?

grahampugh avatar Jul 21 '20 12:07 grahampugh

+1 for this one. Run into a trouble situation while upgrading from Riot to Element on Windows Terminal Server 2016.

  • Element should exist only 1 time on these servers, e..g. in Program Files (x86)\Element
  • All users on the TS starts Element from there
  • There should e a system wide config.json on this folder to change HS and disable auto update
  • Normal users never should start checking for updates

Currently TS setup of Element is fully manual.

vsatmydynipnet avatar Jul 25 '20 09:07 vsatmydynipnet

I'm kind of still waiting for this feature to update my linux workstations from riot 1.6.3 to Element, since I don't wanna create the config.json in the home of my users, and I need them to connect to our matrix server as default. Any chance of seeing it soon ?

airblag avatar Sep 02 '20 09:09 airblag

Same Problem on Linux with the debian packages. Until now, I was overwriting /opt/Riot/resources/webapp/config.json with a custom one after every riot-web package update. So my clients where having the correct default home/identity server setup. Since the update to 1.6.3 this file is ignored so I had to create a ~/.config/Riot/config.json for every single user in their home directory, which is not very practical to deploy changes in the config. I would really love to see a config.json for system config, which is not overwritten by the package updates too :)

I'm still trying to enable labs creating ~/.config/Element/config.json, which Element mentions on the startup as the config dir, but it won't read it. In fact I even failed to find the default config, can you give me a hand here @airblag ?

TriplEight avatar Apr 13 '21 19:04 TriplEight

The default config is packaged inside a file called app.asar - it'd be something like https://github.com/vector-im/element-desktop/blob/develop/element.io/release/config.json

t3chguy avatar Apr 13 '21 19:04 t3chguy

@t3chguy thanks, in my case (Ubuntu 20.04) there are

/opt/Element/resources/app.asar 

The first one being an archive and I didn't find how to effectively edit it.

/opt/Element/resources/app.asar.unpacked/
└── node_modules
    └── gifwrap
        ├── LICENSE
        ├── package.json
        ├── src
        │   ├── bitmapimage.js
        │   ├── gifcodec.js
        │   ├── gifframe.js
        │   ├── gif.js
        │   ├── gifutil.js
        │   └── index.js
        └── templates
            └── README.hbs

The second one is unpacked and has no such settings :/

TriplEight avatar Apr 14 '21 18:04 TriplEight

You would need to use https://github.com/electron/asar to unpack it.

t3chguy avatar Apr 14 '21 18:04 t3chguy

@t3chguy yeah, I managed. Nothin like config.json inside. Even reinstallation did not help. How to define which config file if uses, it clearly seems like it's somewhere else.

TriplEight avatar Apr 14 '21 19:04 TriplEight

What's inside the asar then? Element needs a config.json file to function

t3chguy avatar Apr 14 '21 19:04 t3chguy

@t3chguy the tree output is too big, could find only these:

fd config.json                                                                                                                                                                                                              3197ms  Mi 14 Apr 2021 20:03:37 UTC
app.asar.unpacked2/node_modules/@jimp/custom/types/tsconfig.json
app.asar.unpacked2/node_modules/atomically/tsconfig.json
app.asar.unpacked2/node_modules/image-q/demo/html/src/tsconfig.json
app.asar.unpacked2/node_modules/image-q/src/tsconfig.json
app.asar.unpacked2/node_modules/jimp/types/ts3.1/tsconfig.json
app.asar.unpacked2/node_modules/jimp/types/tsconfig.json
app.asar.unpacked2/node_modules/timm/tsconfig.json
app.asar.unpacked2/node_modules/uri-js/tsconfig.json

Still, grepping for settings from https://github.com/vector-im/element-desktop/blob/develop/element.io/release/config.json does return only some of then in the js code, not jsons.

TriplEight avatar Apr 14 '21 20:04 TriplEight

OK, I've managed to make it work. element-desktop didn't warn/error that config.json's syntax is wrong. Or I just don't know how to enable the verbose logs. Short manual:

  1. in order to find where your element-desktop stores the data, run it from the terminal, first two lines of output will be about
    /home/$USER/.config/Element exists: yes
    /home/$USER/.config/Riot exists: no
    
  2. Copy over the default config into /home/$USER/.config/Element /config.json
  3. If the syntax is correct, you'll see the changes in the settings, I found it easy to flag "showLabsSettings": true, so it's seen in the settings right away.

TriplEight avatar May 03 '21 14:05 TriplEight

Is it possible now to add a System-wide config.json for Element in Debian based distribution by adding it to /opt/Element/resources/config.json or /opt/Element/config.json ? Doesn't seem like working...

Thatoo avatar Aug 30 '21 05:08 Thatoo

No, given that this issue is still Open.

t3chguy avatar Aug 31 '21 10:08 t3chguy

Believe solved by https://github.com/element-hq/element-desktop/pull/1921

Half-Shot avatar Oct 18 '24 07:10 Half-Shot

It is not, as you would need to inject an envvar or cli argument, which you cannot do on the default shortcuts/desktop files without the updater then nuking them. This issue asked for checking a standard path e.g. /etc/element-desktop/config.json

t3chguy avatar Oct 18 '24 08:10 t3chguy

Wrongly closed due to action misconfiguration

t3chguy avatar Feb 24 '25 10:02 t3chguy