Rockbox Technical Forums

Support and General Use => Theming and Appearance Customization => Topic started by: iPodVT on March 10, 2023, 10:13:31 PM

Title: Is it possible to import text into a .sbs file?
Post by: iPodVT on March 10, 2023, 10:13:31 PM
I have several iPods (don't ask...), and each has a unique name.  I would like to add a feature to my personal Rockbox theme that would display the iPod's unique name somewhere on the Main Menu screen.  But I don't want each iPod to have to have a unique customized .sbs file with the iPod's name hard-coded in it.  So I'm wondering if it's possible to import a piece of text into the .sbs file - maybe via some kind of "include file" type of mechanism - so that I can then just have a small unique text file on each iPod that contains only the iPod's name.  Is this possible, or does anyone have a suggestion for a different/better way to accomplish this?

Thanks.
Title: Re: Is it possible to import text into a .sbs file?
Post by: Frankenpod on March 10, 2023, 11:56:56 PM
Don't know about a text file, but as a theme can load bitmaps, I suppose you could just hard-code the name as a bit map image (with the same name for the bitmap file on all of them) and have the SBS load that.
Title: Re: Is it possible to import text into a .sbs file?
Post by: iPodVT on March 11, 2023, 12:01:21 AM
Thanks very much for your reply and suggestion.

I actually considered that solution, but creating all of those bitmap files would be much more labor intensive than an equal number of text files.
Title: Re: Is it possible to import text into a .sbs file?
Post by: Frankenpod on March 11, 2023, 10:53:35 AM
How many iPods have you got!  (I have about 30 at this point, and that's how I'd do it if I wanted to do that...wouldn't be that hard to make a text file then take a screenshot of it and save and crop the bitmap, surely?  Don't think it would help for me as I tend to constantly switch themes anyway, though what I've occasionally thought would be handy is to have a different loading/RB splash screen for each of them...but the splash screen bitmap is hard-coded into RB, with good reason I guess)

I don't know then, maybe someone else will know of a way to display text.
Title: Re: Is it possible to import text into a .sbs file?
Post by: rockbox_dev123 on March 11, 2023, 07:35:37 PM
Edit the English translation file to contain the iPod's name as a string, and then use:
Code: [Select]
%Sx(iPodName)To display the "translation".

 8)
Title: Re: Is it possible to import text into a .sbs file?
Post by: iPodVT on March 11, 2023, 08:42:07 PM
Thanks for your reply and suggestion.

Following up with that, I looked at the contents of the english-us.lng file.  I have no idea what its content format is nor what (or where) to edit into its content to implement your suggestion, and I'm not finding any related documentation.  I'm not putting it on you to instruct me, but the nuts and bolts of implementing your suggestion is a total mystery to me.  Is there some reasonably comprehensive documention somewhere that I'm not finding?

As well, wouldn't I have to reedit the .lng file each time it gets updated (as was the case with english-us.lng as recently as March 3)?
Title: Re: Is it possible to import text into a .sbs file?
Post by: dconrad on March 11, 2023, 08:51:03 PM
Edit the English translation file to contain the iPod's name as a string, and then use:
Code: [Select]
%Sx(iPodName)To display the "translation".

 8)

I'm sure this works, but I just wanted to pop in to mention I have a suspicion that changing the lang file could potentially cause an instability. For sure go for it, but if you run into any weird crashes this is the first thing to look at. I think the safest approach is to ensure that it's at the end of the file. Just wanted to mention that.
Title: Re: Is it possible to import text into a .sbs file?
Post by: iPodVT on March 11, 2023, 08:57:47 PM
Thanks.

Could I trouble you to please tell me what to add to the end of the file if my iPod's name is "my iPod"?

Also, I viewed the .lng file in a text editor.  Is it my imagination or does it contain some invisible non printing characters?
Title: Re: Is it possible to import text into a .sbs file?
Post by: Dook on March 16, 2023, 07:25:21 AM
Can't call it a sane solution, but here's how I'd do it. I'd use the %St tag to get the output of a setting, then choose a setting I don't use that can have multiple values. Here, I use Line Selector Colours>Secondary Colour. Then in the theme make a viewport that will house the iPod's name, then use the following code to decide what name to use.
Code: [Select]
%?if(%St(line selector end color), =,ffffff)<iPod Name One|>
%?if(%St(line selector end color), =,f7ffff)<iPod Name Two|>
%?if(%St(line selector end color), =,efffff)<iPod Name Three|>
%?if(%St(line selector end color), =,e7ffff)<iPod Name Four|>
It's essentially hijacking this setting to allow us to make our own custom settings parameters for the theme. You could go to any iPod, and use the Rockbox settings to pick whatever name you wanted
Title: Re: Is it possible to import text into a .sbs file?
Post by: iPodVT on March 16, 2023, 10:04:48 AM
Thanks very much for providing this solution.  I love the way it repurposes the setting in a way that is so different from its original intention.  But it's not quite the solution I am hoping for.  I think I need to file a new feature request for either or both of the following:

1 - The ability to specify one or more strings in a .cfg file that could be accessed as settings from a theme file.  In the .cfg file it could have the setting name and setting value form of UserString N: TheActualString.  These UserString settings would not need to be set or editable from within Rockbox, only from an external text editor.  They could reside in any .cfg file that could be included in config.cfg with something like UserStrings: /.rockbox/UserStrings.cfg.  Then the theme file could access them with %St(UserString N).

2 - The ability for a theme file to retrieve the contents of a text file, limited in length to Rockbox's string length limit.  Maybe it would look something like %tf(/.rockbox/MyDeviceName.txt).

Does this seem reasonable/worthwhile?