diff --git a/common/overlays/default.nix b/common/overlays/default.nix index 9f37a1c..5ccbd6c 100644 --- a/common/overlays/default.nix +++ b/common/overlays/default.nix @@ -1,6 +1,5 @@ {nixpkgs-wayland, ...} @ inputs: [ (import ./dracula-theme inputs) - (import ./squeekboard) nixpkgs-wayland.overlay ] diff --git a/common/overlays/squeekboard/default.nix b/common/overlays/squeekboard/default.nix deleted file mode 100644 index a310c98..0000000 --- a/common/overlays/squeekboard/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -final: prev: { - squeekboard = prev.squeekboard.overrideAttrs (o: { - patches = - (o.patches or []) - ++ [./remove-panel.patch]; - }); -} diff --git a/common/overlays/squeekboard/remove-panel.patch b/common/overlays/squeekboard/remove-panel.patch deleted file mode 100644 index bd874d8..0000000 --- a/common/overlays/squeekboard/remove-panel.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 10be06ebc72ec8f516003577dabcedb60fe05982 Mon Sep 17 00:00:00 2001 -From: matt1432 -Date: Sat, 18 Nov 2023 20:26:50 -0500 -Subject: [PATCH] remove panel - ---- - src/panel.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/src/panel.c b/src/panel.c -index a9942c8..333727e 100644 ---- a/src/panel.c -+++ b/src/panel.c -@@ -75,13 +75,13 @@ panel_manager_request_widget (struct panel_manager *self, struct wl_output *outp - PHOSH_TYPE_LAYER_SURFACE, - "layer-shell", squeek_wayland->layer_shell, - "wl-output", output, -- "height", height, -+ "height", 1, - "anchor", ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM - | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT - | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT, - "layer", ZWLR_LAYER_SHELL_V1_LAYER_TOP, - "kbd-interactivity", FALSE, -- "exclusive-zone", height, -+ - "namespace", "osk", - NULL - ); -@@ -100,7 +100,7 @@ panel_manager_request_widget (struct panel_manager *self, struct wl_output *outp - gtk_window_set_icon_name (GTK_WINDOW(self->window), "squeekboard"); - gtk_window_set_keep_above (GTK_WINDOW(self->window), TRUE); - } else { -- panel_manager_resize(self, height); -+ panel_manager_resize(self, 1); - } - - if (!self->widget) { --- -2.42.0 - diff --git a/modules/ags/README.md b/modules/ags/README.md index 0825f50..888cf3b 100644 --- a/modules/ags/README.md +++ b/modules/ags/README.md @@ -37,7 +37,5 @@ The main dependencies to try it are as follows: If you're interested in my 2-1 laptop setup, you'll need: - **ydotool** for my custom on-screen keyboard -- my [patched](https://git.nelim.org/matt1432/nixos-configs/src/branch/master/common/overlays/squeekboard/remove-panel.patch) -version of **squeekboard** to get a dbus interface for keyboard -control (I'm looking into implementing this by itself) - **lisgd** to have touch screen gestures # TODO: switch to hyprgrass +when it has better binds diff --git a/modules/ags/config/global-types.d.ts b/modules/ags/config/global-types.d.ts index d64f619..214055b 100644 --- a/modules/ags/config/global-types.d.ts +++ b/modules/ags/config/global-types.d.ts @@ -100,6 +100,15 @@ export type OSD = { } }; +// For ./ts/on-screen-keyboard +export type OskWindow = Window void; + killGestureSigs: () => void; + setSlideUp: () => void; + setSlideDown: () => void; +}>; + // For CursorBox import { CursorBox, CursorBoxProps } from 'ts/misc/cursorbox'; export type CursorBox = CursorBox; diff --git a/modules/ags/config/services/tablet.ts b/modules/ags/config/services/tablet.ts index 12076be..cd526c1 100644 --- a/modules/ags/config/services/tablet.ts +++ b/modules/ags/config/services/tablet.ts @@ -47,9 +47,9 @@ class Tablet extends Service { return this.#oskState; } - constructor() { - super(); - this.#listenOskState(); + set oskState(value: boolean) { + this.#oskState = value; + this.emit('osk-toggled', this.#oskState); } #blockInputs() { @@ -76,9 +76,6 @@ class Tablet extends Service { } setTabletMode() { - execAsync(['gsettings', 'set', 'org.gnome.desktop.a11y.applications', - 'screen-keyboard-enabled', 'true']).catch(print); - execAsync(['brightnessctl', '-d', 'tpacpi::kbd_backlight', 's', '0']) .catch(print); @@ -91,9 +88,6 @@ class Tablet extends Service { } setLaptopMode() { - execAsync(['gsettings', 'set', 'org.gnome.desktop.a11y.applications', - 'screen-keyboard-enabled', 'false']).catch(print); - execAsync(['brightnessctl', '-d', 'tpacpi::kbd_backlight', 's', '2']) .catch(print); @@ -160,43 +154,9 @@ class Tablet extends Service { } } - #listenOskState() { - subprocess( - ['bash', '-c', 'busctl monitor --user sm.puri.OSK0'], - (output) => { - if (output.includes('BOOLEAN')) { - const match = output.match('true|false'); - - if (match) { - this.#oskState = match[0] === 'true'; - this.emit('osk-toggled', this.#oskState); - } - } - }, - ); - } - - static openOsk() { - execAsync(['busctl', 'call', '--user', - 'sm.puri.OSK0', '/sm/puri/OSK0', 'sm.puri.OSK0', - 'SetVisible', 'b', 'true']) - .catch(print); - } - - static closeOsk() { - execAsync(['busctl', 'call', '--user', - 'sm.puri.OSK0', '/sm/puri/OSK0', 'sm.puri.OSK0', - 'SetVisible', 'b', 'false']) - .catch(print); - } - toggleOsk() { - if (this.#oskState) { - Tablet.closeOsk(); - } - else { - Tablet.openOsk(); - } + this.#oskState = !this.#oskState; + this.emit('osk-toggled', this.#oskState); } } diff --git a/modules/ags/config/ts/on-screen-keyboard/gesture.ts b/modules/ags/config/ts/on-screen-keyboard/gesture.ts index d2a6c32..e47e8db 100644 --- a/modules/ags/config/ts/on-screen-keyboard/gesture.ts +++ b/modules/ags/config/ts/on-screen-keyboard/gesture.ts @@ -11,7 +11,7 @@ const HIDDEN_MARGIN = 340; const ANIM_DURATION = 700; // Types -import { BoxGeneric } from 'global-types'; +import { OskWindow } from 'global-types'; const releaseAllKeys = () => { @@ -23,11 +23,10 @@ const releaseAllKeys = () => { ]).catch(print); }; -export default (window) => { +export default (window: OskWindow) => { const gesture = Gtk.GestureDrag.new(window); - const child = window.child as BoxGeneric; - child.setCss(`margin-bottom: -${HIDDEN_MARGIN}px;`); + window.child.setCss(`margin-bottom: -${HIDDEN_MARGIN}px;`); let signals = [] as Array; @@ -39,14 +38,14 @@ export default (window) => { window.visible = true; window.attribute.setSlideDown(); - child.setCss(` + window.child.setCss(` transition: margin-bottom 0.7s cubic-bezier(0.36, 0, 0.66, -0.56); margin-bottom: 0px; `); } else { - timeout(ANIM_DURATION + 10, () => { + timeout(ANIM_DURATION + 100 + 100, () => { if (!Tablet.tabletMode) { window.visible = false; } @@ -54,7 +53,7 @@ export default (window) => { releaseAllKeys(); window.attribute.setSlideUp(); - child.setCss(` + window.child.setCss(` transition: margin-bottom 0.7s cubic-bezier(0.36, 0, 0.66, -0.56); margin-bottom: -${HIDDEN_MARGIN}px; @@ -86,6 +85,10 @@ export default (window) => { signals.push( gesture.connect('drag-update', () => { Hyprland.messageAsync('j/cursorpos').then((out) => { + if (!window.attribute.startY) { + return; + } + const currentY = JSON.parse(out).y; const offset = window.attribute.startY - currentY; @@ -93,7 +96,7 @@ export default (window) => { return; } - (window.child as BoxGeneric).setCss(` + window.child.setCss(` margin-bottom: ${offset - HIDDEN_MARGIN}px; `); }); @@ -103,7 +106,7 @@ export default (window) => { // End drag signals.push( gesture.connect('drag-end', () => { - (window.child as BoxGeneric).setCss(` + window.child.setCss(` transition: margin-bottom 0.5s ease-in-out; margin-bottom: -${HIDDEN_MARGIN}px; `); @@ -127,6 +130,10 @@ export default (window) => { signals.push( gesture.connect('drag-update', () => { Hyprland.messageAsync('j/cursorpos').then((out) => { + if (!window.attribute.startY) { + return; + } + const currentY = JSON.parse(out).y; const offset = window.attribute.startY - currentY; @@ -134,7 +141,7 @@ export default (window) => { return; } - (window.child as BoxGeneric).setCss(` + window.child.setCss(` margin-bottom: ${offset}px; `); }); @@ -144,7 +151,7 @@ export default (window) => { // End drag signals.push( gesture.connect('drag-end', () => { - (window.child as BoxGeneric).setCss(` + window.child.setCss(` transition: margin-bottom 0.5s ease-in-out; margin-bottom: 0px; `); diff --git a/modules/ags/config/ts/on-screen-keyboard/keyboard.ts b/modules/ags/config/ts/on-screen-keyboard/keyboard.ts index 4fbb8ed..2cc688d 100644 --- a/modules/ags/config/ts/on-screen-keyboard/keyboard.ts +++ b/modules/ags/config/ts/on-screen-keyboard/keyboard.ts @@ -16,10 +16,10 @@ const COLOR = 'rgba(0, 0, 0, 0.3)'; const SPACING = 4; // Types -import { BoxGeneric, WindowGeneric } from 'global-types'; +import { BoxGeneric, OskWindow } from 'global-types'; -export default (window: WindowGeneric) => Box({ +export default (window: OskWindow) => Box({ vertical: true, children: [ CenterBox({ diff --git a/modules/ags/config/ts/on-screen-keyboard/main.ts b/modules/ags/config/ts/on-screen-keyboard/main.ts index b5f8683..6144959 100644 --- a/modules/ags/config/ts/on-screen-keyboard/main.ts +++ b/modules/ags/config/ts/on-screen-keyboard/main.ts @@ -5,6 +5,8 @@ import Tablet from '../../services/tablet.ts'; import Gesture from './gesture.ts'; import Keyboard from './keyboard.ts'; +/* Types */ +import { OskWindow } from 'global-types'; // Start ydotool daemon execAsync('ydotoold').catch(print); @@ -13,24 +15,16 @@ execAsync('ydotoold').catch(print); export default () => { const window = Window({ name: 'osk', - visible: false, layer: 'overlay', anchor: ['left', 'bottom', 'right'], + }) + .hook(Tablet, (self: OskWindow, state) => { + self.attribute.setVisible(state); + }, 'osk-toggled') - setup: (self) => { - self - .hook(Tablet, (_, state) => { - // @ts-expect-error too lazy to do keyboard type - self.attribute.setVisible(state); - }, 'osk-toggled') - - .hook(Tablet, () => { - if (!Tablet.tabletMode && !Tablet.oskState) { - window.visible = false; - } - }, 'mode-toggled'); - }, - }); + .hook(Tablet, () => { + window.visible = !(!Tablet.tabletMode && !Tablet.oskState); + }, 'mode-toggled'); window.child = Keyboard(window); diff --git a/modules/ags/config/ts/setup.ts b/modules/ags/config/ts/setup.ts index 36cd80f..17d8fb5 100644 --- a/modules/ags/config/ts/setup.ts +++ b/modules/ags/config/ts/setup.ts @@ -1,4 +1,3 @@ -const Hyprland = await Service.import('hyprland'); const Bluetooth = await Service.import('bluetooth'); import Brightness from '../services/brightness.ts'; @@ -34,33 +33,17 @@ export default () => { name: 'oskOn', gesture: 'DU', edge: 'B', - command: 'busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 ' + - 'SetVisible b true', + command: () => { + Tablet.oskState = true; + }, }); TouchGestures.addGesture({ name: 'oskOff', gesture: 'UD', edge: 'B', - command: 'busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 ' + - 'SetVisible b false', - }); - - TouchGestures.addGesture({ - name: 'swipeSpotify1', - gesture: 'LR', - edge: 'L', - command: () => Hyprland.messageAsync( - 'dispatch togglespecialworkspace spot', - ), - }); - - TouchGestures.addGesture({ - name: 'swipeSpotify2', - gesture: 'RL', - edge: 'L', - command: () => Hyprland.messageAsync( - 'dispatch togglespecialworkspace spot', - ), + command: () => { + Tablet.oskState = false; + }, }); }; diff --git a/modules/ags/default.nix b/modules/ags/default.nix index d10c4b6..c6b5d0a 100644 --- a/modules/ags/default.nix +++ b/modules/ags/default.nix @@ -88,7 +88,6 @@ in { ]) ++ (optionals isTouchscreen (with pkgs; [ lisgd - squeekboard ydotool ])); }; @@ -100,12 +99,10 @@ in { "layers, 0" ]; - exec-once = - [ - "ags" - "sleep 3; ags -r 'App.openWindow(\"applauncher\")'" - ] - ++ optionals isTouchscreen ["squeekboard"]; + exec-once = [ + "ags" + "sleep 3; ags -r 'App.openWindow(\"applauncher\")'" + ]; bind = [ "$mainMod SHIFT, E, exec, ags -t powermenu"