feat(ags lisgd): allow setting ags functions as lisgd command

This commit is contained in:
matt1432 2023-11-06 20:38:16 -05:00
parent b2e4c84545
commit 107fb94fe8
4 changed files with 23 additions and 38 deletions

View file

@ -2,11 +2,10 @@ import App from 'resource:///com/github/Aylur/ags/app.js';
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js'; import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
import Variable from 'resource:///com/github/Aylur/ags/variable.js'; import Variable from 'resource:///com/github/Aylur/ags/variable.js';
import { Widget, Box, EventBox, Overlay } from 'resource:///com/github/Aylur/ags/widget.js'; import { Box, EventBox, Overlay, Revealer } from 'resource:///com/github/Aylur/ags/widget.js';
import { timeout } from 'resource:///com/github/Aylur/ags/utils.js'; import { timeout } from 'resource:///com/github/Aylur/ags/utils.js';
import { RoundedCorner } from '../screen-corners.js'; import { RoundedCorner } from '../screen-corners.js';
import Gesture from './gesture.js';
const Revealed = Variable(true); const Revealed = Variable(true);
const Hovering = Variable(false); const Hovering = Variable(false);
@ -31,17 +30,14 @@ export default props => Overlay({
hexpand: true, hexpand: true,
vertical: true, vertical: true,
children: [ children: [
Widget.Revealer({ Revealer({
transition: 'slide_down', transition: 'slide_down',
setup: self => self.revealChild = true, setup: self => self.revealChild = true,
properties: [['timeouts', []]], properties: [['timeouts', []]],
connections: [[Revealed, self => { connections: [[Revealed, self => {
const Bar = App.getWindow('bar'); App.getWindow('bar').setCss(Revealed.value ? '' : wStyle);
Bar.setCss(Revealed.value ? '' : wStyle); App.getWindow('bg-gradient').visible = !Revealed.value;
const BgGradient = App.getWindow('bg-gradient');
BgGradient.visible = !Revealed.value;
if (Revealed.value) { if (Revealed.value) {
timeout(2000, () => { timeout(2000, () => {
@ -54,13 +50,14 @@ export default props => Overlay({
} }
}]], }]],
child: Gesture({ child: EventBox({
onHover: () => Hovering.value = true, onHover: () => Hovering.value = true,
onHoverLost: self => { onHoverLost: self => {
Hovering.value = false; Hovering.value = false;
if (Revealed.value) { if (Revealed.value) {
timeout(2000, () => { timeout(2000, () => {
if (!Hovering.value) { if (!Hovering.value) {
// Replace bar with transparent eventbox
self.get_parent().get_parent().children[1].revealChild = true; self.get_parent().get_parent().children[1].revealChild = true;
self.get_parent().revealChild = false; self.get_parent().revealChild = false;
} }
@ -71,7 +68,7 @@ export default props => Overlay({
}), }),
}), }),
Widget.Revealer({ Revealer({
connections: [[Revealed, self => { connections: [[Revealed, self => {
if (Revealed.value) { if (Revealed.value) {
timeout(2000, () => { timeout(2000, () => {
@ -86,11 +83,13 @@ export default props => Overlay({
child: EventBox({ child: EventBox({
onHover: self => { onHover: self => {
Hovering.value = true; Hovering.value = true;
// Replace eventbox with bar
self.get_parent().get_parent().children[0].revealChild = true; self.get_parent().get_parent().children[0].revealChild = true;
self.get_parent().revealChild = false; self.get_parent().revealChild = false;
}, },
child: Box({ child: Box({
css: 'min-height: 50px;', css: 'min-height: 5px;',
}), }),
}), }),
}), }),

View file

@ -1,27 +0,0 @@
import App from 'resource:///com/github/Aylur/ags/app.js';
import { CenterBox, EventBox } from 'resource:///com/github/Aylur/ags/widget.js';
import Gtk from 'gi://Gtk';
export default ({
child,
...props
}) => {
const widget = EventBox({
...props,
});
const gesture = Gtk.GestureSwipe.new(widget);
widget.add(CenterBox({
children: [child],
connections: [[gesture, () => {
const velocity = gesture.get_velocity()[1];
if (velocity < -100)
App.openWindow('applauncher');
}, 'update']],
}));
return widget;
};

View file

@ -1,3 +1,4 @@
import App from 'resource:///com/github/Aylur/ags/app.js';
import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js'; import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js';
import Tablet from '../services/tablet.js'; import Tablet from '../services/tablet.js';
@ -13,6 +14,13 @@ export default () => {
execAsync(['bash', '-c', '$AGS_PATH/startup.sh']).catch(print); execAsync(['bash', '-c', '$AGS_PATH/startup.sh']).catch(print);
TouchGestures.addGesture({
name: 'openAppLauncher',
gesture: 'UD',
edge: 'T',
command: () => App.openWindow('applauncher'),
});
TouchGestures.addGesture({ TouchGestures.addGesture({
name: 'oskOn', name: 'oskOn',
gesture: 'DU', gesture: 'DU',

View file

@ -78,6 +78,11 @@ class TouchGestures extends Service {
return; return;
} }
if (typeof command !== 'string') {
globalThis[name] = command;
command = `ags -r "${name}()"`;
}
this.gestures.set(name, [ this.gestures.set(name, [
'-g', '-g',
`${nFingers},${gesture},${edge},${distance},${command}`, `${nFingers},${gesture},${edge},${distance},${command}`,