add import & export of xattr tags
Loving the application. Thank you for your work.
As I have used KDE Plasma for years, I have tagged some files. The tagging system in KDE uses extended file attributes. To be more exact, Dolphin is using user.xdg.tags in the following format:
tag1, tag2, parentTag/subTag, parentTag2/subParent/subTag2
This pull request aims to add 2 additional buttons in the Settings, and the corresponding functions for them:
- import from xattr, just
user.xdg.tagsanduser.baloo.rating - export tags back to xattr (tags and rating)
The PR does not include:
-
user.xdg.comment(I simply never used it) - no automated tests. The existing tests do pass. Manual testing was performed for import and export several times.
In addition trying to run yarn start I would get a warning about APPIMAGE environment variable not being set. I had to add this line to src/main.ts. This is not part of the PR.
--- a/src/main.ts
+++ b/src/main.ts
@@ -27,6 +27,8 @@ const basePath = app.getPath('userData');
const preferencesFilePath = path.join(basePath, 'preferences.json');
const windowStateFilePath = path.join(basePath, 'windowState.json');
+process.env.APPIMAGE = path.join(__dirname, 'dist', `OneFolder-${app.getVersion()}.AppImage`)
+
// if (IS_DEV) {
// Object.defineProperty(app, 'isPackaged', {
// get() {
thank you very much for this, it looks great.
Would you mind sharing some pictures with those tags so I can test it on my machine?
Hello,
You can use these terminal commands to set tags and get tags. In KDE Dolphin (with baloo indexing enabled), the xattr show up in the GUI. Of course, this can be turned into a javascript test instead:
setfattr -n user.baloo.rating -v "10" audiophiles.png # 10 is 5 stars
setfattr -n user.xdg.tags -v "comics/xkcd, black_and_white, stick_figures, parent/subparent/subtag1, parent/subparent/subtag2" audiophiles.png
# to get the attributes back:
getfattr -e text --only-values -d --match="user.xdg.tags" audiophiles.png
[!NOTE] "comics/xkcd" will show up as xkcd below. "comics" parent is still a tag, but also regarded as a "folder" per se. Similarly, "parent/subparent/subtag1" shows up as "subtag1" only.
On my end it looks like this:
After importing into OneFolder it looks like this:
Tags in the sidebar:
Tag chips over the image itself:
[!IMPORTANT] Many of my pictures do not have scores, or tags, or both. As such in the code I added try catch for both to simply console.error. Please, feel free to change this to better suit your standards.