set background color of "box" using variable
-
- Posts: 11
- Joined: Sun Jan 27, 2019 5:31 pm
set background color of "box" using variable
I want to set the "box" background color to a variable that can be changed using a shortcut. how would I do that? Could I do it through a binding? I'm trying to use it to create themes for my layout.
Re: set background color of "box" using variable
load up script editor and paste this code
LL.setVariableString("mycolor", "c:" + LL.pickColor("Set Background Color", 0xffffffff, true));
Now go into the bindings tab for each item you want to use this color and add a new binding set the property to box and value to $mycolor. The box property syntax is explained here.
https://www.lightninglauncher.com/wiki/ ... ndings_box
LL.setVariableString("mycolor", "c:" + LL.pickColor("Set Background Color", 0xffffffff, true));
Now go into the bindings tab for each item you want to use this color and add a new binding set the property to box and value to $mycolor. The box property syntax is explained here.
https://www.lightninglauncher.com/wiki/ ... ndings_box
-
- Posts: 11
- Joined: Sun Jan 27, 2019 5:31 pm
Re: set background color of "box" using variable
Thanks. The script works.
Re: set background color of "box" using variable
Cool, i made a quick update to the script so it can also pull color from the wallpaper for now it only gets the dark muted color because I found this to work the best for my setup and tbh the community's kinda dead so didn't think many people would be using it anyways, but it's easy to modify to get other colors even if you don't know Javascript, cheers to the dev for the sample code 
If you wanna edit the code for other colors and don't know JS
the following colors are supported.
Light Vibrant
Vibrant
Dark Vibrant
Light Muted
Muted
Dark Muted
link here for more info and examples httpss://developer.android.com/training/material/palette-colors
all you need to do is change the line that says palette.getDarkMutedColor() to something like palette.getGetLightMutedColor() or palette.getVibrantColor()
LL.bindClass("android.app.WallpaperManager");
var choice = parseInt(prompt("1. Extract color from wallpaper\n2. Use a custom hex color", ""));
switch(choice)
{
case 1:
wallpaperColor();
break;
case 2:
customColor();
break;
}
function wallpaperColor()
{
try {
// extract the wallpaper bitmap
var wp = WallpaperManager.getInstance(LL.getContext()).getDrawable();
var bitmap = wp.getBitmap();
Palette.generateAsync(bitmap, {
onGenerated: function(palette) {
LL.setVariableString("mycolor", "c:" + palette.getDarkMutedColor([0]));
}
}).execute(null);
} catch(e) {
e.printStackTrace();
// no bitmap or OOM
}
}
function customColor()
{
LL.setVariableString("mycolor", "c:" + LL.pickColor("Set Box Background Color", 0xffff5722, true));
}

If you wanna edit the code for other colors and don't know JS
the following colors are supported.
Light Vibrant
Vibrant
Dark Vibrant
Light Muted
Muted
Dark Muted
link here for more info and examples httpss://developer.android.com/training/material/palette-colors
all you need to do is change the line that says palette.getDarkMutedColor() to something like palette.getGetLightMutedColor() or palette.getVibrantColor()
LL.bindClass("android.app.WallpaperManager");
var choice = parseInt(prompt("1. Extract color from wallpaper\n2. Use a custom hex color", ""));
switch(choice)
{
case 1:
wallpaperColor();
break;
case 2:
customColor();
break;
}
function wallpaperColor()
{
try {
// extract the wallpaper bitmap
var wp = WallpaperManager.getInstance(LL.getContext()).getDrawable();
var bitmap = wp.getBitmap();
Palette.generateAsync(bitmap, {
onGenerated: function(palette) {
LL.setVariableString("mycolor", "c:" + palette.getDarkMutedColor([0]));
}
}).execute(null);
} catch(e) {
e.printStackTrace();
// no bitmap or OOM
}
}
function customColor()
{
LL.setVariableString("mycolor", "c:" + LL.pickColor("Set Box Background Color", 0xffff5722, true));
}
-
- Posts: 11
- Joined: Sun Jan 27, 2019 5:31 pm
Re: set background color of "box" using variable
Once again it works. I'd love to understand javascript, but for some reason I just never could get the hang of it. I learned how to do basic stuff like window.alert("hello world"); but that's about it. One more question. Does the script support transparency?
Re: set background color of "box" using variable
I got into it when the dev added scripting to the launcher so my skills are pretty basic, it doesn't support transparency because I couldn't figure out how I'd go about doing it from what I read here https://gist.github.com/lopspower/03fb1cc0ac9f32ef38f4 I'd just need to swap the first 2 characters of the hex color code with 2 from the alpha but when i tested that it was giving me wrong results. I think il rewrite this script anyways and try a different way, I'd like to build a nice UI that shows previews of the wallpaper colors.
-
- Posts: 11
- Joined: Sun Jan 27, 2019 5:31 pm
Re: set background color of "box" using variable
You've still been very helpful. You know more than I do. I wouldn't have a script at all on my own, so thank you.
Re: set background color of "box" using variable
here's a look at the new version hopefully I can get the transparency working.
- Attachments
-
- Screenshot_20200404-033207_Lightning Launcher.jpg (471.97 KiB) Viewed 3880 times
-
- Posts: 11
- Joined: Sun Jan 27, 2019 5:31 pm
Re: set background color of "box" using variable
Still can't get transparency to work but I'm not giving up yet and I'm gonna upload the script before I lose it. I made a couple changes to its appearance so more of the desktops visible and easier to use, simply edit line 11 with your variables name.
Uploaded here if you wanna try it out viewtopic.php?f=14&t=1004
Uploaded here if you wanna try it out viewtopic.php?f=14&t=1004
- Attachments
-
- Screenshot_20200404-191017_Lightning Launcher.jpg (644.67 KiB) Viewed 3869 times