yshui / picom

A lightweight compositor for X11 with animation support
https://picom.app/
Other
4.18k stars 589 forks source link

[feature_request] Dynamic configuration #365

Open kinglouie opened 4 years ago

kinglouie commented 4 years ago

I'm currently relatively new to arch and started with bspwm as my desktop and picom as my compositor. What I really like about bspwm is that you can configure it with a simple bash script and the bspc command.

I was wondering if it would be possible to implement a similar architecture into picom so we are able to change the config with scripts while picom is running.

Here is an example why I would like to have this: My default bspwm setup has large gaps around/between windows and I have a rounded corner patch for bspwm for good looks. When I have a large number of windows on my display I use a shortcut to disable said gaps around the windows so the screen space is better used. When this is happening I disable the rounded corners with the bspc command because it looks better if the windows touch each other. I also would like to disable window transparency/shadows in picom but currently I don't think this is possible.

When the new rounded corners feature lands in picom I would also want to configure this on the fly. Ideally these configurations could be set on a display level and also on a window level.

I'm really curious what you think about this.

yshui commented 4 years ago

There is the dbus interface for that. And there is convenience scripts for that too. You can use picom-trans to change the transparency of windows.

absolutelynothelix commented 4 years ago

there are two ways to do what you want:

  1. picom is quite lightweight (a lightweight compositor for x11 (c)) so it's not a problem to quickly restart it
  2. recently picom obtained a new mechanism that watches configuration file for changes, so if you change picom's configuration it will notice the changes and reload itself

you can either have two configuration files (the first one for your normal look and unixporn, the second one for real workflow), or modify a single one with sed, for example. so just add to your shortcuts the following things:

if you on the latest released picom:

if you on the picom built from latest next

tbh, i don't see the point of implementing such thing into a compositor.

kinglouie commented 4 years ago

@yshui I'm digging this up again because I was never able to script a satisfying solution. Please correct me if I'm mistaken, but as far as I can see the dbus exposed functions are limited to overriding settings on a specific window ID? For my needs I would like to override shadows/transparency/roundedcorners on a display level so if I open new windows on that display the settings apply to them as well.

My current setup includes a small laptop display and a large external display. Ideally I would like to have rounded corners/shadows/transparency disabled on the laptop display because it has no window gaps configured in the tiling window manager, but have all the eyecandy features of picom enabled on the larger display. With a self scripted solution things like moving windows from one display to the other get really hard to implement.

If there isn't such possibilities in picom I would be really stoked if you would consider something like this in the future.

bps86 commented 1 year ago

There is the dbus interface for that. And there is convenience scripts for that too. You can use picom-trans to change the transparency of windows.

I'm glad you have this feature, it's a good step to the right direction. I also wanted to request one more feature to change trans of focused/active window & inactive window. It will be useful to use it on i3 to toggle transparency. Example: you can toggle the active window from 1 to 0.7 and vice versa.

absolutelynothelix commented 1 year ago

@kinglouie, better late than never, so

Please correct me if I'm mistaken, but as far as I can see the dbus exposed functions are limited to overriding settings on a specific window ID?

as far as i know, the answer is no.

Ideally I would like to have rounded corners/shadows/transparency disabled on the laptop display because it has no window gaps configured in the tiling window manager, but have all the eyecandy features of picom enabled on the larger display.

what if the one half of a window is on the first monitor, and the second one is on the second monitor? :) if a window is entirely on a particular monitor it could be possible because we already have a mechanism to determine on which monitor a window is on.

@bps86, if i understand you correctly, look at the inactive-opacity and the active-opacity options. there is also the inactive-opacity-override option.

bps86 commented 1 year ago

@absolutelynothelix I understood that options, but wish could do it real time. Maybe it was my fault because when changing the config file, it does changed realtime. I just haven't find out how to edit the picom config file in realtime without opening text editor.

GordonZed commented 7 months ago

I'm currently relatively new to arch and started with bspwm as my desktop and picom as my compositor. What I really like about bspwm is that you can configure it with a simple bash script and the bspc command.

I was wondering if it would be possible to implement a similar architecture into picom so we are able to change the config with scripts while picom is running.

Here is an example why I would like to have this: My default bspwm setup has large gaps around/between windows and I have a rounded corner patch for bspwm for good looks. When I have a large number of windows on my display I use a shortcut to disable said gaps around the windows so the screen space is better used. When this is happening I disable the rounded corners with the bspc command because it looks better if the windows touch each other. I also would like to disable window transparency/shadows in picom but currently I don't think this is possible.

When the new rounded corners feature lands in picom I would also want to configure this on the fly. Ideally these configurations could be set on a display level and also on a window level.

I'm really curious what you think about this.

I didn't realize there was a time when picom didn't monitor the config file for changes, but anyway, now that it does, this can all be done, and weirdly, we have very similar interests. My i3 config does just this. I have hotkeys for changing the size of gaps, including setting them to 0, and it changes the corner-radius in picom's conf in response as well. I know it's a different twm, but maybe the sed part will help. If not you, then maybe the next person to get here from their search engine of choice.

Here's the relevant part of my config:

# Variable gaps selection mode
bindsym $mod+b mode "mode_gaps"

mode "mode_gaps" {
    bindsym 1 mode "default", gaps inner all set  0; exec --no-startup-id "sed -i 's/corner-radius = [0-9]*;/corner-radius = 00;/' /home/$USER/.config/picom.conf";
    bindsym 2 mode "default", gaps inner all set  5; exec --no-startup-id "sed -i 's/corner-radius = [0-9]*;/corner-radius = 10;/' /home/$USER/.config/picom.conf";
    bindsym 3 mode "default", gaps inner all set 10; exec --no-startup-id "sed -i 's/corner-radius = [0-9]*;/corner-radius = 10;/' /home/$USER/.config/picom.conf";
    bindsym 4 mode "default", gaps inner all set 15; exec --no-startup-id "sed -i 's/corner-radius = [0-9]*;/corner-radius = 15;/' /home/$USER/.config/picom.conf";
    bindsym 5 mode "default", gaps inner all set 20; exec --no-startup-id "sed -i 's/corner-radius = [0-9]*;/corner-radius = 15;/' /home/$USER/.config/picom.conf";
    bindsym 6 mode "default", gaps inner all set 25; exec --no-startup-id "sed -i 's/corner-radius = [0-9]*;/corner-radius = 15;/' /home/$USER/.config/picom.conf";
    bindsym 7 mode "default", gaps inner all set 30; exec --no-startup-id "sed -i 's/corner-radius = [0-9]*;/corner-radius = 15;/' /home/$USER/.config/picom.conf";
    bindsym 8 mode "default", gaps inner all set 35; exec --no-startup-id "sed -i 's/corner-radius = [0-9]*;/corner-radius = 20;/' /home/$USER/.config/picom.conf";
    bindsym 9 mode "default", gaps inner all set 40; exec --no-startup-id "sed -i 's/corner-radius = [0-9]*;/corner-radius = 20;/' /home/$USER/.config/picom.conf";
    bindsym 0 mode "default", gaps inner all set 45; exec --no-startup-id "sed -i 's/corner-radius = [0-9]*;/corner-radius = 25;/' /home/$USER/.config/picom.conf";

    bindsym Return mode "default"
    bindsym Escape mode "default"
}

I'm not a bspwm user, so you'll have to meet me in the middle there and adapt this to your needs, but from what little I think I know, you'd probably take just the raw sed command and put it in a shell script, and do whatever you do to tell bspwm to trigger that script lol. So here's just an example of the command itself.

sed -i 's/corner-radius = [0-9]*;/corner-radius = 10;/

This is a good opportunity to learn some essentials of the Unix tool belt (regex and sed), if they're not already a part of yours, that is.

First sed. The -i option tells sed to edit the file in place, instead of writing to stdout. The s/ part is the substitute command, followed by a slash, then followed by the thing we want to substitute: corner-radius = [0-9]*;, another slash, then what we want to substitute it with: corner-radius = 10;, and finally feed it your picom config file.

If you know regex already, then you already know what's going on, but if not, a quick explanation. Regex (regular expressions) are sequences of characters used for specifying the pattern we're looking to match in the text we're searching. This runs deep, but our example is simple...

[0-9] matches any digit, and * tells it to match any number of digits (including none, iirc), although notice that my i3 config sets the corner-radius using leading zeros, so the * shouldn't be necessary, but one never can be too careful, lol.

So basically, we're changing corner-radius = any numerical value at all to corner-radius = 10;. This can very easily be applied to shadows and transparency. No regex required.

sed -i 's/shadow = true;/shadow = false;/

sed -i 's/inactive-opacity = 0.9;/inactive-opacity = 1.0;/

Hope this helps someone. Sorry for getting all tutorially on you. Was just working on my blog, so I guess I'm just in that kinda mood today lol.

More info on sed: https://www.digitalocean.com/community/tutorials/the-basics-of-using-the-sed-stream-editor-to-manipulate-text-in-linux

The Great Regex Demystifier of Science!: https://regex-generator.olafneumann.org

kinglouie commented 7 months ago

Thanks for your reply, Its been a long time since I left arch, so currently not using picom. At the time I was tinkering with it I tried using the auto config reload feature for my purposes but it had a few issues.

GordonZed commented 6 months ago

Oh yeah most definitely. Not much you can do about it on a per window/workspace basis with picom as currently written. Anyway, I figured it was a long shot that any of the original posters in this thread still needed/wanted to solve this, but I got here from a search so I'm sure someone else will eventually.