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

Include machine name in default target note name #7

Closed
claremacrae opened this issue Jul 23, 2023 · 12 comments
Closed

Include machine name in default target note name #7

claremacrae opened this issue Jul 23, 2023 · 12 comments
Labels
enhancement New feature or request

Comments

@claremacrae
Copy link

Huge thanks for this plugin. It is really going to help with user support on the Tasks plugin.

This is a slightly more simpler alternative to #2, as it does not require adding any settings code and UI.

Scenario

I have a vault which is synced via Obsidian Sync across 3 devices.

If I have the plugin enabled on more than one of these devices, then there will be constant contention and sync conflicts between devices in the content of LOGGING-NOTE.md.

Suggested solution

Please could you consider appending the name of the device to the default filename automatically, so that users get non-conflicting behaviour out of the box.

@claremacrae claremacrae changed the title Include machine name in default file name Include machine name in default target note name Jul 23, 2023
@czottmann
Copy link
Owner

Hi @claremacrae, thanks, that's an excellent suggestion!

Also, your thanks make me unreasonably happy. I'm a big fan of your work and now I am able to give something back, which feels really nice. 🙌🏼

@czottmann czottmann added the enhancement New feature or request label Jul 23, 2023
@claremacrae
Copy link
Author

Wow - thank you for the kind words!

@czottmann
Copy link
Owner

@claremacrae Do you happen to know how to get the device name on mobile? On desktop, it's straightforward (os.hostname()) but since I can't use the Node.js API on mobile …

@claremacrae
Copy link
Author

I’m on mobile at the moment so can’t check. Sorry.

I think if you console.log app you might find something.

Otherwise, I might search in #plugin-dev on Discord. And then ask there.

When using Obsidian Sync, the log shows machine name in a particular format, I think. And I feel it would be good to try to use that same value, if possible.

@czottmann
Copy link
Owner

Good suggestion, thanks! After some serious digging around in Discord, I came across this post:

app.internalPlugins.plugins["sync"].instance.getDefaultDeviceName()

Looks like it fits the bill!

@claremacrae
Copy link
Author

OK. What happens if Sync is disabled? Worth testing with that, I feel.

@claremacrae
Copy link
Author

This is all really interesting.

There is also a nearby post:

See above message for way to grab the Device Name that Sync is using (whether system default or specified by the user) from the Sync plugin internals 🙂

let syncPlugin = app.internalPlugins.plugins["sync"].instance;
console.log(syncPlugin.deviceName ? syncPlugin.deviceName : syncPlugin.getDefaultDeviceName());

@czottmann
Copy link
Owner

In my case, Sync is disabled but Sync is in by default because it's a core plugin and all that. I'm certain .getDefaultDeviceName() will do the trick but over the next few days I'll poke around its source code some more.

@claremacrae
Copy link
Author

In my case, Sync is disabled but Sync is in by default because it's a core plugin and all that. I'm certain .getDefaultDeviceName() will do the trick but over the next few days I'll poke around its source code some more.

OK great. It's not obvious from the Sync docs but it's possible for users to rename their machine for sync:

4BD58C55-D0BE-42EF-AD1A-21996A981B2F

I think that code snippet I posted above would help you, if you wanted to use the user's own name, if supplied...

@czottmann
Copy link
Owner

Oh, now I see, I misread your post, then. Yes, that's true, it should adhere to the user's preference.

czottmann added a commit that referenced this issue Jul 23, 2023
     Device name taken from Sync plugin
@czottmann
Copy link
Owner

Added in 1.2.0, just released. (Found some time and energy, it was a slow Sunday.)

@claremacrae
Copy link
Author

It works great. Thank you!

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

No branches or pull requests

2 participants