You are not logged in.

#1 2019-11-12 21:07:36

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 1,964
Website

Convert Xresources hex colors to Lxterminal rgb colors, a script

Naive script that will attempt to 'convert' Xresources style of color definition to the one expected in Lxterminal.conf.

Usage:

urxlx ~/.Xresources 
# or
urxlx monokai.txt | xclip

For example, this:

! special
*.foreground:   #f8f8f2
*.background:   #272822
*.cursorColor:  #f8f8f2
! black
*.color0:       #272822
*.color8:       #75715e
! red
*.color1:       #f92672
*.color9:       #f92672
...

shall become:

fgcolor=rgb(248,248,242)
bgcolor=rgb(39,40,34)
palette_color_0=rgb(39,40,34)
palette_color_8=rgb(117,113,94)
palette_color_1=rgb(249,38,114)
palette_color_9=rgb(249,38,114)
...

then paste the results to strategic location in ~/.config/lxterminal/lxterminal.conf and win.

Last edited by brontosaurusrex (2019-11-12 21:25:28)

Online

#2 2019-11-12 21:40:56

cog
Cattle Baron
From: New Mexico, USA
Registered: 2015-10-27
Posts: 390
Website

Re: Convert Xresources hex colors to Lxterminal rgb colors, a script

That’s gonna be a handy tool.


Morning, Bunny.  Well, I can see you're in good health.  -George Washington McLintock! (John Wayne, AKA the Duke)

Offline

#3 2019-11-13 00:58:31

DeepDayze
Member
From: In Linux Land
Registered: 2017-05-28
Posts: 778

Re: Convert Xresources hex colors to Lxterminal rgb colors, a script

Very good little utility script to have maybe as part of bunsen-utilities maybe?


Real Men Use Linux

Offline

#4 2019-11-13 13:09:57

clusterF
Member
Registered: 2019-05-07
Posts: 447

Re: Convert Xresources hex colors to Lxterminal rgb colors, a script

Something terminal.sexy could implement. I dont believe they have an lxterminal format there.

https://terminal.sexy/


"Common sense is like deodorant, those who need it the most never use it."

git: clusterF

Online

#5 2019-11-14 02:10:37

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,168
Website

Re: Convert Xresources hex colors to Lxterminal rgb colors, a script

DeepDayze wrote:

Very good little utility script to have maybe as part of bunsen-utilities maybe?

@Bronto, if you feel like adding a -h --help option? I can paste in the GPL copyright bit OK.


John

...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Offline

#6 2019-11-14 09:17:51

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 1,964
Website

Re: Convert Xresources hex colors to Lxterminal rgb colors, a script

@johnraff; How is now?

Online

#7 2019-11-14 09:40:14

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,168
Website

Re: Convert Xresources hex colors to Lxterminal rgb colors, a script

^Cool. I'll drop it in now.


John

...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Offline

#8 2019-11-14 09:52:53

cog
Cattle Baron
From: New Mexico, USA
Registered: 2015-10-27
Posts: 390
Website

Re: Convert Xresources hex colors to Lxterminal rgb colors, a script

Kickass @Brex

can't wait to try it out


Morning, Bunny.  Well, I can see you're in good health.  -George Washington McLintock! (John Wayne, AKA the Duke)

Offline

#9 2019-11-15 07:37:20

ohnonot
...again
Registered: 2015-09-29
Posts: 4,221
Website

Re: Convert Xresources hex colors to Lxterminal rgb colors, a script

If you always convert from 6-digit hex to r,g,b this is trivial.
But .Xresources can deal with a large variety of formats & syntax; recognizing the proper entries is the first step, recognizing all possible formats is another step, having some quality control... it's very, very tricky.
I know you called it naïve for a reason, but I have to point this out.

edit: I now realise that your intention is not to convert currently valid Xresources, but convert one of those terminal.sexy etc. files.

Last edited by ohnonot (2019-11-15 07:44:00)

Offline

#10 2019-11-15 10:36:52

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 1,964
Website

Re: Convert Xresources hex colors to Lxterminal rgb colors, a script

@ohnonot, I'll take that ^ as a compliment. wink

convert one of those terminal.sexy etc. files.

Right, semi-automatic solution of some sort. edit: Can you post a problematic .Xresources example?

Last edited by brontosaurusrex (2019-11-16 00:49:48)

Online

#11 2019-11-17 17:43:53

ohnonot
...again
Registered: 2015-09-29
Posts: 4,221
Website

Re: Convert Xresources hex colors to Lxterminal rgb colors, a script

brontosaurusrex wrote:

edit: Can you post a problematic .Xresources example?

the problem starts right there: the file could be anywhere, you need to deal with what's actually in the X database (xrdb).
I guess the best way is with appres:

appres URXvt

just an example.
Then there's different colour formats that X recognizes, I think one of them is "*color1: 1/4/9"
I think you can see that it's going to be tricky.

BUT those terminal color websites stick to one or two NOT outdated formats anyhow, so for the intended use case your script is just fine!

Offline

Board footer

Powered by FluxBB