Bug 689903 - Feature Request: Make Newt's system-wide palette configurable at run time
Summary: Feature Request: Make Newt's system-wide palette configurable at run time
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: newt
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Lichvar
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-03-22 18:34 UTC by Dustin Kirkland
Modified: 2011-06-27 12:59 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-06-27 12:59:43 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Make newt's system-wide palette configurable at run time (2.63 KB, patch)
2011-03-22 18:34 UTC, Dustin Kirkland
no flags Details | Diff

Description Dustin Kirkland 2011-03-22 18:34:36 UTC
Created attachment 486874 [details]
Make newt's system-wide palette configurable at run time

Hello,

We are carrying a small patch in Ubuntu that makes Newt's default color palette configurable, by optionally placing a configuration file at /etc/newt/palette.  

If no file exists at that path, then newt's operation proceeds as normal.

If, on the other hand, a file does exist at that admin-owned location, a list of color values is read from that file and overloaded into the newtColors struct and set with newtSetColors().

I've tested it pretty well and seems to work quite nicely here.

For testing purposes, you can use these two sets of contents for your /etc/newt/palette values.  The contents of the file is expected to contain newt's color keywords, all on a single line, comma-separate, no whitespace, and a total of 44 values.  For example:

original:
white,blue,black,lightgray,black,lightgray,white,black,red,lightgray,lightgray,red,red,lightgray,lightgray,blue,lightgray,red,lightgray,blue,blue,lightgray,black,lightgray,lightgray,blue,black,lightgray,lightgray,red,white,blue,lightgray,blue,blue,red,blue,lightgray,black,lightgray,lightgray,red,black,brown


ubuntu:
white,magenta,black,lightgray,black,lightgray,white,black,red,lightgray,lightgray,red,red,lightgray,lightgray,magenta,lightgray,red,lightgray,magenta,magenta,lightgray,black,lightgray,lightgray,magenta,black,lightgray,lightgray,red,white,magenta,lightgray,magenta,magenta,red,magenta,lightgray,black,lightgray,lightgray,red,black,brown

Please consider committing this patch against your upstream newt branch.  Thanks.

Signed-off-by:
Dustin Kirkland <kirkland>

Comment 1 Miroslav Lichvar 2011-05-30 12:13:09 UTC
Instead of requiring all 44 colors on one line I think it would be better to specify color of each item separately. For items which are not specified in the config the default would be used.

Something like:

root=white,black
border=,yellow

Few more things:
- the default path should be configurable in the configure script, /etc/newt/colors by default?
- perhaps it would be useful to be able to override the colors also via getenv("NEWT_COLORS"), e.g. NEWT_COLORS=root=white,black:border=,yellow

I can look into it if you want.

Thanks.

Comment 2 Dustin Kirkland 2011-05-31 18:01:39 UTC
Awesome!  Thanks for the response.  I was worried this bug/patch might have gotten dumped into the bit bucket.

Regarding the format of the file, I just went for the simplest approach, from the perspective of reading the values in the C code.  I didn't expect this to be something that people changed often, frequently, or on their own.  I expected more that a distro or a packager would do this, and probably only ever do it once or twice, so I didn't really think about it in terms of a user-friendly interface, but instead, just as a "functional" one.

Regarding the default path, yes, of course, that could (and should?) very well be configurable.  /etc/newt/colors seemed to me like a simple, straightforward, obvious default.

Regarding a "NEWT_COLORS" environment variable, that's an excellent idea, such that the color scheme could even be modified on an application-by-application, or process-by-process basis (rather than system wide).

I'm concerned a little bit by the complexity of the code necessary to process the descriptive configuration file and/or environment variable.  At this point, I would prefer for you to point me to a git branch with your implementation of these, and I'll gladly build/test that, and port over Ubuntu's use of this functionality to your new implementation.

Cheers,
Dustin

Comment 3 Miroslav Lichvar 2011-06-02 11:43:02 UTC
Ok, I've pushed a patch implementing that to git (git://git.fedorahosted.org/git/newt), please let me know how it works for you.

Comment 4 Dustin Kirkland 2011-06-06 14:47:05 UTC
Awesome, thanks!  I'll get this tested...

Comment 5 Miroslav Lichvar 2011-06-27 12:59:43 UTC
It is in newt-0.52.13.


Note You need to log in before you can comment on or make changes to this bug.