fix: fix animation for heart and osk buttons

This commit is contained in:
matt1432 2023-07-27 21:46:32 -04:00
parent 49f2c8dbca
commit 5862efb395
5 changed files with 75 additions and 10 deletions

View file

@ -6,9 +6,11 @@ if [[ ! -f "$FILE" ]]; then
fi fi
if grep -q 󰣐 "$FILE"; then if grep -q 󰣐 "$FILE"; then
eww close heart
eww update heart-ts=false eww update heart-ts=false
echo  > "$FILE" echo  > "$FILE"
else else
eww open heart
eww update heart-ts=true eww update heart-ts=true
echo 󰣐 >> "$FILE" echo 󰣐 >> "$FILE"
fi fi

View file

@ -35,7 +35,7 @@
.toggle-off { .toggle-off {
background-color: $bg; background-color: $bg;
transition: border-color 0.5s ease-in-out; //transition: border-color 0.5s ease-in-out;
color: #CBA6F7; color: #CBA6F7;
border-radius: 80px; border-radius: 80px;
border: 2px solid #1b1b2b; border: 2px solid #1b1b2b;
@ -48,7 +48,7 @@
.toggle-on { .toggle-on {
background-color: $bg; background-color: $bg;
transition: border-color 0.5s ease-in-out; //transition: border-color 0.5s ease-in-out;
color: #CBA6F7; color: #CBA6F7;
border-radius: 80px; border-radius: 80px;
border: 2px solid $contrastbg; border: 2px solid $contrastbg;

View file

@ -2,8 +2,8 @@
;; On-Screen Keyboard Toggle ;; On-Screen Keyboard Toggle
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar osk-ts false) (defvar osk-ts false)
(defwidget osk-toggle [] (defwidget osk-toggle-on []
(eventbox :class {osk-ts ? "toggle-on" : "toggle-off"} (eventbox :class "toggle-on"
:onclick "$HYPR_PATH/osk-toggle.sh toggle &" :onclick "$HYPR_PATH/osk-toggle.sh toggle &"
:cursor "pointer" :cursor "pointer"
@ -13,6 +13,34 @@
) )
) )
) )
(defwidget osk-toggle-off []
(eventbox :class "toggle-off"
:onclick "$HYPR_PATH/osk-toggle.sh toggle &"
:cursor "pointer"
(box :class "osk-toggle"
:orientation "h"
(label :text " 󰌌 ")
)
)
)
(defwindow osk
:monitor 0
:stacking "overlay"
:exclusive "ignore"
:geometry (geometry :x "5px"
:y "10px"
:width "0px"
:height "0px"
:anchor "top left"
)
(revealer
:transition "crossfade"
:reveal osk-ts
:duration "550ms"
(osk-toggle-on)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Tablet Mode Toggle ;; Tablet Mode Toggle
@ -34,8 +62,9 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Heart Toggle ;; Heart Toggle
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defwidget heart-toggle [] (defvar heart-ts "default")
(eventbox :class {heart_icon == "󰣐" ? "toggle-on" : "toggle-off"} (defwidget heart-toggle-on []
(eventbox :class "toggle-on"
:onclick "$EWW_PATH/heart.sh" :onclick "$EWW_PATH/heart.sh"
:cursor "pointer" :cursor "pointer"
@ -45,6 +74,34 @@
) )
) )
) )
(defwidget heart-toggle-off []
(eventbox :class "toggle-off"
:onclick "$EWW_PATH/heart.sh"
:cursor "pointer"
(box :class "heart-toggle"
:orientation "h"
(label :text " ${heart_icon} ")
)
)
)
(defwindow heart
:monitor 0
:stacking "overlay"
:exclusive "ignore"
:geometry (geometry :x "140px"
:y "10px"
:width "0px"
:height "0px"
:anchor "top left"
)
(revealer
:transition "crossfade"
:reveal heart-ts
:duration "550ms"
(heart-toggle-on)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Left Bar ;; Left Bar
@ -54,9 +111,9 @@
:space-evenly true :space-evenly true
:spacing 12 :spacing 12
:orientation "h" :orientation "h"
(osk-toggle) (osk-toggle-off)
(tablet-toggle) (tablet-toggle)
(heart-toggle) (heart-toggle-off)
) )
) )
(defwindow left-bar (defwindow left-bar

View file

@ -30,6 +30,8 @@ exec-once = $HYPR_PATH/osk-toggle.sh getState
# sometimes waybar starts after and stops me from pressing eww buttons # sometimes waybar starts after and stops me from pressing eww buttons
exec-once = bash -c "sleep 0.5; eww reload" exec-once = bash -c "sleep 0.5; eww reload"
exec-once = bash -c "grep -q 󰣐 $HOME/.config/.heart && eww open heart && sleep 0.5 && eww update showh=true"
exec-once = gnome-keyring-daemon --start --components=secrets exec-once = gnome-keyring-daemon --start --components=secrets
exec-once = squeekboard exec-once = squeekboard

View file

@ -3,9 +3,11 @@
state () { state () {
if [[ $(busctl get-property --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 Visible) == "b true" ]]; then if [[ $(busctl get-property --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 Visible) == "b true" ]]; then
echo "Running" echo "Running"
eww open osk
eww update osk-ts=true eww update osk-ts=true
else else
echo "Stopped" echo "Stopped"
eww close osk
eww update osk-ts=false eww update osk-ts=false
fi fi
} }
@ -14,10 +16,12 @@ toggle () {
if [[ $(busctl get-property --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 Visible) == "b true" ]]; then if [[ $(busctl get-property --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 Visible) == "b true" ]]; then
echo "Running" echo "Running"
busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b false busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b false
eww close osk
eww update osk-ts=false eww update osk-ts=false
else else
echo "Stopped" echo "Stopped"
busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true
eww open osk
eww update osk-ts=true eww update osk-ts=true
fi fi
} }