Compare commits
3 commits
b0710205e6
...
63c5d0b72f
Author | SHA1 | Date | |
---|---|---|---|
63c5d0b72f | |||
6ab95385ee | |||
f065d595a1 |
8 changed files with 101 additions and 80 deletions
|
@ -21,7 +21,6 @@ exec(`sassc ${scss} ${css}`);
|
|||
Setup();
|
||||
|
||||
|
||||
// TODO: get rid of 'properties' and 'binds' prop
|
||||
export default {
|
||||
style: css,
|
||||
notificationPopupTimeout: 5000,
|
||||
|
|
|
@ -80,6 +80,7 @@ const ModKey = (key) => {
|
|||
const button = EventBox({
|
||||
cursor: 'pointer',
|
||||
class_name: 'key',
|
||||
|
||||
on_primary_click_release: (self) => {
|
||||
console.log('mod toggled');
|
||||
|
||||
|
@ -89,6 +90,7 @@ const ModKey = (key) => {
|
|||
self.child.toggleClassName('active', !Mod.value);
|
||||
Mod.value = !Mod.value;
|
||||
},
|
||||
|
||||
setup: (self) => {
|
||||
self.hook(NormalClick, () => {
|
||||
Mod.value = false;
|
||||
|
|
|
@ -7,14 +7,13 @@ import PopupWindow from './misc/popup.js';
|
|||
import CursorBox from './misc/cursorbox.js';
|
||||
|
||||
|
||||
// FIXME: eventboxes are the wrong size
|
||||
const PowermenuWidget = () => CenterBox({
|
||||
class_name: 'powermenu',
|
||||
// @ts-expect-error
|
||||
vertical: false,
|
||||
|
||||
start_widget: CursorBox({
|
||||
class_name: 'shutdown',
|
||||
class_name: 'shutdown button',
|
||||
on_primary_click_release: () => execAsync(['systemctl', 'poweroff'])
|
||||
.catch(print),
|
||||
|
||||
|
@ -24,7 +23,7 @@ const PowermenuWidget = () => CenterBox({
|
|||
}),
|
||||
|
||||
center_widget: CursorBox({
|
||||
class_name: 'reboot',
|
||||
class_name: 'reboot button',
|
||||
on_primary_click_release: () => execAsync(['systemctl', 'reboot'])
|
||||
.catch(print),
|
||||
|
||||
|
@ -34,7 +33,7 @@ const PowermenuWidget = () => CenterBox({
|
|||
}),
|
||||
|
||||
end_widget: CursorBox({
|
||||
class_name: 'logout',
|
||||
class_name: 'logout button',
|
||||
on_primary_click_release: () => Hyprland.sendMessage('dispatch exit')
|
||||
.catch(print),
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ export default () => Box({
|
|||
Icon({
|
||||
size: 26,
|
||||
class_name: 'slider-label',
|
||||
binds: [['icon', SpeakerIcon, 'value']],
|
||||
icon: SpeakerIcon.bind(),
|
||||
}),
|
||||
|
||||
Slider({
|
||||
|
@ -62,7 +62,7 @@ export default () => Box({
|
|||
children: [
|
||||
Icon({
|
||||
class_name: 'slider-label',
|
||||
binds: [['icon', Brightness, 'screen-icon']],
|
||||
icon: Brightness.bind('screenIcon'),
|
||||
}),
|
||||
|
||||
Slider({
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
min-height: 130px;
|
||||
}
|
||||
|
||||
button {
|
||||
.button {
|
||||
margin: 5px 10px;
|
||||
border-radius: 12px;
|
||||
min-width: 80px;
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import App from 'resource:///com/github/Aylur/ags/app.js';
|
||||
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||
import Service from 'resource:///com/github/Aylur/ags/service.js';
|
||||
|
||||
import { subprocess } from 'resource:///com/github/Aylur/ags/utils.js';
|
||||
import GUdev from 'gi://GUdev';
|
||||
|
||||
const { GUdev } = imports.gi;
|
||||
|
||||
const UDEV_POINTERS = [
|
||||
'ID_INPUT_MOUSE',
|
||||
|
@ -34,8 +36,10 @@ class Pointers extends Service {
|
|||
});
|
||||
}
|
||||
|
||||
/** @type typeof imports.gi.Gio.Subprocess */
|
||||
#process;
|
||||
#lastLine = '';
|
||||
/** @type Array<string> */
|
||||
#pointers = [];
|
||||
#udevClient = GUdev.Client.new(['input']);
|
||||
|
||||
|
@ -60,7 +64,12 @@ class Pointers extends Service {
|
|||
// FIXME: logitech mouse screws everything up on disconnect
|
||||
#initUdevConnection() {
|
||||
this.#getDevices();
|
||||
this.#udevClient.connect('uevent', (_, action) => {
|
||||
this.#udevClient.connect('uevent',
|
||||
/**
|
||||
* @param {typeof imports.gi.GUdev.Client} _
|
||||
* @param {string} action
|
||||
*/
|
||||
(_, action) => {
|
||||
if (action === 'add' || action === 'remove') {
|
||||
this.#getDevices();
|
||||
if (this.#process) {
|
||||
|
@ -73,8 +82,12 @@ class Pointers extends Service {
|
|||
|
||||
#getDevices() {
|
||||
this.#pointers = [];
|
||||
this.#udevClient.query_by_subsystem('input').forEach((dev) => {
|
||||
const isPointer = UDEV_POINTERS.some((p) => dev.has_property(p));
|
||||
this.#udevClient.query_by_subsystem('input').forEach(
|
||||
/** @param {typeof imports.gi.GUdev.Device} dev */
|
||||
(dev) => {
|
||||
const isPointer = UDEV_POINTERS.some(
|
||||
(p) => dev.has_property(p),
|
||||
);
|
||||
|
||||
if (isPointer) {
|
||||
const hasEventFile = dev.has_property('DEVNAME') &&
|
||||
|
@ -85,7 +98,8 @@ class Pointers extends Service {
|
|||
this.#pointers.push(dev.get_property('DEVNAME'));
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
this.emit('device-fetched', true);
|
||||
}
|
||||
|
@ -123,7 +137,6 @@ class Pointers extends Service {
|
|||
this.emit('new-line', output);
|
||||
}
|
||||
},
|
||||
(err) => logError(err),
|
||||
);
|
||||
this.emit('proc-started', true);
|
||||
}
|
||||
|
@ -139,8 +152,11 @@ class Pointers extends Service {
|
|||
#initAppConnection() {
|
||||
App.connect('window-toggled', () => {
|
||||
const anyVisibleAndClosable = Array.from(App.windows).some((w) => {
|
||||
// @ts-expect-error
|
||||
const closable = w[1].attribute?.close_on_unfocus &&
|
||||
// @ts-expect-error
|
||||
!(w[1].attribute?.close_on_unfocus === 'none' ||
|
||||
// @ts-expect-error
|
||||
w[1].attribute?.close_on_unfocus === 'stay');
|
||||
|
||||
return w[1].visible && closable;
|
||||
|
@ -156,9 +172,12 @@ class Pointers extends Service {
|
|||
});
|
||||
}
|
||||
|
||||
/** @param {string} clickStage */
|
||||
static detectClickedOutside(clickStage) {
|
||||
const toClose = Array.from(App.windows).some((w) => {
|
||||
// @ts-expect-error
|
||||
const closable = (w[1].attribute?.close_on_unfocus &&
|
||||
// @ts-expect-error
|
||||
w[1].attribute?.close_on_unfocus === clickStage);
|
||||
|
||||
return w[1].visible && closable;
|
||||
|
@ -168,22 +187,31 @@ class Pointers extends Service {
|
|||
return;
|
||||
}
|
||||
|
||||
Hyprland.sendMessage('j/layers').then((layers) => {
|
||||
layers = JSON.parse(layers);
|
||||
Hyprland.sendMessage('j/layers').then((response) => {
|
||||
// /** @type import('types/service/hyprland').Layer */
|
||||
const layers = JSON.parse(response);
|
||||
|
||||
Hyprland.sendMessage('j/cursorpos').then((pos) => {
|
||||
pos = JSON.parse(pos);
|
||||
Hyprland.sendMessage('j/cursorpos').then((res) => {
|
||||
const pos = JSON.parse(res);
|
||||
|
||||
Object.values(layers).forEach((key) => {
|
||||
const bar = key.levels['3']
|
||||
.find((n) => n.namespace === 'bar');
|
||||
const bar = key.levels['3'].find(
|
||||
/** @param {{ namespace: string }} n */
|
||||
(n) => n.namespace === 'bar',
|
||||
);
|
||||
|
||||
const widgets = key.levels['3'].filter((n) => {
|
||||
const widgets = key.levels['3'].filter(
|
||||
/** @param {{ namespace: string }} n */
|
||||
(n) => {
|
||||
const window = App.getWindow(n.namespace);
|
||||
|
||||
// @ts-expect-error
|
||||
return window?.attribute?.close_on_unfocus &&
|
||||
window?.attribute?.close_on_unfocus === clickStage;
|
||||
});
|
||||
// @ts-expect-error
|
||||
window?.attribute
|
||||
?.close_on_unfocus === clickStage;
|
||||
},
|
||||
);
|
||||
|
||||
if (pos.x > bar?.x && pos.x < bar?.x + bar?.w &&
|
||||
pos.y > bar?.y && pos.y < bar?.y + bar?.h) {
|
||||
|
@ -192,12 +220,22 @@ class Pointers extends Service {
|
|||
// TODO: make this configurable
|
||||
}
|
||||
else {
|
||||
widgets.forEach((w) => {
|
||||
widgets.forEach(
|
||||
/** @param {{
|
||||
* namespace: string
|
||||
* x: number
|
||||
* y: number
|
||||
* h: number
|
||||
* w: number
|
||||
* }} w
|
||||
*/
|
||||
(w) => {
|
||||
if (!(pos.x > w.x && pos.x < w.x + w.w &&
|
||||
pos.y > w.y && pos.y < w.y + w.h)) {
|
||||
App.closeWindow(w.namespace);
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
});
|
||||
}).catch(print);
|
||||
|
|
|
@ -2,7 +2,6 @@ import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
|||
import Service from 'resource:///com/github/Aylur/ags/service.js';
|
||||
import TouchGestures from './touch-gestures.js';
|
||||
import { execAsync, subprocess } from 'resource:///com/github/Aylur/ags/utils.js';
|
||||
import GUdev from 'gi://GUdev';
|
||||
|
||||
const ROTATION_MAP = {
|
||||
'normal': 0,
|
||||
|
@ -11,6 +10,10 @@ const ROTATION_MAP = {
|
|||
'left-up': 1,
|
||||
};
|
||||
const SCREEN = 'desc:BOE 0x0964';
|
||||
const DEVICES = [
|
||||
'wacom-hid-52eb-finger',
|
||||
'wacom-hid-52eb-pen',
|
||||
];
|
||||
|
||||
|
||||
class Tablet extends Service {
|
||||
|
@ -30,9 +33,10 @@ class Tablet extends Service {
|
|||
|
||||
#tabletMode = false;
|
||||
#oskState = false;
|
||||
/** @type typeof imports.gi.Gio.Subprocess */
|
||||
#autorotate;
|
||||
/** @type typeof imports.gi.Gio.Subprocess */
|
||||
#blockedInputs;
|
||||
#udevClient = GUdev.Client.new(['input']);
|
||||
|
||||
get tabletMode() {
|
||||
return this.#tabletMode;
|
||||
|
@ -44,7 +48,6 @@ class Tablet extends Service {
|
|||
|
||||
constructor() {
|
||||
super();
|
||||
this.#initUdevConnection();
|
||||
this.#listenOskState();
|
||||
}
|
||||
|
||||
|
@ -59,8 +62,7 @@ class Tablet extends Service {
|
|||
'--device', '/dev/input/by-path/platform-AMDI0010:02-event-mouse',
|
||||
'--device', '/dev/input/by-path/platform-thinkpad_acpi-event',
|
||||
'--device', '/dev/video-bus'],
|
||||
() => { /**/ },
|
||||
(err) => logError(err));
|
||||
() => { /**/ });
|
||||
this.emit('inputs-blocked', true);
|
||||
}
|
||||
|
||||
|
@ -113,31 +115,6 @@ class Tablet extends Service {
|
|||
this.emit('mode-toggled', true);
|
||||
}
|
||||
|
||||
#initUdevConnection() {
|
||||
this.#getDevices();
|
||||
this.#udevClient.connect('uevent', (_, action) => {
|
||||
if (action === 'add' || action === 'remove') {
|
||||
this.#getDevices();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#getDevices() {
|
||||
this.devices = [];
|
||||
Hyprland.sendMessage('j/devices').then((out) => {
|
||||
const devices = JSON.parse(out);
|
||||
|
||||
devices.touch.forEach((dev) => {
|
||||
this.devices.push(dev.name);
|
||||
});
|
||||
devices.tablets.forEach((dev) => {
|
||||
this.devices.push(dev.name);
|
||||
});
|
||||
}).catch(print);
|
||||
|
||||
this.emit('device-fetched', true);
|
||||
}
|
||||
|
||||
startAutorotate() {
|
||||
if (this.#autorotate) {
|
||||
return;
|
||||
|
@ -153,7 +130,7 @@ class Tablet extends Service {
|
|||
`keyword monitor ${SCREEN},transform,${orientation}`,
|
||||
).catch(print);
|
||||
|
||||
const batchRotate = this.devices.map((dev) =>
|
||||
const batchRotate = DEVICES.map((dev) =>
|
||||
`keyword device:${dev}:transform ${orientation}; `);
|
||||
|
||||
Hyprland.sendMessage(`[[BATCH]] ${batchRotate.flat()}`);
|
||||
|
@ -164,7 +141,6 @@ class Tablet extends Service {
|
|||
}
|
||||
}
|
||||
},
|
||||
(err) => logError(err),
|
||||
);
|
||||
this.emit('autorotate-started', true);
|
||||
}
|
||||
|
@ -182,11 +158,14 @@ class Tablet extends Service {
|
|||
['bash', '-c', 'busctl monitor --user sm.puri.OSK0'],
|
||||
(output) => {
|
||||
if (output.includes('BOOLEAN')) {
|
||||
this.#oskState = output.match('true|false')[0] === 'true';
|
||||
const match = output.match('true|false');
|
||||
|
||||
if (match) {
|
||||
this.#oskState = match[0] === 'true';
|
||||
this.emit('osk-toggled', this.#oskState);
|
||||
}
|
||||
}
|
||||
},
|
||||
(err) => logError(err),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,12 +44,17 @@ class TouchGestures extends Service {
|
|||
}
|
||||
|
||||
#gestures = new Map();
|
||||
/** @type typeof imports.gi.Gio.Subprocess */
|
||||
#gestureDaemon;
|
||||
|
||||
get gestures() {
|
||||
return this.#gestures;
|
||||
}
|
||||
|
||||
get gestureDaemon() {
|
||||
return this.#gestureDaemon;
|
||||
}
|
||||
|
||||
addGesture({
|
||||
name,
|
||||
nFingers = '1',
|
||||
|
@ -57,7 +62,7 @@ class TouchGestures extends Service {
|
|||
edge = '*',
|
||||
distance = '*',
|
||||
command,
|
||||
} = {}) {
|
||||
}) {
|
||||
gesture = String(gesture).toUpperCase();
|
||||
if (!GESTURE_VERIF.includes(gesture)) {
|
||||
logError('Wrong gesture id');
|
||||
|
@ -119,7 +124,6 @@ class TouchGestures extends Service {
|
|||
this.#gestureDaemon = subprocess(
|
||||
command,
|
||||
() => { /**/ },
|
||||
(err) => logError(err),
|
||||
);
|
||||
this.emit('daemon-started', true);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue