From b48035354874b6a7ba7eb2ebf4d97d288d509a42 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sat, 15 Jul 2023 00:46:04 -0400 Subject: [PATCH] feat: migrate osk-toggle to eww widget --- configs/eww/traybuttons/traybuttons.scss | 13 ++++++-- configs/eww/traybuttons/traybuttons.yuck | 35 +++++++++++++++++++-- configs/hypr/main.conf | 6 ++++ configs/hypr/scripts/osk-toggle.sh | 39 +++++++++++++++++++----- nixos/home/packages.nix | 3 ++ 5 files changed, 84 insertions(+), 12 deletions(-) diff --git a/configs/eww/traybuttons/traybuttons.scss b/configs/eww/traybuttons/traybuttons.scss index a79868e4..26d18e6f 100644 --- a/configs/eww/traybuttons/traybuttons.scss +++ b/configs/eww/traybuttons/traybuttons.scss @@ -1,6 +1,13 @@ +.osk-toggle { + font-size: 30px; + min-height: 26px; + min-width: 50px; + padding: 0px 0px 0px 5px; +} + .notif-panel { min-width: 50px; - min-height: 16px; + min-height: 26px; font-size: 20px; padding: 2px 25px 2px 35px; } @@ -15,7 +22,7 @@ transition: border-color 0.5s ease-in-out; color: #CBA6F7; border-radius: 80px; - border: 3px solid $contrastbg; + border: 2px solid #1b1b2b; } .toggle-off:hover { @@ -28,7 +35,7 @@ transition: border-color 0.5s ease-in-out; color: #CBA6F7; border-radius: 80px; - border: 3px solid #CBA6F7; + border: 2px solid $contrastbg; } .toggle-on:hover { diff --git a/configs/eww/traybuttons/traybuttons.yuck b/configs/eww/traybuttons/traybuttons.yuck index cb77fc1e..487ad627 100644 --- a/configs/eww/traybuttons/traybuttons.yuck +++ b/configs/eww/traybuttons/traybuttons.yuck @@ -1,3 +1,32 @@ +(defvar osk-toggle-state false) + +(defwidget osk-toggle [] + (eventbox :class {osk-toggle-state ? "toggle-on" : "toggle-off"} + :onclick "$HYPR_PATH/osk-toggle.sh toggle &" + (box :class "osk-toggle" + :space-evenly true + :spacing 6 + :orientation "h" + (label :text " 󰌌 ") + ) + ) +) + +(defwindow osk-toggle + :monitor 0 + :stacking "overlay" + :exclusive "ignore" + :geometry (geometry :x "10px" + :y "9px" + :width "0px" + :height "0px" + :anchor "top left" + ) + (osk-toggle) +) + + + (defvar toggle-state false) (defwidget tablet-toggle [] @@ -17,7 +46,7 @@ :monitor 0 :stacking "overlay" :exclusive "ignore" - :geometry (geometry :x "66px" + :geometry (geometry :x "72px" :y "9px" :width "0px" :height "0px" @@ -26,6 +55,8 @@ (tablet-toggle) ) + + (defvar notif-panel-state false) (defwidget notif-panel [] @@ -46,7 +77,7 @@ :stacking "overlay" :exclusive "ignore" :geometry (geometry :x "50px" - :y "10px" + :y "11px" :width "0px" :height "0px" :anchor "top right" diff --git a/configs/hypr/main.conf b/configs/hypr/main.conf index 785b39d7..04cb55e1 100644 --- a/configs/hypr/main.conf +++ b/configs/hypr/main.conf @@ -26,6 +26,9 @@ exec-once = bash -c "sleep 7; GalaxyBudsClient /StartMinimized" exec-once = eww daemon exec-once = eww open tablet-toggle exec-once = eww open notif-panel +exec-once = eww open osk-toggle +# TODO: put this in eww configs? +exec-once = $HYPR_PATH/osk-toggle.sh getState # sometimes waybar starts after and stops me from pressing eww buttons exec-once = bash -c "sleep 0.5; eww reload" @@ -158,6 +161,8 @@ windowrule = float,^(com.nextcloud.desktopclient.nextcloud)$ windowrule = move cursor 0 25,^(com.nextcloud.desktopclient.nextcloud)$ windowrule = size 400 581,^(com.nextcloud.desktopclient.nextcloud)$ +windowrule = tile,^(photoshop.exe)$ + # See https://wiki.hyprland.org/Configuring/Keywords/ for more $mainMod = SUPER @@ -217,6 +222,7 @@ bindm = $mainMod, mouse:273, resizewindow # Take a screenshot bind =, Print, exec, bash -c 'grim -g "$(slurp)" - | swappy -f -' +bind = $mainMod SHIFT, C, exec, wl-color-picker # Volume control binde =, XF86AudioRaiseVolume, exec, swayosd --output-volume raise diff --git a/configs/hypr/scripts/osk-toggle.sh b/configs/hypr/scripts/osk-toggle.sh index e59b03cb..ba71a168 100755 --- a/configs/hypr/scripts/osk-toggle.sh +++ b/configs/hypr/scripts/osk-toggle.sh @@ -1,10 +1,35 @@ #!/usr/bin/env bash -if [[ $(busctl get-property --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 Visible) == "b true" ]] -then - echo "Running" - busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b false -else - echo "Stopped" - busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true +state () { + if [[ $(busctl get-property --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 Visible) == "b true" ]]; then + echo "Running" + eww update osk-toggle-state=true + else + echo "Stopped" + eww update osk-toggle-state=false + fi +} + +toggle () { + if [[ $(busctl get-property --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 Visible) == "b true" ]]; then + echo "Running" + eww update osk-toggle-state=false + busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b false + else + echo "Stopped" + eww update osk-toggle-state=true + busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true + fi +} + +if [[ $1 == "getState" ]]; then + while true; do + sleep 0.2 + state + done fi + +if [[ $1 == "toggle" ]];then + toggle +fi + diff --git a/nixos/home/packages.nix b/nixos/home/packages.nix index 81005e18..eb5ca8ef 100644 --- a/nixos/home/packages.nix +++ b/nixos/home/packages.nix @@ -26,6 +26,7 @@ (with python311Packages; [ python pyclip + gdown ]) ++ (with plasma5Packages; [ @@ -74,6 +75,8 @@ dracula-theme dracula-icon-theme steam-run + wineWowPackages.stable + cabextract qt5.qtwayland qt6.qtwayland bottles-unwrapped