From a06f8ca97d261114fa1879f2c6a72a0df67b4d99 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Mon, 19 Aug 2024 10:54:00 +0700 Subject: [PATCH] booru: add gui toggle for save in folder by tags --- .config/ags/modules/.configuration/user_options.js | 2 +- .config/ags/modules/sideleft/apis/booru.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.config/ags/modules/.configuration/user_options.js b/.config/ags/modules/.configuration/user_options.js index fb9cf0fe..b1c5e5be 100644 --- a/.config/ags/modules/.configuration/user_options.js +++ b/.config/ags/modules/.configuration/user_options.js @@ -102,7 +102,7 @@ let configOptions = { 'columns': 2, 'batchCount': 20, 'allowNsfw': false, - 'sortInFolderByTags': false, + 'saveInFolderByTags': false, }, 'pages': { 'order': ["apis", "tools"], diff --git a/.config/ags/modules/sideleft/apis/booru.js b/.config/ags/modules/sideleft/apis/booru.js index 23223c31..340c5d34 100644 --- a/.config/ags/modules/sideleft/apis/booru.js +++ b/.config/ags/modules/sideleft/apis/booru.js @@ -110,6 +110,15 @@ export const BooruSettings = () => MarginRevealer({ self.attribute.enabled.value = BooruService.nsfw; }, 'notify::nsfw') }), + ConfigToggle({ + icon: 'sell', + name: 'Save in folder by tags', + desc: 'Saves images in folders by their tags', + initValue: userOptions.sidebar.image.saveInFolderByTags, + onChange: (self, newValue) => { + userOptions.sidebar.image.saveInFolderByTags = newValue; + }, + }), ] }) ] @@ -224,7 +233,7 @@ const BooruPage = (taglist, serviceName = 'Booru') => { const currentTags = BooruService.queries.at(-1).realTagList.filter(tag => !tag.includes('rating:')); const tagDirectory = currentTags.join('+'); let fileExtension = data.file_ext || 'jpg'; - const saveCommand = `mkdir -p $(xdg-user-dir PICTURES)/homework/${data.is_nsfw ? '🌶️/' : ''}${userOptions.sidebar.image.sortInFolderByTags ? tagDirectory : ''} && curl -L -o $(xdg-user-dir PICTURES)/homework/${data.is_nsfw ? '🌶️/' : ''}${userOptions.sidebar.image.sortInFolderByTags ? (tagDirectory + '/') : ''}${data.md5}.${fileExtension} '${data.file_url}'`; + const saveCommand = `mkdir -p $(xdg-user-dir PICTURES)/homework/${data.is_nsfw ? '🌶️/' : ''}${userOptions.sidebar.image.saveInFolderByTags ? tagDirectory : ''} && curl -L -o $(xdg-user-dir PICTURES)/homework/${data.is_nsfw ? '🌶️/' : ''}${userOptions.sidebar.image.saveInFolderByTags ? (tagDirectory + '/') : ''}${data.md5}.${fileExtension} '${data.file_url}'`; execAsync(['bash', '-c', saveCommand]) .then(() => self.label = 'done') .catch(print);