GTK incompatible with running syncthing under its own user?

I’m running syncthing under its own user on Debian Gnome.

The user has a logon script but no password so that it can be su’d to but not logged in to.

Having installed syncthing GTK, I tried running it under my own user, but it created a new instance.

Tried to run under syncthing user, but it failed trying to access X.

My conclusion is that I can’t run this way with GTK.

Am I right?

Is there a way to use GTK with my user pointing to syncthing under its user?

Isn’t there a way to point it directly towards an API URL?

I don’t think so. I was looking at using it to control a remote host but it seems syncthing-gtk wants to start the daemon itself and attach to it. There are no obvious configurations to point GTK to an already running instance.

I think it can be done (saw something at some point), but I’ve no idea how.

I’ve never used it myself so I might be talking shit, but I imagine that if worst came to worst you could point it to the right config directory (so it picks up the api url), and somehow give it a “syncthing” binary that launches but does nothing. Say, a copy of cat or so. It’s a bit hacky though. And it could run into trouble if it expects to be able to decide the api key from the outside. Or file a feature request. :slight_smile:

1 Like

Well, I want to continue to run syncthing as a systemd service at startup under a dedicated user. I see no benefit for me running any other way.

The file ~/.config/syncthing-gtk/config.json generated is

{
    "autokill_daemon": 2,
    "autostart_daemon": 2,
    "daemon_priority": 0,
    "folder_as_path": true,
    "force_dark_theme": false,
    "icons_in_menu": true,
    "infobox_style": "font_weight=\"bold\" font_size=\"large\"",
    "last_updatecheck": "1970-01-01T01:00:01",
    "max_cpus": 0,
    "minimize_on_start": false,
    "notification_for_error": true,
    "notification_for_folder": false,
    "notification_for_update": true,
    "st_autoupdate": false,
    "syncthing_binary": "/usr/bin/syncthing",
    "use_inotify": [],
    "use_old_header": false,
    "window_position": null
}

Except for root when

"autokill_daemon": 1,
"autostart_daemon": 1,

I’m guessing the daemon is syncthing and that there are at least 3 possible.

So, for now, I’ll give up on GTK and use the web gui and syncthing-inotify.

Thanks for all the responses.

I will not be near my computers for a day or two so I cannot look at the configs for myself but the Syncthing-GTK source shows something interesting.

From https://github.com/syncthing/syncthing-gtk/blob/master/syncthing_gtk/daemon.py

def _read_config(self):     
   # Read syncthing config to get connection url
   configxml = os.path.join(get_config_dir(), "syncthing", "config.xml")

get_config_dir() seems to just look in standard user specific config directories for the xml so you could probably get away with a hardlink to the dedicated user’s xml. Syncthing-GTK may even have a command line flag to handle this similar to Syncthing’s -home flag.

Are you hoping for full control of the daemon or just monitoring? You would have to manage the config file permissions if you want Syncthing-GTK to edit them. I would also look at making a script similar to gksu -u syncthing 'syncthing' to use to execute the service if you need to.

P.S. I don’t pretend to know anything about the workings of Syncthing-GTK. I have just been poking around in some free time while on a locked down windows machine so I could be miles off.

Interesting thought @kluppy.

A link from my ~/.config/syncthing/config.xml might common up the config. A link from my ~/.config/syncthing might common up just about everything.

Permissions should be simple as I already have a common group for syncthing and me.

What worries me is having 2 instances of syncthing running on the same data. How do I get GTK running under me to recognise the instance running under syncthing-user as the real one and not start a second instance?

I think st_gtk tests for an active daemon before starting one. If the config points to the correct daemon and it is active it will connect to it.

If you point St_gtk to the script I suggested it would start the daemon as the synching user if it wasn’t already running.

After prompting for a password.

I’ll backup a bit and give it a go.

Seems to be working. Thanks for the ideas @kluppy.

Needed some more hardkinks in the ~/.config/syncthing dir.

I think I’ll leave the typo.

Out of interest, what extra links did you have to add?

`david@monocerus:~$ cd .config/syncthing-gtk
david@monocerus:~/.config/syncthing-gtk$ ls -lai
total 20
4587521 drwxr-xr-x  2 david david 4096 Jan 12 15:11 .
3407875 drwx------ 23 david david 4096 Jan 18 11:45 ..
*5505058 -rw-rw-r--  2 st    std    622 Jan 11 14:40 config.json
*5505040 -rwxrwxr-x  2 st    std    199 Jan 12 17:23 run_syncthing
*5505089 -rwxrwxr-x  2 st    std    158 Jan 12 17:23 run_syncthing_part2
david@monocerus:~/.config/syncthing-gtk$ ls -lai /home/st/.config/syncthing-gtk
total 20
5505057 drwxrwx--- 2 st std 4096 Jan 11 14:43 .
5505026 drwxr-x--- 4 st std 4096 Jan  7 11:54 ..
5505058 -rw-rw-r-- 2 st std  622 Jan 11 14:40 config.json
5505040 -rwxrwxr-x 2 st std  199 Jan 12 17:23 run_syncthing
5505089 -rwxrwxr-x 2 st std  158 Jan 12 17:23 run_syncthing_part2
david@monocerus:~/.config/syncthing-gtk$ ls -lai ../syncthing
total 32
3408906 drwxr-xr-x  2 david david 4096 Jan 10 20:00 .
3407875 drwx------ 23 david david 4096 Jan 18 11:45 ..
*5505034 -rw-r--r--  2 st    std    615 Jan  6 14:45 cert.pem
*5505063 -rw-rw----  1 st    std   3197 Jan  7 09:24 config.xml
*5505044 -rw-------  1 st    std    165 Jan  7 14:23 csrftokens.txt
*5505037 -rw-r--r--  2 st    std   1070 Jan  6 14:45 https-cert.pem
*5505038 -rw-------  2 st    std   1675 Jan  6 14:45 https-key.pem
*5505039 -rw-------  2 st    std    288 Jan  6 14:45 key.pem
david@monocerus:~/.config/syncthing-gtk$ ls -lai /home/st/.config/syncthing
total 52
5505029 drwxr-x--- 3 st std  4096 Jan 12 23:46 .
5505026 drwxr-x--- 4 st std  4096 Jan  7 11:54 ..
5505034 -rw-r--r-- 2 st std   615 Jan  6 14:45 cert.pem
5505041 -rw------- 1 st st   3190 Jan 12 23:46 config.xml
5505199 -rw------- 1 st st    264 Jan 12 15:54 csrftokens.txt
5505037 -rw-r--r-- 2 st std  1070 Jan  6 14:45 https-cert.pem
5505038 -rw------- 2 st std  1675 Jan  6 14:45 https-key.pem
5505030 drwxr-xr-x 2 st std 20480 Jan 18 11:00 index-v0.11.0.db
5505039 -rw------- 2 st std   288 Jan  6 14:45 key.pem
david@monocerus:~/.config/syncthing-gtk$ 

I’ve starred the hardlinks. st and david are members of std.

Obviously I needed to config.xml and config.json. I got a permissions error on a certificate file (I forget which one) trying to run gtk, so I just did hardlinks for all files in the syncthing directory.

By the way, I haven’t got it all working properly yet. Gtk points to the correct syncthing instance, but I need to sort out gtk starting syncthing properly. Will post when I get round to trying this. `

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.