Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 29 May 2020, 16:11
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Listing all color names
Post new topic   Reply to topic View previous topic :: View next topic
Page 3 of 3 [43 Posts]   Goto page: Previous 1, 2, 3
Author Message
Argolance


Joined: 06 Jan 2008
Posts: 3793
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Tue 19 May 2020, 06:52    Post subject:  

Bonjour,
Nice!
MochiMoppel wrote:
With rgb.txt being such an unreliable source for color names I wonder if we should continue to rely on it.

Yes, it's reasonable to wonder...

Cordialement.

_________________

Puppy Search
Back to top
View user's profile Send private message Visit poster's website 
some1

Joined: 17 Jan 2013
Posts: 123

PostPosted: Tue 19 May 2020, 08:24    Post subject:  

rgb.txt:
In the old days X relied on/kept the colorVALUE-colorNAME -listing in rgb.txt.
Later/nowadays the listing became hardcoded
in the source - and X no longer need the file.
The rgb.txt present in a distro will likely
just be a copy of the ancient rgb.txt-file.
Hardcoding the listing in the source came
with some extra pairs added to the list.

Try to extract the list from the binary in Tahr32(or another puppy with a not too old Xorg)..
My hunch is that there will be 782 items -like in Bionic -and 30 more pairs than in rgb.txt.
(awk may be an alternative to strings|grep|...)
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 2061
Location: Japan

PostPosted: Wed 20 May 2020, 04:19    Post subject:  

Yes, rgb.txt is less essential than it used to be and AFAIK some distros have ditched it altogether, but as long as Puppy keeps a copy and as long as some applications use it, it should be accurate, shouldn't it? Keeping an outdated copy that was created 20 years ago (acc, to its header) in modern Puppies like bionicpub just makes no sense to me. But apart from the content there is another issue that needs fixing:

Location of rgb.txt

Puppy default
the usual path to the file in Puppies is /usr/share/X11/rgb.txt, a location where no application I know would expect it.

netpbm utilities
The netpbm utilities expect rgb.txt to be in any of these locations:
/usr/lib/X11/rgb.txt
/usr/openwin/lib/rgb.txt
/usr/X11R6/lib/X11/rgb.txt


For reasons I don't know the devs didn't solve this issue by putting a symlink to /usr/share/X11/rgb.txt into one of these locations. Instead they tried to fix it with an entry in /etc/profile:
Code:
#w468 netpbm utilities need to be told where rgb.txt is...
[ -f /usr/share/X11/rgb.txt ] && export RGBDEF=/usr/share/X11/rgb.txt

yad
For yad the default path is
/etc/X11/rgb.txt
With a symlink in this location the command
Code:
yad --color --palette
would create a yad dialog with rgb.txt as its palette.

gcolor2
Like yad gcolor2 shows rgb.txt by default, but searches in additional locations:
/usr/X11R6/lib/X11/rgb.txt
/usr/lib/X11/rgb.txt
/etc/X11/rgb.txt
/usr/openwin/lib/X11/rgb.txt

Unlike yad gcolor2 does not allow user defined alternative paths, hence woof-CE's strange decision to allow the misuse of /root/.rgb.txt for this purpose. A simple symlink in one of the paths known to gcolor2 would enable gcolor2 to function as intended.

Bottomline
A few symlinks would rectify all issues associated with the current location
Back to top
View user's profile Send private message 
rockedge


Joined: 11 Apr 2012
Posts: 1800
Location: Connecticut, United States

PostPosted: Wed 20 May 2020, 14:20    Post subject:  

Hello MochiMoppel!

As usual supplied us with some really good information. I am adjusting my systems to incorporate the new symlinks

Thank you. Stay well.
Back to top
View user's profile Send private message Visit poster's website 
misko_2083


Joined: 08 Nov 2016
Posts: 109

PostPosted: Wed 20 May 2020, 14:40    Post subject:  

Yad list can be used to display color. Either with@fore@ or @back@ column or with this trick with the pango markup:
Code:
printf '<span background="%s">\t\t</span>\n' "$col"  | yad --list --column=color

https://developer.gnome.org/pygtk/stable/class-pangocolor.html
nut the color doesn't have to be taken from rgb.txt file it can be in rgb form.
https://developer.gnome.org/pygtk/stable/class-pangocolor.html
e.g.
Code:
printf '<span background="%s">\t\t</span>\n' "#000"  | yad --list --column=color


In combination with the color dialog in a paned dialog.
But only the eyedropper tool can be used to select the color from a list in the second pane.
Code:
#!/bin/bash

COLORS="$(busybox strings -n3 $(type -p Xorg) | grep -m1 -A751 alice)"

yadkey="$((${RANDOM} * $$))"

yad --color --plug=${yadkey} --tabnum=1 --gtk-palette --expand-palette --palette=/usr/share/X11/rgb.txt &

OIFS=$IFS
IFS=$'\n'

for col in $COLORS
do
   printf '<span background="%s">\t\t</span>\n' "$col"
   echo "$col"
done |  yad --plug=${yadkey} --tabnum=2 --list --column=X11color --column=name --print-column=2  &

IFS=$OIFS

yad --paned --key="${yadkey}" \
    --title="Color" --width=500 --height=700
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 2061
Location: Japan

PostPosted: Thu 21 May 2020, 22:22    Post subject:  

misko_2083 wrote:
Yad list can be used to display color. Either with@fore@ or @back@ column or with this trick with the pango markup

Nice trick. I like the clean look of the yad list. Unfortunately the use of pango can lead to unexpected results. I tried to use --dclick-action
Code:
--dclick-action='bash -c "gxmessage %s"'

With color names containing spaces yad crashes. Unspaced color names work fine. Doesn't seem to be a quotation issue.
Back to top
View user's profile Send private message 
misko_2083


Joined: 08 Nov 2016
Posts: 109

PostPosted: Fri 22 May 2020, 04:40    Post subject:  

MochiMoppel wrote:
misko_2083 wrote:
Yad list can be used to display color. Either with@fore@ or @back@ column or with this trick with the pango markup

Nice trick. I like the clean look of the yad list. Unfortunately the use of pango can lead to unexpected results. I tried to use --dclick-action
Code:
--dclick-action='bash -c "gxmessage %s"'

With color names containing spaces yad crashes. Unspaced color names work fine. Doesn't seem to be a quotation issue.

What happens when you replace regular spaces with one of those from Unicode?
\u2002 or \u2003 https://en.m.wikipedia.org/wiki/Whitespace_character
The idea is to replace the space in the color names with spaces and use them in the list.
If yad doesn't crash on dclick action, the color name can be switched back to the regular whitespace character in the exported function.
echo -e "Red\u2002Moon" | yad ...
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 2061
Location: Japan

PostPosted: Fri 22 May 2020, 05:51    Post subject:  

misko_2083 wrote:
What happens when you replace regular spaces with one of those from Unicode?
A barrage of yad warnings ("perhaps you used an invalid character in an attribute name") and with such invalid color names not surprisingly a failure to display colors. At least yad doesn't crash ...
Back to top
View user's profile Send private message 
step

Joined: 04 May 2012
Posts: 1312

PostPosted: Fri 22 May 2020, 17:50    Post subject:  

Fatdog's yad doesn't crash with dclick action on 'alice blue'. However the shell prints a parse error:
Quote:

blue> ' 'alice blue': -c: line 0: unexpected EOF while looking for matching `''
blue> ' 'alice blue': -c: line 1: syntax error: unexpected end of file

I think going through the shell isn't necessary. With --dclick-action=gxmessage and nothing else it works for 'alice blue' and AliceBlue alike.

_________________
Fatdog64-810|+Packages|Kodi|gtkmenuplus
Back to top
View user's profile Send private message 
misko_2083


Joined: 08 Nov 2016
Posts: 109

PostPosted: Fri 22 May 2020, 19:02    Post subject:  

Definitely a quoting issue. Wink
%s returns the entire row with all the pango markup
<span background='slate gray'> </span> slate gray

What works for me is --dclick-action='bash -c "gxmessage \"%s\""'
also single quotes around background markup
printf "<span background='%s'>\t\t</span>\n" "slate gray"

Code:
function ehoyad () { yad --width=600 --title="$@"; }
export -f ehoyad

printf "<span background='%s'>\t\t</span>\n%s\n" "slate gray" "slate gray" | yad --list --column=color --column=name --dclick-action='bash -c "ehoyad \"%s\""'
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 2061
Location: Japan

PostPosted: Fri 22 May 2020, 22:57    Post subject:  

@misko: Your're right, it is a quoting issue, but not in the --dclick-action argument. Doesn't matter if escaped quotes are added to %s or not. What is crucial is the somewhat odd quoting required for printf. I tested with your script you posted on May 21 and I never suspected your code because it looks right. What causes the problems is
Code:
printf '<span background="%s">\t\t</span>\n' "$col"

When you change it to
Code:
printf "<span background='%s'>\t\t</span>\n" "$col"
or
Code:
printf '%s\n' "<span background='$col'>      </span>"
everything works fine.
Back to top
View user's profile Send private message 
01micko


Joined: 11 Oct 2008
Posts: 8759
Location: qld

PostPosted: Sat 23 May 2020, 18:38    Post subject:  

MochiMoppel wrote:
Yes, rgb.txt is less essential than it used to be and AFAIK some distros have ditched it altogether, but as long as Puppy keeps a copy and as long as some applications use it, it should be accurate, shouldn't it? Keeping an outdated copy that was created 20 years ago (acc, to its header) in modern Puppies like bionicpub just makes no sense to me.


https://lists.x.org/archives/xorg-announce/2014-November/002494.html There is rgb-1.0.6 - latest AFAIK - contains rgb.txt


MochiMoppel wrote:
But apart from the content there is another issue that needs fixing:

Location of rgb.txt

Puppy default
the usual path to the file in Puppies is /usr/share/X11/rgb.txt, a location where no application I know would expect it.

netpbm utilities
The netpbm utilities expect rgb.txt to be in any of these locations:
/usr/lib/X11/rgb.txt
/usr/openwin/lib/rgb.txt
/usr/X11R6/lib/X11/rgb.txt


For reasons I don't know the devs didn't solve this issue by putting a symlink to /usr/share/X11/rgb.txt into one of these locations. Instead they tried to fix it with an entry in /etc/profile:
Code:
#w468 netpbm utilities need to be told where rgb.txt is...
[ -f /usr/share/X11/rgb.txt ] && export RGBDEF=/usr/share/X11/rgb.txt

yad
For yad the default path is
/etc/X11/rgb.txt
With a symlink in this location the command
Code:
yad --color --palette
would create a yad dialog with rgb.txt as its palette.

gcolor2
Like yad gcolor2 shows rgb.txt by default, but searches in additional locations:
/usr/X11R6/lib/X11/rgb.txt
/usr/lib/X11/rgb.txt
/etc/X11/rgb.txt
/usr/openwin/lib/X11/rgb.txt

Unlike yad gcolor2 does not allow user defined alternative paths, hence woof-CE's strange decision to allow the misuse of /root/.rgb.txt for this purpose. A simple symlink in one of the paths known to gcolor2 would enable gcolor2 to function as intended.

Bottomline
A few symlinks would rectify all issues associated with the current location


Symlinks /etc/X11/rgb.txt and /usr/lib/X11/rgb.txt added to woof-ce.

_________________
Puppy Linux Blog - contact me for access
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 2061
Location: Japan

PostPosted: Mon 25 May 2020, 20:49    Post subject:  

01micko wrote:
Symlinks /etc/X11/rgb.txt and /usr/lib/X11/rgb.txt added to woof-ce.

Thank you.
Please don't forget to remove /root/.rgb.txt. It really shouldn't have been added in the first place. If you don't then gcolor2 will list all system colors twice.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 3 of 3 [43 Posts]   Goto page: Previous 1, 2, 3
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0828s ][ Queries: 13 (0.0244s) ][ GZIP on ]