From 230cb0df5206acf6f30a38c7e1df160582db1006 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Wed, 31 May 2023 02:29:22 -0400 Subject: [PATCH] feat: add open/close animations to widgets --- eww/actions/actions.yuck | 12 +++++++++--- eww/closer/closer.yuck | 2 +- eww/date/date.yuck | 11 ++++++++--- eww/powermenu/powermenu.yuck | 11 ++++++++--- eww/scripts/close-opened.sh | 17 +++++++++++++++++ eww/scripts/close.sh | 8 ++++++++ eww/scripts/open.sh | 6 ++++++ sway/config | 4 ++-- sway/scripts/esc.sh | 1 + waybar/scripts/date-toggle.sh | 6 +++--- waybar/scripts/quick-toggle.sh | 6 +++--- 11 files changed, 66 insertions(+), 18 deletions(-) create mode 100755 eww/scripts/close-opened.sh create mode 100755 eww/scripts/close.sh create mode 100755 eww/scripts/open.sh diff --git a/eww/actions/actions.yuck b/eww/actions/actions.yuck index 3a46add3..90ee3426 100644 --- a/eww/actions/actions.yuck +++ b/eww/actions/actions.yuck @@ -166,7 +166,7 @@ :space-evenly true :spacing 10 (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" :halign "end" "" @@ -188,7 +188,9 @@ ) ) -(defwindow actions +(defvar actions-visible false) + +(defwindow actions-reveal :monitor "0" :geometry (geometry :x "10px" :y "4px" @@ -196,4 +198,8 @@ :height "10px" ; automatically generated by eww. :anchor "top right") -(actions)) + (revealer + :transition "crossfade" + :reveal actions-visible + :duration "550ms" + (actions))) diff --git a/eww/closer/closer.yuck b/eww/closer/closer.yuck index 7b577946..ac0b9fbd 100644 --- a/eww/closer/closer.yuck +++ b/eww/closer/closer.yuck @@ -1,5 +1,5 @@ (defwidget closer [] - (eventbox :onclick "eww close-all")) + (eventbox :onclick "$HOME/.config/eww/scripts/close-opened.sh && eww close closer")) (defwindow closer :monitor 0 diff --git a/eww/date/date.yuck b/eww/date/date.yuck index 8facf57f..208873ad 100644 --- a/eww/date/date.yuck +++ b/eww/date/date.yuck @@ -46,12 +46,17 @@ ) ) -(defwindow date +(defvar date-visible false) + +(defwindow date-reveal :monitor 0 :geometry (geometry :x "70px" :y "4px" :width "0px" ; automatically generated :height "0px" ; automatically generated :anchor "top right") - :wm-ignore true -(date)) + (revealer + :transition "crossfade" + :reveal date-visible + :duration "550ms" +(date))) diff --git a/eww/powermenu/powermenu.yuck b/eww/powermenu/powermenu.yuck index 057a50f7..b01a0d58 100644 --- a/eww/powermenu/powermenu.yuck +++ b/eww/powermenu/powermenu.yuck @@ -35,12 +35,17 @@ :wm-ignore true (powermenu-clickhandler)) -(defwindow powermenu +(defvar powermenu-visible false) + +(defwindow powermenu-reveal :monitor 0 :geometry (geometry :x "0px" :y "0px" :width "500px" :height "150px" :anchor "center") - :wm-ignore true -(powermenu)) + (revealer + :transition "crossfade" + :reveal powermenu-visible + :duration "550ms" +(powermenu))) diff --git a/eww/scripts/close-opened.sh b/eww/scripts/close-opened.sh new file mode 100755 index 00000000..82481858 --- /dev/null +++ b/eww/scripts/close-opened.sh @@ -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 diff --git a/eww/scripts/close.sh b/eww/scripts/close.sh new file mode 100755 index 00000000..52754bb0 --- /dev/null +++ b/eww/scripts/close.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +WINDOW="$1" +( +eww update $WINDOW-visible=false +sleep .55 +eww close $WINDOW-reveal +) & diff --git a/eww/scripts/open.sh b/eww/scripts/open.sh new file mode 100755 index 00000000..ab3bb3a8 --- /dev/null +++ b/eww/scripts/open.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +WINDOW="$1" + +eww open $WINDOW-reveal +eww update $WINDOW-visible=true diff --git a/sway/config b/sway/config index ba1c0d34..14af4914 100755 --- a/sway/config +++ b/sway/config @@ -144,7 +144,7 @@ dim_inactive_colors.urgent #900000FF bindswitch --reload --locked lid:on exec swaylock # Kill all eww widgets - bindsym Escape exec $scripts/esc.sh + #bindsym Escape exec $scripts/esc.sh # Kill focused window bindsym $mod+c kill @@ -164,7 +164,7 @@ dim_inactive_colors.urgent #900000FF # 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 "eww open powermenu && eww open closer" + bindsym $mod+Shift+e exec "$HOME/.config/eww/scripts/open.sh powermenu && eww open closer" # # Moving around: # diff --git a/sway/scripts/esc.sh b/sway/scripts/esc.sh index 58f26f07..e8ee671a 100755 --- a/sway/scripts/esc.sh +++ b/sway/scripts/esc.sh @@ -2,3 +2,4 @@ if [[ $(eww state) ]]; then eww close-all fi +input-emulator kbd key esc diff --git a/waybar/scripts/date-toggle.sh b/waybar/scripts/date-toggle.sh index 34a3f39b..0e02bf7f 100755 --- a/waybar/scripts/date-toggle.sh +++ b/waybar/scripts/date-toggle.sh @@ -1,8 +1,8 @@ #!/bin/bash if [[ $(eww state | grep calendar_month) ]]; then - eww close date && eww close closer + $HOME/.config/eww/scripts/close.sh date && eww close closer else - eww close-all - eww open date && eww open closer + $HOME/.config/eww/scripts/close-opened.sh + $HOME/.config/eww/scripts/open.sh date && eww open closer fi diff --git a/waybar/scripts/quick-toggle.sh b/waybar/scripts/quick-toggle.sh index 82dd7d16..ae294e43 100755 --- a/waybar/scripts/quick-toggle.sh +++ b/waybar/scripts/quick-toggle.sh @@ -1,8 +1,8 @@ #!/bin/bash if [[ $(eww state | grep br_icon) ]]; then - eww close actions && eww close closer + $HOME/.config/eww/scripts/close.sh actions && eww close closer else - eww close-all - eww open actions && eww open closer + $HOME/.config/eww/scripts/close-opened.sh + $HOME/.config/eww/scripts/open.sh actions && eww open closer fi