feat(ags): remove squeekboard dependency
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-04-07 11:34:44 -04:00
parent 9766d98542
commit 4e7904775b
11 changed files with 54 additions and 155 deletions

View file

@ -1,6 +1,5 @@
{nixpkgs-wayland, ...} @ inputs: [
(import ./dracula-theme inputs)
(import ./squeekboard)
nixpkgs-wayland.overlay
]

View file

@ -1,7 +0,0 @@
final: prev: {
squeekboard = prev.squeekboard.overrideAttrs (o: {
patches =
(o.patches or [])
++ [./remove-panel.patch];
});
}

View file

@ -1,41 +0,0 @@
From 10be06ebc72ec8f516003577dabcedb60fe05982 Mon Sep 17 00:00:00 2001
From: matt1432 <matt@nelim.org>
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

View file

@ -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

View file

@ -100,6 +100,15 @@ export type OSD = {
}
};
// For ./ts/on-screen-keyboard
export type OskWindow = Window<BoxGeneric, {
startY: null | number;
setVisible: (state: boolean) => void;
killGestureSigs: () => void;
setSlideUp: () => void;
setSlideDown: () => void;
}>;
// For CursorBox
import { CursorBox, CursorBoxProps } from 'ts/misc/cursorbox';
export type CursorBox = CursorBox;

View file

@ -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);
}
}

View file

@ -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<number>;
@ -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;
`);

View file

@ -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({

View file

@ -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);

View file

@ -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;
},
});
};

View file

@ -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"