Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for feedback: magick_background widget (background FX) #49

Closed
Lokaltog opened this issue Mar 12, 2014 · 4 comments
Closed

Request for feedback: magick_background widget (background FX) #49

Lokaltog opened this issue Mar 12, 2014 · 4 comments
Labels

Comments

@Lokaltog
Copy link
Owner

I've implemented an alternative way to create background effects, as CSS filters proved to be a bit wonky (the blur effect is a major hassle to implement properly, and the webview frequently crashed due to out of memory errors when testing it with various images and settings).

This feature requires graphicsmagick (switched from imagemagick due to poor performance) to work, which isn't ideal, but I don't know another better way of doing this efficiently. The bg image is generated on startup and don't use any extra resources when wkline is running.

What this widget does is crop an image of your choice, then apply a configurable amount of brightness/saturation/blur to the image, then sets it as the statusline background image.

Here's a screenshot of a test I just did with blur and lower brightness applied:

2014-03-12-184506_1920x1080_scrot

To enable this widget, make sure you have graphicsmagick installed and recompile wkline. You should now be able to enable the magick_background widget in your config.json:

        {
            "module": "magick_background",
            "config": {
                "image": "file:///path/to/your/bg-image.jpg",
                "blur_radius": 0,
                "brightness": 100,
                "saturation": 100
            }
        },

These are the options you're most likely to want to use currently, the rest are defined in the widget header file. The brightness and saturation settings are set as percentages in the range 0..100 (100 is default brightness/saturation).

You may need to tweak the values depending on your background image and preference. I found that a blur radius of 3 or 4, brightness of 70-80 and saturation of 0 looks pretty good with medium to dark images.

Anyways, it would be great if you guys could give me some feedback on this and let me know what you think, or if you have suggestions to other effects that can be added (any feature of graphicsmagick is possible).

@Lokaltog
Copy link
Owner Author

Here's an example of a frosted glass effect made possible by the latest commits:

2014-03-14-142303_1920x1080_scrot

Settings:

            "config": {
                "image": "...",
                "blur_radius": 6,
                "brightness": 130,
                "saturation": 100,
                "css_gradient_overlay": "top, rgba(255,255,255,.3), rgba(255,255,255,.2) 15%, rgba(255,255,255,.3) 95%, rgba(255,255,255,.2)"
            }

@alspore
Copy link
Contributor

alspore commented Mar 14, 2014

I don't think that the configuration should be stored in config.json because it will add a couple steps to installing themes from others.

Would it be possible to store the config information as part of the theme?

@Lokaltog
Copy link
Owner Author

The theme ultimately decides what to do with the information it receives as you can see here. You could create a theme that completely ignores the CSS and implements its own overlay, or ignores the magick_background widget completely. I did try to implement a default gradient in the theme, but it's impossible to find a combination of blur/brightness/saturation and a gradient overlay that works well for any kind of background image.

I also don't think we should tie the background effect to the themes in any way, as it requires graphicsmagick, and I'm 100% certain that a lot of users don't want the extra dependency or don't think the effect looks good.

While you make a good point that it will be more difficult to installing themes from others I think that the best solution would be that theme creators create themes that will work with any background image, and not depend on this widget. The default theme uses RGBA colors instead of grayscale colors in order to accomplish this. If other themes do the same you could ideally either use the default theme background or any combination of magick_background effects in any theme - i.e. if you prefer the frosted glass effect you can keep that look in any theme you choose to install.

I'm not sure if this is the best or most user-friendly way of doing it though, so please let me know if you have any ideas to how this can be implemented in a better way.

Lokaltog added a commit that referenced this issue Mar 21, 2014
First of all: holy shit what a lesson in frustration this has
been. Thanks for nothing XCB devs, the practically nonexistent docs for
working with X pixmaps made this a lot harder than it should have been.

This feature enables reading the root pixmap and applying effects
directly onto the resulting bitmap so you won't have to supply an image
config option to the magick background widget if you set the background
on the X root window (feh and other apps do this). Some WMs don't, in
those cases you'll still have to specify your background image for this
widget to work.

The feature works by reading the root window background pixmap, then
converting it to a valid BMP file in-memory. GraphicsMagick reads this
BMP file and applies effects to the image.

Possible stuff that might become issues in the future, and areas that
have room for improvement:

* system endianness *may* be an issue as we're working directly on RGB
  integer values stored in memory, so the R and B channels may become
  swapped on big-endian systems
* if X replies with a pixmap that isn't 24-bit the whole thing will
  probably crash, some error handling should be added for some edge-case
  scenarios

Ref #49
@Lokaltog
Copy link
Owner Author

Lokaltog commented May 4, 2014

Closing due to lack of feedback.

@Lokaltog Lokaltog closed this as completed May 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants