You are not logged in.

#1 2025-11-01 15:23:03

greenjeans
Member
Registered: 2025-01-18
Posts: 264
Website

Modding the yad color selector function

So I know hhh uses the yad color picker as i've seen it in one of his screenshots, awesome little tool if
you do any theme work. So I decided to give it a .desktop and some mild mods to the command to
make it even more handy.

yad --color in terminal gets you the basic version. But there are other options
available with this command, see the yad man page for (most of) them. If you want
the color swatches you can use --gtk-palette but I don't find them to be
too useful. The --palette command can be used to pull up a palette file and
display the colors and their code in a drop down menu, and if you want the gui to
start every time with that dropdown already expanded, then add --expand-palette
to it as well. The --palette command by default uses /etc/X11/rgb.txt for a
palette file unless a different one is specified by adding a path to the command :
--palette=/path/to/file.txt, so it's possible to make a custom palette file, I made
one for my theme, but you have to follow the format in rgb.txt closely.

And there are some of the normal operators you can use too, to add a window title or
an icon, borders, etc. Here's the command i'm using:

yad --color --title='Color Selection' --window-icon=style --borders=15 --palette --expand-palette

If you want to add the ability for copying a selected color code into your clipboard,
you can install xsel and then pipe it to the clippy:

yad --color --title='Color Selection' --window-icon=style --borders=15 --palette --expand-palette | xsel -ib

Simple .desktop, drop it in ~/.local/share/applications to get a menu entry:

[Desktop Entry]
Name=Color Selection
Comment=Choose colors from the palette or the screen
Exec=sh -c "yad --color --title='Color Selection' --window-icon=style --borders=15 --palette --expand-palette | xsel -ib"
Icon=style
Terminal=false
Type=Application
Categories=Graphics; 

And that gets you this:
okavt0.png

Now the above shot shows the palette from rgb.txt, but that can be changed as I mentioned above, the mod using a custom file works great when you're working on a specific theme. Now I have to admit, when I decided to try that part I got a little lazy, my theme is pretty large and I didn't relish the idea of going through everything and manually writing out a long file, so I decided to try an LLM as this seemed like the kind of simple yet long and tedious task that an LLM would be useful for. And it worked fine, fed the machine my gtk.css files and it spit me out a working file. So now when i'm on my build partition the palette that shows up in the color picker is all my theme colors with code for the color, a swatch, and also what it's being used for in the theme (i.e. fg_color, bg_color etc.).

Offline

Board footer

Powered by FluxBB