WillPower3309 / swayfx

SwayFX: Sway, but with eye candy!
MIT License
1.29k stars 48 forks source link

differentiate (un)focused windows + smart_shadow #139

Open litoj opened 1 year ago

litoj commented 1 year ago

Just as we have different colors for border, it would be nice if the colors settings could be expanded to shadows too, possibly like:

set $... #color
client.focused          $border $bg $text $indicator $child_border $shadow
client.focused_inactive $border $bg $text $indicator $child_border $shadow
client.unfocused        $border $bg $text $indicator $child_border $shadow

Maybe a toggle for the shadow/saturation altogether with focused windows, something like:

#       focused inactive unfocused
shadows on/off  on/off   on/off
saturation 0-2  0-2      0-2

And lastly an option to disable shadows, when there is only one window (if no gaps or smart_gaps is set, then the shadow has nowhere to display, aside of over the statusbar (which is probably unwanted by the user)). This could be implicit (toggle with smart_gaps) or explicit: smart_shadows on/off

These are just ideas, it is currently already possible using swayipc, I made a simple script for this functionality:

#!/usr/bin/bash

declare -i last=0
declare -a line
while read -ra line; do
    if [[ ${line[2]} == '"focus",' ]]; then # line[1]="change":
        swaymsg "[con_id=$last]" shadows off
        swaymsg "[con_id=$last"' app_id="^(?!firefox|mpv).*$"]' saturation set 0.8
        last=${line[6]%,} # line[5]="id":
        # line[32]="width": line[34]="height":
        (( ${line[33]%,} >= 2550 && ${line[35]%,} >= 1560 )) ||
            swaymsg "[con_id=$last]" shadows on 1
        # [[ ${line[12]} == '1.0,' ]] line[11]="percent":

        swaymsg "[con_id=$last]" saturation set 1
    fi
done < <(swaymsg -t subscribe -m "['window']")

Edit:

BTW the forementioned script doesn't work perfectly, since 100% windows are all windows that have changed tiling mode for the next window. I fixed that with detecting their size. Still, both have the problem that when closing a second-to-last window, the last will be focused but resized after the event, meaning it reports size < screen size so it has enabled shadows even though it shouldn't.

When trying to detect floating mode change (resizing happend) it works with getting into floating mode, but the size and percent is completely messed up when going back to tiling mode. I don't know why, but it reports window size 2526x1542 when it tiles as the only window on tiled workspace, but full screen res (without statusbar) 2560x1576 when other tiled windows are present.

WillPower3309 commented 1 year ago

smart shadow is what I was trying to get at with #116 , and will definitely be implemented (in fact, I think that could even default to being on). The color settings are a really good idea, but I don't want to clash with sway upstream by changing them. Perhaps we can implement the toggle like idea you had!

litoj commented 1 year ago

To expand on the idea of how to specify the colours, would it make sense to use the shadows option and instead of on just directly specify the colour or use off to disable altogether?

shadows off/#RRGGBB off/on/#RRGGBB off/on/#RRGGBB

on could imply to be the same color as for the first/active window column, just an idea