Comments (21)
is this the plan for implementing this? because i think i might try my hand at it soon.
from stylix.
Custom types are the best solution I can come up with. Let's go ahead with that.
from stylix.
This is something I've thought about before - we could have a function to load a scheme from a file, and another to generate one based on a given image and settings.
The polarity
and override
options would become arguments to that generator function, which prevents those being used elsewhere. For example switching apps between light and dark mode based on polarity
, which we should avoid because someone using a premade scheme won't have set the polarity
correctly.
from stylix.
A bit related to #54 . The point is that people want other things than just an image as wallpaper, so we need to support that. Maybe we could have an options stylix.wallpaper
that is pretty free-form, and set stylix.image
from it if it is set. I'll experiment with this idea and open a draft PR.
from stylix.
I agree, there should be a single option which takes one of
- An image
- A list of images
- An animation
Theoretically the palette generator could support all of these directly, as it's just selecting pixels at random and then improving on that selection. That would however be quite resource intensive, especially for video wallpapers, as the entire file needs to be loaded into memory to do the selection.
I think we should stick with the idea of picking a single image/frame to use in the generator for now.
How should we handle backwards compatibility with the creation of a new option? stylix.wallpaper
cannot default to stylix.image
, because the default image will depend on the wallpaper, which creates an infinite loop if neither of the options are set.
from stylix.
The answer is probably to not take stylix.wallpaper
for granted: to place conditions in modules that would use it.
The default of stylix.wallpaper
should be null
. In the modules, simply check that stylix.wallpaper
is not null
. If it is null
, try to use stylix.image
as a fallback. This can probably be made a helper function as well.
from stylix.
so is this the plan were going through with?
from stylix.
It would be simpler if there was only one option, with a function to create a still image from it. If the value is already a still image then this can be passed through the function unmodified.
This way, we can rename stylix.image
to stylix.wallpaper
using mkRenameOption
, which maintains backwards compatibility without introducing new possible values.
The helper function would work as follows:
- If the input is an image, return it unmodified
- If the input is a video, return a derivation which extracts a frame
- If the input is a list, choose one value and call the function again
This requires having some way to detect whether the input is an image or a video. As both paths and fetchurl
preserve the original file name, we should be able to detect based on the file extension, and throw an error if it's unknown. This can also let us reject unusual image formats.
from stylix.
One limitation with this approach is that in the case of the list, we may want more features (for example how long to display each wallpaper, how to handle transitions...). I don't really have any good idea on how to handle it.
from stylix.
Is it possible to use a submodule type within an enum? If so, we could replace the list with a submodule having those extra options.
from stylix.
We can as long as there is only one such submodule (otherwise it gets complicated pretty fast I think), so it would work but if we want to support other kinds of wallpaper in the future it may get complicated, but I'm not sure how probable it is.
from stylix.
On further thought, we could represent all wallpapers as an attrset:
{
type = "image";
file = ./image.png;
}
{
type = "animation";
file = ./video.mp4;
}
{
type = "slideshow";
delay = 5;
files = [ ./image1.png ./image2.png ];
}
It's possible to define custom types with a validator function, which in this case would reject anything without a type
attribute or not matching the specification for that type.
We can then add constructors to simplify and provide defaults:
mkImage ./image.png
mkAnimation ./video.mp4
mkSlideshow {
files = [ ./image1.png ./image2.png ];
}
This also avoids the need to parse file extensions, as the type of wallpaper is known.
What do you think?
Also, should there be a separate type for animated images (GIF, AVIF) vs video (MP4, AVI)? As these might need a different implementation.
from stylix.
it may be best to separate animated images and videos as mpvpaper is much less efficient then its cousins that only support animated images, at least on wayland, I dont know too much about the x11 side of things, i would recommend swww for the implementation of the slideshow and animated image types if we plan to go forward with this solution.
from stylix.
whats everyone's opinion on maybe moving the color scheme to the custom types like the image? then rather then setting the color scheme directly you use a constructor to set the base16 scheme like nord or any other scheme.
from stylix.
I think @danth's idea is great but I'd like to mention it is pretty easy right now to use official themes: see how I do it here.
One problem with using custom types is that it makes the option less self-documenting, so it should be avoid as much as possible. I actually don't know of any module where it's used, but it would be great to find some previous uses to see how they did it.
from stylix.
you guys are probably more knowledgable in this subject then i am so i dont really have much of an opinion on the matter
from stylix.
im personally in favor of moving everything over to the constructor but @danth what do you think?
from stylix.
I'm also in favor of the custom types, but it would be nice if we had a way to generate documentation for them
from stylix.
@danth it looks like the gnome module relies on the polarity option, perhaps it would be a good idea to retain the polarity option but not have it influence the generated colorscheme? because there are other modules that i can see said option being useful for like qutebrowser.
from stylix.
(As mentioned on Matrix) I think we should calculate polarity based on the background colour when it's needed for a module, as this will support handmade schemes too. So if the background colour is darker than a threshold, set the theme to dark, otherwise set the theme to light. Then the polarity option will only be used as a guide for the generated scheme.
from stylix.
Dumping additional slideshow feature suggestions.
- Randomly select an item from collection (
mkSlideshow.files
). - Use a blurred image copy for the borders instead of black borders, if the aspect ration of the item does not match the aspect ratio of the drawing canvas.
- Add additional options for randomly selecting items (feature suggestion
1.
): select only items that match the specifiedstylix.base16Scheme
scheme in order to remain in the same color scheme.
On non-nix-based systems, I currently use the following shell script to implement the first two feature suggestions: https://github.com/trueNAHO/dotfiles/blob/767b4ba1cc84ee2c980956cab72c708a958087f9/home/dot_local/bin/executable_set_wallpaper
from stylix.
Related Issues (20)
- treewide: avoid IFD HOT 12
- How to set stylix.fonts.monospace.package to a nerdfont override HOT 1
- GNOME lock screen looks bad with light theme
- Hyprland config broken with latest commits upstream HOT 2
- Qutebrowser dark mode HOT 2
- Rofi theme customizability HOT 5
- Activating xfconfSettings: Failed to set property.
- Add cursor support for Hyprland HOT 3
- Adaptive Cursor Theme HOT 1
- After recent cursor update get invisible cursor with XWayland apps HOT 4
- pinentry: add support HOT 2
- Support MPV UI plugin HOT 1
- Support MPV
- GTK3 Sidebar looks funny. HOT 8
- shell_remove_dark_mode.patch no longer works HOT 2
- The option `home-manager.users.redacted.wayland.windowManager.hyprland.settings' does not exist. HOT 1
- qt: some icons are not displayed correctly HOT 2
- Add Stylus/custom CSS support HOT 1
- stylix.image should be optional HOT 1
- Long loading times for fish shell in alacritty HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stylix.