View Single Post
Old 07-16-2023, 04:55 PM   #29
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,476
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by arpeggioaccele View Post
I got the action chain working! It took me a while to figure out what went wrong; it was the little checkboxes that enable/disable the event trigger.

Using two chains to hide all layouts then enable the ones I wanted with the condition
template = program: current_library_name()
datatype = text
condition value = Library name
(why is book title and font choice displayed here, super confusing imo)

Then I just called both chains when the event triggered, which is terribly slow but it was my first try lol.
Glad you have it working.

The font and title boxes are shown because it is using the general template tester, which has no idea what you are trying to do. It gives you the value of the template for the current book(s), if it can figure out what the current book is. It also gives you access to the template debugger, which you didn't mention. Your condition template might be simple or it might be a multi-line complex GPM or Python template. Calibre can't know in advance/read your mind.

As regards "terribly slow", the time will depend on the number of books in the library. Mine takes 0.5 seconds to switch libraries to my test library of 100 books, which for me isn't slow. For my test library of 50,000 books it taks 2.4 seconds, of which 2 seconds is calibre opening the library. Switching to a library with 1 book takes 0.1 seconds. Are these times similar to what you are seeing? It is taking longer than simply changing the library then pushing the layout buttons?

To help with the comparison, what I have is:
  • Three action chains, one per library, that hide all panels then show different things depending on the library. These chains don't have a condition.
  • One "Chain caller" action that "calls" the three above chains. Each chain call has a condition checking the library, so only one chain is actually called.
  • The event manager's "Library Changed" and "Calibre initialized" events each call the "Chain caller" action.
chaley is offline   Reply With Quote