View Single Post
Old 09-20-2020, 06:47 PM   #20
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 7,034
Karma: 4604637
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
Quote:
Originally Posted by chaley View Post
You can do the same thing in a custom template function. Example:
...
Does this answer your question?
Yes, thank you.

It's not polished, obviously, but this does what I wanted:

template function:
Code:
def evaluate(self, formatter, kwargs, mi, locals, *fnargs):
	from calibre.gui2.ui import get_gui
    dm = get_gui().device_manager
	info = dm.get_current_device_information()
	v = ''
	if dm.is_device_present and info is not None:
		print(info)
		v = info['info'][4]['main']['device_name']
	return v
custom column template:
Code:
{:device_info()}
See attached screen caps for all the GUI settings.

ADDED:
Quote:
Originally Posted by chaley View Post
I could add a function that returns the connected device name, but it wouldn't be guaranteed to be the empty string for a time after a device disconnects.
chaley was right about that. I've updated the function above to also notice when the device is not present.
Attached Thumbnails
Click image for larger version

Name:	custom column.PNG
Views:	79
Size:	36.5 KB
ID:	182048   Click image for larger version

Name:	template function.PNG
Views:	81
Size:	217.9 KB
ID:	182049  

Last edited by JimmXinu; 09-20-2020 at 07:00 PM.
JimmXinu is offline   Reply With Quote