feat: add open/close animations to widgets

This commit is contained in:
matt1432 2023-05-31 02:29:22 -04:00
parent 8eabd0d05a
commit 230cb0df52
11 changed files with 66 additions and 18 deletions

View file

@ -166,7 +166,7 @@
:space-evenly true :space-evenly true
:spacing 10 :spacing 10
(button :class "do-logout" (button :class "do-logout"
:onclick "eww close closer && eww open powermenu && eww open closer" :onclick "eww close closer && $HOME/.config/eww/scripts/open.sh powermenu && eww open closer"
:tooltip "Logout" :tooltip "Logout"
:halign "end" :halign "end"
"" ""
@ -188,7 +188,9 @@
) )
) )
(defwindow actions (defvar actions-visible false)
(defwindow actions-reveal
:monitor "0" :monitor "0"
:geometry (geometry :x "10px" :geometry (geometry :x "10px"
:y "4px" :y "4px"
@ -196,4 +198,8 @@
:height "10px" ; automatically generated by eww. :height "10px" ; automatically generated by eww.
:anchor "top right") :anchor "top right")
(actions)) (revealer
:transition "crossfade"
:reveal actions-visible
:duration "550ms"
(actions)))

View file

@ -1,5 +1,5 @@
(defwidget closer [] (defwidget closer []
(eventbox :onclick "eww close-all")) (eventbox :onclick "$HOME/.config/eww/scripts/close-opened.sh && eww close closer"))
(defwindow closer (defwindow closer
:monitor 0 :monitor 0

View file

@ -46,12 +46,17 @@
) )
) )
(defwindow date (defvar date-visible false)
(defwindow date-reveal
:monitor 0 :monitor 0
:geometry (geometry :x "70px" :geometry (geometry :x "70px"
:y "4px" :y "4px"
:width "0px" ; automatically generated :width "0px" ; automatically generated
:height "0px" ; automatically generated :height "0px" ; automatically generated
:anchor "top right") :anchor "top right")
:wm-ignore true (revealer
(date)) :transition "crossfade"
:reveal date-visible
:duration "550ms"
(date)))

View file

@ -35,12 +35,17 @@
:wm-ignore true :wm-ignore true
(powermenu-clickhandler)) (powermenu-clickhandler))
(defwindow powermenu (defvar powermenu-visible false)
(defwindow powermenu-reveal
:monitor 0 :monitor 0
:geometry (geometry :x "0px" :geometry (geometry :x "0px"
:y "0px" :y "0px"
:width "500px" :width "500px"
:height "150px" :height "150px"
:anchor "center") :anchor "center")
:wm-ignore true (revealer
(powermenu)) :transition "crossfade"
:reveal powermenu-visible
:duration "550ms"
(powermenu)))

17
eww/scripts/close-opened.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/bash
# Store the output of the command in an array, keeping only lines with '*'
readarray -t array <<< "$(eww windows | grep '^\*')"
# Remove the '*' from each element
for ((i=0; i<${#array[@]}; i++))
do
array[i]=${array[i]#'*'}
array[i]=${array[i]%-reveal}
done
# Print the elements of the array
for element in "${array[@]}"
do
$HOME/.config/eww/scripts/close.sh "$element"
done

8
eww/scripts/close.sh Executable file
View file

@ -0,0 +1,8 @@
#!/bin/bash
WINDOW="$1"
(
eww update $WINDOW-visible=false
sleep .55
eww close $WINDOW-reveal
) &

6
eww/scripts/open.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
WINDOW="$1"
eww open $WINDOW-reveal
eww update $WINDOW-visible=true

View file

@ -144,7 +144,7 @@ dim_inactive_colors.urgent #900000FF
bindswitch --reload --locked lid:on exec swaylock bindswitch --reload --locked lid:on exec swaylock
# Kill all eww widgets # Kill all eww widgets
bindsym Escape exec $scripts/esc.sh #bindsym Escape exec $scripts/esc.sh
# Kill focused window # Kill focused window
bindsym $mod+c kill bindsym $mod+c kill
@ -164,7 +164,7 @@ dim_inactive_colors.urgent #900000FF
# Exit sway (logs you out of your Wayland session) # Exit sway (logs you out of your Wayland session)
#bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -B 'Yes, exit sway' 'swaymsg exit' #bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -B 'Yes, exit sway' 'swaymsg exit'
bindsym $mod+Shift+e exec "eww open powermenu && eww open closer" bindsym $mod+Shift+e exec "$HOME/.config/eww/scripts/open.sh powermenu && eww open closer"
# #
# Moving around: # Moving around:
# #

View file

@ -2,3 +2,4 @@
if [[ $(eww state) ]]; then if [[ $(eww state) ]]; then
eww close-all eww close-all
fi fi
input-emulator kbd key esc

View file

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
if [[ $(eww state | grep calendar_month) ]]; then if [[ $(eww state | grep calendar_month) ]]; then
eww close date && eww close closer $HOME/.config/eww/scripts/close.sh date && eww close closer
else else
eww close-all $HOME/.config/eww/scripts/close-opened.sh
eww open date && eww open closer $HOME/.config/eww/scripts/open.sh date && eww open closer
fi fi

View file

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
if [[ $(eww state | grep br_icon) ]]; then if [[ $(eww state | grep br_icon) ]]; then
eww close actions && eww close closer $HOME/.config/eww/scripts/close.sh actions && eww close closer
else else
eww close-all $HOME/.config/eww/scripts/close-opened.sh
eww open actions && eww open closer $HOME/.config/eww/scripts/open.sh actions && eww open closer
fi fi