eruption
eruption copied to clipboard
Pywal integration
I think it would be really nice to be able to sync your system colors with physical hardware. Pywal generates a color scheme based of an image. So far I have written a simple script to get the colors from the pywal cache directory i.e. $XDG_CACHE_HOME/wal/
. The colors are in hexdecimal in the json file I am using.
The json file can look something like this:
{
"wallpaper": "/home/linux/Pictures/Wallpapers/1163434.jpg",
"alpha": "100",
"special": {
"background": "#0d0c0d",
"foreground": "#a5c2f0",
"cursor": "#a5c2f0"
},
"colors": {
"color0": "#0d0c0d",
"color1": "#5958A1",
"color2": "#5E5CB8",
"color3": "#A049D8",
"color4": "#18ABD8",
"color5": "#1C9AE2",
"color6": "#13B0F7",
"color7": "#a5c2f0",
"color8": "#7387a8",
"color9": "#5958A1",
"color10": "#5E5CB8",
"color11": "#A049D8",
"color12": "#18ABD8",
"color13": "#1C9AE2",
"color14": "#13B0F7",
"color15": "#a5c2f0"
}
}
I doubt we will need anything above the colors
object.
Cool, this definitely looks worth integrating! I did not know Pywal
before, just had a quick look at it. It would be really nice if Eruption had some kind of color palette mechanism that gets synced with the system wide color scheme.
It would be great if we can leverage the already existing color gradient support for this. Please have a look at lava-lamp.lua
, that makes use of 'named gradient' objects. The library support code is located at: eruption/src/scripting/script.rs:445
, function gradient_from_name(...)
. This could be easily adapted/extended to load user-defined gradients.
@array-in-a-matrix I have implemented a working prototype that is able to set the colors of a new stock-gradient called "system", from a JSON file generated via the wal
command.
Please use it like this:
eruptionctl switch profile lava-lamp-syscolors.profile
wal -i ~/images/background.jpg && eruptionctl color-schemes import pywal
Please have a look at the topic/pywal-integration
branch.
@X3n0m0rph59 I have compiled and tried these changes, the profile works but the colors displayed aren't matching up with the image's color palette. My mouse just cycles between generic rainbow colors.
@array-in-a-matrix Ah sorry, I did not adapt the batique.lua
script. I have just pushed the changes required to make it work. Now it should render colors only from the system
named gradient, even on non-keyboard devices.
So after running:
eruptionctl color-schemes import pywal
It should no longer use rainbow colors but only use the imported color scheme instead!
You can play around with custom gradient stops like this
eruptionctl color-schemes add system 0 0 0 0 255 0 0 255 255 255 255 255
Format is RGBA, stop 0 is skipped.
Black (unused): 0 0 0 0 Red (fully opaque): 255 0 0 255 White (fully opaque): 255 255 255 255
So the above command registers the system
gradient, using the two colors red to white.
Persistence of named color-schemes after a restart of Eruption is still missing!
I just tested it and it works! I unfortunately don't have other devices to test it with but its great so far!
@array-in-a-matrix Great! Glad, that it is working now!
I just pushed the latest set of changes, including a persistence layer, so that the named color schemes are actually saved and restored when the eruption
daemon is restarted.
The import command will now skip the color0
, since it is mostly black/white, and distorts the resulting gradient somewhat. This was previously implemented inside eruption
proper.
Import will now import colors 1..15, and skip color0:
eruptionctl color-schemes import pywal
So the "0 0 0 0" is no longer needed:
eruptionctl color-schemes add system 0 0 0 0 255 0 0 255 255 255 255 255
This is the valid syntax now:
eruptionctl color-schemes add system 255 0 0 255 255 255 255 255
To achieve a red to white gradient
color0
could be other colors having an option to use it would be nice.
Does the command take the first 15 colors given to it? because eruption
doesn't complain when given an absurd amount of colors
eruptionctl color-schemes add system 231 180 251 44 162 147 214 ...
@array-in-a-matrix
color0 could be other colors having an option to use it would be nice.
Yes, that sounds reasonable! I will implement a parameter --optimize
that, in the current implementation, will just filter out color0
, the default will be to use all 16 colors then.
All color quadruples that are specified on the command line will get integrated into a single gradient. That means we generate n / 4 different color-stops, where n is the count of integers specified on the command line.