From 9526ee34f12214831b762082906823b6861f8705 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Mon, 21 Oct 2024 00:37:19 -0400 Subject: [PATCH] waybar: add virtual keyboard toggle based on hyprland tablet script (#140) * waybar: add toggle-virtual-keyboard button based on hyprland tablet mode script * waybar: add css stylings --- .../services/waybar/default.nix | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/homeManagerModules/services/waybar/default.nix b/homeManagerModules/services/waybar/default.nix index f98062e6..13346f4c 100644 --- a/homeManagerModules/services/waybar/default.nix +++ b/homeManagerModules/services/waybar/default.nix @@ -105,6 +105,25 @@ in { tooltip-format = "Close the focused window."; }; + "custom/virtual-keyboard" = let + toggle-virtual-keyboard = pkgs.writeShellScript "toggle-virtual-keyboard" '' + STATE=`${lib.getExe pkgs.dconf} read /org/gnome/desktop/a11y/applications/screen-keyboard-enabled` + + if [ $STATE -z ] || [ $STATE == "false" ]; then + if ! [ `pgrep -f ${lib.getExe' pkgs.squeekboard "squeekboard"}` ]; then + ${lib.getExe' pkgs.squeekboard "squeekboard"} & + fi + ${lib.getExe pkgs.dconf} write /org/gnome/desktop/a11y/applications/screen-keyboard-enabled true + elif [ $STATE == "true" ]; then + ${lib.getExe pkgs.dconf} write /org/gnome/desktop/a11y/applications/screen-keyboard-enabled false + fi + ''; + in { + on-click = ''${toggle-virtual-keyboard}''; + format = "󰌌"; + tooltip-format = "Toggle the virtual keyboard."; + }; + clock = { format = "{:%I:%M%p}"; interval = 60; @@ -235,7 +254,9 @@ in { modules = ["custom/menu"] ++ lib.optional (cfg.desktop.hyprland.tabletMode.enable) - "custom/app-close"; + "custom/app-close" + ++ lib.optional (cfg.desktop.hyprland.tabletMode.enable) + "custom/virtual-keyboard"; orientation = "horizontal"; }; @@ -276,6 +297,7 @@ in { #custom-app-close, #custom-logout, #custom-menu, + #custom-virtual-keyboard, #idle_inhibitor, #mode, #network,