View Single Post
Old 03-13-2021, 06:51 PM   #375
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,140
Karma: 77213683
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I have this code:

Code:
      {
        "active": true,
        "chain_settings": {
          "chain_links": [
            {
              "action_name": "Single Field Edit",
              "action_settings": {
                "col_name": "#kobocoll",
                "template": "program:\n\tg = field('#genres');\n\tk = field('#kobocoll');\n\tif list_contains(g, ',', '^Fanfiction$', '1', '') then\n\t\tk = list_union(k, 'Fanfiction', ',')\n\tfi;\n\tif list_contains(g, ',', '^Cozy Mystery$', '1', '') then\n\t\tk = list_union(k, 'Cozy Mysteries', ',')\n\tfi;\n\tif list_contains(g, ',', '^Horses$', '1', '') then\n\t\tk = list_union(k, 'Horses', ',')\n\tfi;\n\tif list_contains(g, ',', '^(Fantasy|Science Fiction)$', '1', '') then\n\t\tk = list_union(k, 'Fantasy & Sci-Fi', ',')\n\tfi;\n\tk",
                "value_type": "template"
              },
              "comment": "Update #kobocoll column"
            },
            {
              "action_name": "Calibre Actions",
              "action_settings": {
                "disable_busy_cursor": false,
                "selection": [
                  {
                    "display": "Send to device",
                    "path": [
                      "Send To Device"
                    ]
                  }
                ]
              },
              "comment": "Send to device if device is connected",
              "condition_settings": {
                "cmp_type": "=",
                "datatype": "text",
                "template": "program: connected_device_name('main')",
                "value": "Kobo Aura HD"
              }
            },
            {
              "action_name": "Calibre Actions",
              "action_settings": {
                "disable_busy_cursor": false,
                "selection": [
                  {
                    "display": "Add to list: Send to Device",
                    "path": [
                      "Reading List",
                      "Add to list",
                      "Add to list: Send to Device"
                    ],
                    "paths_text": "Add to list|Add to list: Send to Device"
                  }
                ]
              },
              "comment": "Add to \"Send to Device\" list if device is not connected",
              "condition_settings": {
                "cmp_type": "=",
                "datatype": "text",
                "template": "program: connected_device_name('main')",
                "value": ""
              }
            },
            {
              "action_name": "Single Field Edit",
              "action_settings": {
                "col_name": "#onkobo",
                "template": "program:\n\tif and(\tcheck_yes_no('#onkobo', '', '', 1),) then \t'False' \n\telse 'True'\n\tfi",
                "value_type": "template"
              },
              "comment": "Set #onkobo column"
            }
          ],
          "refresh_gui": true
        },
        "image": "sync.png",
        "menuText": "Send to Device",
        "subMenu": ""
      },
However i noticed a slight glitch with it. When I eject my Kobo, sometimes the conditional doesn't update (the template value in the evaluator confirms this) and it tries to do the wrong actions (and predictably fail) the next time I run the chain. When this happens my two greyed-out chains are also available.

Any idea why?
Attached Files
File Type: zip Send to Device Chain.zip (3.7 KB, 524 views)

Last edited by ownedbycats; 03-13-2021 at 06:59 PM.
ownedbycats is online now   Reply With Quote